In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article is to share with you about using strace to find the reasons for Emacs startup blocking. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Due to the use of the configuration of spacemacs, the configuration is more complex, so I don't want to find out the problem by experimenting with reducing the configuration. I happened to be learning to use the strace tool recently, so I decided to use strace to see where Emacs got stuck.
Strace emacs-fg-daemon
There is a lot of output. Here, only part of the content before stutter is intercepted.
Readlinkat (AT_FDCWD, "/ home", 0x7ffd1d3abb50, 1024) =-1 EINVAL (invalid parameter) readlinkat (AT_FDCWD, "/ home/lujun9972", 0x7ffd1d3abf00, 1024) =-1 EINVAL (invalid parameter) readlinkat (AT_FDCWD, "/ home/lujun9972/.emacs.d", 0x7ffd1d3ac2b0, 1024) =-1 EINVAL (invalid parameter) readlinkat (AT_FDCWD, "/ home/lujun9972/.emacs.d/elpa", 0x7ffd1d3ac660, 1024) =-1 EINVAL (invalid parameter) readlinkat (AT_FDCWD) "/ home/lujun9972/.emacs.d/elpa/exec-path-from-shell-20180323.1904", 0x7ffd1d3aca10, 1024) =-1 EINVAL (invalid parameter) readlinkat (AT_FDCWD, "/ home/lujun9972/.emacs.d/elpa/exec-path-from-shell-20180323.1904/exec-path-from-shell.elc", 0x7ffd1d3acdc0, 1024) =-1 EINVAL (invalid parameter) lseek (7,-2655, SEEK_CUR) = 1441read (7 "\ n (defvar exec-path-from-shell-de", 4096) = 4096lseek (7, 5537, SEEK_SET) = 5537lseek (7, 5537, SEEK_SET) = 5537lseek (7, 5537) SEEK_SET) = 5537brk (0x7507000) = 0x7507000lseek (7, 5537, SEEK_SET) = 5537lseek (7, 5537, SEEK_SET) = 5537lseek (7, 5537, SEEK_SET) = 5537read (7 4096) = 2430lseek (7, 7967, SEEK_SET) = 7967lseek (7, 7967, SEEK_SET) = 7967read (7, "" 4096) = 0close (7) = 0getpid () = 10818faccessat (AT_FDCWD, "/ home/lujun9972/bin/printf", X_OK) =-1 ENOENT (no that file or directory) faccessat (AT_FDCWD, "/ usr/local/sbin/printf" X_OK) =-1 ENOENT (no file or directory) faccessat (AT_FDCWD, "/ usr/local/bin/printf", X_OK) =-1 ENOENT (no that file or directory) faccessat (AT_FDCWD, "/ usr/bin/printf", X_OK) = 0stat ("/ usr/bin/printf", {st_mode=S_IFREG | 0755, st_size=51176,...}) = 0openat (AT_FDCWD, "/ dev/null") O_RDONLY | O_CLOEXEC) = 7faccessat (AT_FDCWD, "/ proc/5070/fd/.", F_OK) = 0faccessat (AT_FDCWD, "/ proc/5070/fd/.", F_OK) = 0faccessat (AT_FDCWD, "/ bin/bash", X_OK) = 0stat ("/ bin/bash", {st_mode=S_IFREG | 0755, st_size=903440,...}) = 0pipe2 ([8,9], O_CLOEXEC) = 0rt_sigprocmask (SIG_BLOCK) [INT CHLD], [], 8) = 0vfork () = 10949rt_sigprocmask (SIG_SETMASK, [], NULL, 8) = 0close (9) = 0close (7) = 0read (8) "bash:\ 346\ 2277\ 347\ 257", 16384) = 74read (8, "bash:\ 346\ 255\ 244 shell\ 344\ 270\ 346\ 346", 16310) = 35read (8) "setterm:\ 347\ 273\ 347\ 257 xterm-256color\ 344"..., 16275) = 51read (8, "Couldn't get a file descriptor r", 16224) = 56read (8, "bash: [:\ 357\ 274\ 232\ 351\ 234\ 350\ 346\ 346\ 245\ 274", 16168) = 34read (8) "Your display number is 0\ n", 16134) = 25read (8, "Test whether fcitx is running co"..., 16109) = 53read (8, "Fcitx is running correctly.\ n\ nThe 0/home/lujun9972/bin:/ho =", 16056) = 87read (8, "Launch fbterm...\ n", 15969) = 17read (8, "stdin isn't a tty!\ n", 15952) = 19read (8, "_ RESULT\ 0/home/lujun9972/bin:/ho"..., 15933) = 298read (8, 0x7ffd1d39ce9d) 15635) =? ERESTARTSYS (To be restarted if SA_RESTART is set)-SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=10949, si_uid=1000, si_status=0, si_utime=10, si_stime=7}-- rt_sigreturn ({mask= []}) =-1 EINTR (interrupted system call) read (8, ", 15635) = 0wait4 (10949, [{WIFEXITED (s) & & WEXITSTATUS (s) = = 0}], 0 NULL) = 10949close (8) = 0getpid () = 10818faccessat (AT_FDCWD, "/ home/lujun9972/bin/printf", X_OK) =-1 ENOENT (no that file or directory) faccessat (AT_FDCWD, "/ usr/local/sbin/printf", X_OK) =-1 ENOENT (no that file or directory) faccessat (AT_FDCWD "/ usr/local/bin/printf", X_OK) =-1 ENOENT (no file or directory) faccessat (AT_FDCWD, "/ usr/bin/printf", X_OK) = 0stat ("/ usr/bin/printf", {st_mode=S_IFREG | 0755, st_size=51176,...}) = 0openat (AT_FDCWD, "/ dev/null", O_RDONLY | O_CLOEXEC) = 7faccessat (AT_FDCWD, "/ proc/5070/fd/.", F_OK) = 0faccessat (AT_FDCWD) "/ proc/5070/fd/.", F_OK) = 0faccessat (AT_FDCWD, "/ bin/bash", X_OK) = 0stat ("/ bin/bash", {st_mode=S_IFREG | 0755, st_size=903440,...}) = 0pipe2 ([8,9], O_CLOEXEC) = 0rt_sigprocmask (SIG_BLOCK, [INT CHLD], [] 8) = 0vfork () = 11679rt_sigprocmask (SIG_SETMASK, [], NULL, 8) = 0close (9) = 0close (7) = 0read (8, "setterm:\ 347\ 273\ 210\ 347\ 253 xterm-256color\ 344", 16384) = 51read (8) "Couldn't get a file descriptor r"..., 16333) = 56read (8, "/ home/lujun9972/.bash_profile:\ 347"..., 16277) = 72read (8, "Your display number is 0\ nTest wh"..., 16205) = 78read (8, "Fcitx is running correctly.\ n\ nThe RESULT ="..., 16127) = 104read (8, "stdin isn't a tty!\ n", 16023) = 19read (8, "_ _ RESULT\ 0b269cd09e7ec4e8a115188c"... 16004) = 298read (8, 0x7ffd1d39cba6, 15706) =? ERESTARTSYS (To be restarted if SA_RESTART is set)-SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=11679, si_uid=1000, si_status=0, si_utime=1, si_stime=1}-rt_sigreturn ({mask= []}) =-1 EINTR (interrupted system call) read (8
It is easy to see that when Emacs stutters, it is trying to read from the No. 8 file handle.
So where is the No. 8 file handle defined? Looking ahead, you can see:
Pipe2 ([8,9], O_CLOEXEC) = 0rt_sigprocmask (SIG_BLOCK, [INT CHLD], [], 8) = 0vfork () = 11679rt_sigprocmask (SIG_SETMASK, [], NULL, 8) = 0close (9) = 0
It can be inferred that the Emacs main process fork produces a child process (process number is 11679) and reads the contents of the child process through the pipeline.
However, from
-SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=11679, si_uid=1000, si_status=0, si_utime=1, si_stime=1}-rt_sigreturn ({mask= []}) =-1 EINTR (interrupted system call) read (8
As you can see, in fact, the child process has exited (the parent process received a SIGCHLD signal), and the parent process is still trying to read from the pipe, resulting in blocking.
And from
Read (8, "setterm:\ 347\ 273\ 210\ 347\ 257 xterm-256color\ 344"..., 16384) = 51read (8, "Couldn't get a file descriptor r"..., 16333) = 56read (8, "/ home/lujun9972/.bash_profile:\ 347"..., 16277) = 72read (8, "Your display number is 0\ nTest wh"..., 16205) = 78read (8, "Fcitx is running correctly.\ n\ nTest wh ="..., 16127) = 104read (8) "stdin isn't a tty!\ n", 16023) = 19read (8, "_ _ RESULT\ 0b269cd09e7ec4e8a115188c"..., 16004) = 298read (8, 0x7ffd1d39cba6, 15706) =? ERESTARTSYS (To be restarted if SA_RESTART is set)
As you can see, the output of the child process seems to be the output of my interactive login bash when it starts (.bash _ profile loaded)
Looking forward, I found this piece of information:
Readlinkat (AT_FDCWD, "/ home", 0x7ffd1d3abb50, 1024) =-1 EINVAL (invalid parameter) readlinkat (AT_FDCWD, "/ home/lujun9972", 0x7ffd1d3abf00, 1024) =-1 EINVAL (invalid parameter) readlinkat (AT_FDCWD, "/ home/lujun9972/.emacs.d", 0x7ffd1d3ac2b0, 1024) =-1 EINVAL (invalid parameter) readlinkat (AT_FDCWD, "/ home/lujun9972/.emacs.d/elpa", 0x7ffd1d3ac660, 1024) =-1 EINVAL (invalid parameter) readlinkat (AT_FDCWD) "/ home/lujun9972/.emacs.d/elpa/exec-path-from-shell-20180323.1904", 0x7ffd1d3aca10, 1024) =-1 EINVAL (invalid parameter) readlinkat (AT_FDCWD, "/ home/lujun9972/.emacs.d/elpa/exec-path-from-shell-20180323.1904/exec-path-from-shell.elc", 0x7ffd1d3acdc0, 1024) =-1 EINVAL (invalid parameter) lseek (7,-2655, SEEK_CUR) = 1441read (7 "\ n (defvar exec-path-from-shell-de", 4096) = 4096
This is obviously about exec-path-from-shell.
By looking at the implementation of exec-path-from-shell, it is found that exec-path-from-shell is implemented by actually calling a shell, and then outputting the values of PATH and MANPATH. And for bash, the default startup parameter is-I-l (which can be set through exec-path-from-shell-arguments). That is, bash will be launched as an interactive login shell, so .bash _ profile and .bashrc will be loaded.
Since it is found that it has something to do with the package exec-path-from-shell, and it is said that this package does not mean much to Linux, it would be better to disable it directly.
Dotspacemacs-excluded-packages'(exec-path-from-shell)
Restart Emacs again and find that the startup speed is much faster this time.
Thank you for reading! This is the end of this article on "using strace to find the reasons for Emacs startup blocking". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.