成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

使用strace查找Emacs啟動(dòng)阻塞的原因

系統(tǒng) Linux
之前就覺(jué)得我的 Emacs 啟動(dòng)好慢,查看啟動(dòng)日志會(huì)發(fā)現(xiàn)啟動(dòng)到一般的時(shí)候會(huì)有一個(gè)比較長(zhǎng)時(shí)間的卡頓。 之前一直沒(méi)有理會(huì)它,今天花了點(diǎn)時(shí)間探索了一下,發(fā)現(xiàn)罪魁禍?zhǔn)拙尤皇?exec-path-from-shell 這個(gè)包。

[[278222]]

之前就覺(jué)得我的 Emacs 啟動(dòng)好慢,查看啟動(dòng)日志會(huì)發(fā)現(xiàn)啟動(dòng)到一般的時(shí)候會(huì)有一個(gè)比較長(zhǎng)時(shí)間的卡頓。 之前一直沒(méi)有理會(huì)它,今天花了點(diǎn)時(shí)間探索了一下,發(fā)現(xiàn)罪魁禍?zhǔn)拙尤皇?exec-path-from-shell 這個(gè)包。

現(xiàn)將探索的過(guò)程記錄如下: 由于使用了 spacemacs 的配置,配置上比較復(fù)雜,不太想通過(guò)實(shí)驗(yàn)縮減配置的方式來(lái)摸索出問(wèn)題的地方。剛好最近在學(xué)習(xí)使用 strace 工具,因此決定使用 strace 來(lái)看看 Emacs 到底卡在哪里。

strace emacs --fg-daemon

輸出的內(nèi)容特別多,這里只截取卡頓前的部分內(nèi)容

  1. readlinkat(AT_FDCWD, "/home", 0x7ffd1d3abb50, 1024) = -1 EINVAL (無(wú)效的參數(shù))
  2. readlinkat(AT_FDCWD, "/home/lujun9972", 0x7ffd1d3abf00, 1024) = -1 EINVAL (無(wú)效的參數(shù))
  3. readlinkat(AT_FDCWD, "/home/lujun9972/.emacs.d", 0x7ffd1d3ac2b0, 1024) = -1 EINVAL (無(wú)效的參數(shù))
  4. readlinkat(AT_FDCWD, "/home/lujun9972/.emacs.d/elpa", 0x7ffd1d3ac660, 1024) = -1 EINVAL (無(wú)效的參數(shù))
  5. readlinkat(AT_FDCWD, "/home/lujun9972/.emacs.d/elpa/exec-path-from-shell-20180323.1904", 0x7ffd1d3aca10, 1024) = -1 EINVAL (無(wú)效的參數(shù))
  6. readlinkat(AT_FDCWD, "/home/lujun9972/.emacs.d/elpa/exec-path-from-shell-20180323.1904/exec-path-from-shell.elc", 0x7ffd1d3acdc0, 1024) = -1 EINVAL (無(wú)效的參數(shù))
  7. lseek(7, -2655, SEEK_CUR) = 1441
  8. read(7, "\n(defvar exec-path-from-shell-de"..., 4096) = 4096
  9. lseek(7, 5537, SEEK_SET) = 5537
  10. lseek(7, 5537, SEEK_SET) = 5537
  11. lseek(7, 5537, SEEK_SET) = 5537
  12. lseek(7, 5537, SEEK_SET) = 5537
  13. lseek(7, 5537, SEEK_SET) = 5537
  14. lseek(7, 5537, SEEK_SET) = 5537
  15. brk(0x7507000) = 0x7507000
  16. lseek(7, 5537, SEEK_SET) = 5537
  17. lseek(7, 5537, SEEK_SET) = 5537
  18. lseek(7, 5537, SEEK_SET) = 5537
  19. read(7, "230\\205\26\0\t\22\\307\\310\t!\vC\\\"\\211\24\\2"..., 4096) = 2430
  20. lseek(7, 7967, SEEK_SET) = 7967
  21. lseek(7, 7967, SEEK_SET) = 7967
  22. lseek(7, 7967, SEEK_SET) = 7967
  23. lseek(7, 7967, SEEK_SET) = 7967
  24. read(7, "", 4096) = 0
  25. close(7) = 0
  26. getpid() = 10818
  27. faccessat(AT_FDCWD, "/home/lujun9972/bin/printf", X_OK) = -1 ENOENT (沒(méi)有那個(gè)文件或目錄)
  28. faccessat(AT_FDCWD, "/usr/local/sbin/printf", X_OK) = -1 ENOENT (沒(méi)有那個(gè)文件或目錄)
  29. faccessat(AT_FDCWD, "/usr/local/bin/printf", X_OK) = -1 ENOENT (沒(méi)有那個(gè)文件或目錄)
  30. faccessat(AT_FDCWD, "/usr/bin/printf", X_OK) = 0
  31. stat("/usr/bin/printf", {st_mode=S_IFREG|0755, st_size=51176, ...}) = 0
  32. openat(AT_FDCWD, "/dev/null", O_RDONLY|O_CLOEXEC) = 7
  33. faccessat(AT_FDCWD, "/proc/5070/fd/.", F_OK) = 0
  34. faccessat(AT_FDCWD, "/proc/5070/fd/.", F_OK) = 0
  35. faccessat(AT_FDCWD, "/bin/bash", X_OK) = 0
  36. stat("/bin/bash", {st_mode=S_IFREG|0755, st_size=903440, ...}) = 0
  37. pipe2([8, 9], O_CLOEXEC) = 0
  38. rt_sigprocmask(SIG_BLOCK, [INT CHLD], [], 8) = 0
  39. vfork() = 10949
  40. rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
  41. close(9) = 0
  42. close(7) = 0
  43. read(8, "bash: \346\227\240\346\263\225\350\256\276\345\256\232\347\273\210\347\253\257\350\277\233\347\250\213\347\273"..., 16384) = 74
  44. read(8, "bash: \346\255\244 shell \344\270\255\346\227\240\344\273\273\345\212\241\346\216\247\345"..., 16310) = 35
  45. read(8, "setterm: \347\273\210\347\253\257 xterm-256color \344"..., 16275) = 51
  46. read(8, "Couldn't get a file descriptor r"..., 16224) = 56
  47. read(8, "bash: [: \357\274\232\351\234\200\350\246\201\346\225\264\346\225\260\350\241\250\350\276\276\345\274"..., 16168) = 34
  48. read(8, "Your display number is 0\n", 16134) = 25
  49. read(8, "Test whether fcitx is running co"..., 16109) = 53
  50. read(8, "Fcitx is running correctly.\n\n==="..., 16056) = 87
  51. read(8, "Launch fbterm...\n", 15969) = 17
  52. read(8, "stdin isn't a tty!\n", 15952) = 19
  53. read(8, "__RESULT\0/home/lujun9972/bin:/ho"..., 15933) = 298
  54. read(8, 0x7ffd1d39ce9d, 15635) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
  55. --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=10949, si_uid=1000, si_status=0, si_utime=10, si_stime=7} ---
  56. rt_sigreturn({mask=[]}) = -1 EINTR (被中斷的系統(tǒng)調(diào)用)
  57. read(8, "", 15635) = 0
  58. wait4(10949, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 10949
  59. close(8) = 0
  60. getpid() = 10818
  61. faccessat(AT_FDCWD, "/home/lujun9972/bin/printf", X_OK) = -1 ENOENT (沒(méi)有那個(gè)文件或目錄)
  62. faccessat(AT_FDCWD, "/usr/local/sbin/printf", X_OK) = -1 ENOENT (沒(méi)有那個(gè)文件或目錄)
  63. faccessat(AT_FDCWD, "/usr/local/bin/printf", X_OK) = -1 ENOENT (沒(méi)有那個(gè)文件或目錄)
  64. faccessat(AT_FDCWD, "/usr/bin/printf", X_OK) = 0
  65. stat("/usr/bin/printf", {st_mode=S_IFREG|0755, st_size=51176, ...}) = 0
  66. openat(AT_FDCWD, "/dev/null", O_RDONLY|O_CLOEXEC) = 7
  67. faccessat(AT_FDCWD, "/proc/5070/fd/.", F_OK) = 0
  68. faccessat(AT_FDCWD, "/proc/5070/fd/.", F_OK) = 0
  69. faccessat(AT_FDCWD, "/bin/bash", X_OK) = 0
  70. stat("/bin/bash", {st_mode=S_IFREG|0755, st_size=903440, ...}) = 0
  71. pipe2([8, 9], O_CLOEXEC) = 0
  72. rt_sigprocmask(SIG_BLOCK, [INT CHLD], [], 8) = 0
  73. vfork() = 11679
  74. rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
  75. close(9) = 0
  76. close(7) = 0
  77. read(8, "setterm: \347\273\210\347\253\257 xterm-256color \344"..., 16384) = 51
  78. read(8, "Couldn't get a file descriptor r"..., 16333) = 56
  79. read(8, "/home/lujun9972/.bash_profile: \347"..., 16277) = 72
  80. read(8, "Your display number is 0\nTest wh"..., 16205) = 78
  81. read(8, "Fcitx is running correctly.\n\n==="..., 16127) = 104
  82. read(8, "stdin isn't a tty!\n", 16023) = 19
  83. read(8, "__RESULT\0b269cd09e7ec4e8a115188c"..., 16004) = 298
  84. read(8, 0x7ffd1d39cba6, 15706) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
  85. --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=11679, si_uid=1000, si_status=0, si_utime=1, si_stime=1} ---
  86. rt_sigreturn({mask=[]}) = -1 EINTR (被中斷的系統(tǒng)調(diào)用)
  87. read(8,

很容易就可以看出,當(dāng) Emacs 卡頓時(shí),它在嘗試從 8 號(hào)文件句柄中讀取內(nèi)容。

那么 8 號(hào)文件句柄在哪里定義的呢?往前看可以看到:

  1. pipe2([8, 9], O_CLOEXEC) = 0
  2. rt_sigprocmask(SIG_BLOCK, [INT CHLD], [], 8) = 0
  3. vfork() = 11679
  4. rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
  5. close(9) = 0

可以推測(cè)出,Emacs 主進(jìn)程 fork 出一個(gè)子進(jìn)程(進(jìn)程號(hào)為 11679),并通過(guò)管道讀取子進(jìn)程的內(nèi)容。

然而,從

  1. --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=11679, si_uid=1000, si_status=0, si_utime=1, si_stime=1} ---
  2. rt_sigreturn({mask=[]}) = -1 EINTR (被中斷的系統(tǒng)調(diào)用)
  3. read(8,

可以看出,實(shí)際上子進(jìn)程已經(jīng)退出了(父進(jìn)程收到 SIGCHLD 信號(hào)),父進(jìn)程確依然在嘗試從管道中讀取內(nèi)容,導(dǎo)致的阻塞。

而且從

  1. read(8, "setterm: \347\273\210\347\253\257 xterm-256color \344"..., 16384) = 51
  2. read(8, "Couldn't get a file descriptor r"..., 16333) = 56
  3. read(8, "/home/lujun9972/.bash_profile: \347"..., 16277) = 72
  4. read(8, "Your display number is 0\nTest wh"..., 16205) = 78
  5. read(8, "Fcitx is running correctly.\n\n==="..., 16127) = 104
  6. read(8, "stdin isn't a tty!\n", 16023) = 19
  7. read(8, "__RESULT\0b269cd09e7ec4e8a115188c"..., 16004) = 298
  8. read(8, 0x7ffd1d39cba6, 15706) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)

看到,子進(jìn)程的輸出似乎是我的交互式登錄 bash 啟動(dòng)時(shí)的輸出(加載了 .bash_profile

在往前翻發(fā)現(xiàn)這么一段信息:

  1. readlinkat(AT_FDCWD, "/home", 0x7ffd1d3abb50, 1024) = -1 EINVAL (無(wú)效的參數(shù))
  2. readlinkat(AT_FDCWD, "/home/lujun9972", 0x7ffd1d3abf00, 1024) = -1 EINVAL (無(wú)效的參數(shù))
  3. readlinkat(AT_FDCWD, "/home/lujun9972/.emacs.d", 0x7ffd1d3ac2b0, 1024) = -1 EINVAL (無(wú)效的參數(shù))
  4. readlinkat(AT_FDCWD, "/home/lujun9972/.emacs.d/elpa", 0x7ffd1d3ac660, 1024) = -1 EINVAL (無(wú)效的參數(shù))
  5. readlinkat(AT_FDCWD, "/home/lujun9972/.emacs.d/elpa/exec-path-from-shell-20180323.1904", 0x7ffd1d3aca10, 1024) = -1 EINVAL (無(wú)效的參數(shù))
  6. readlinkat(AT_FDCWD, "/home/lujun9972/.emacs.d/elpa/exec-path-from-shell-20180323.1904/exec-path-from-shell.elc", 0x7ffd1d3acdc0, 1024) = -1 EINVAL (無(wú)效的參數(shù))
  7. lseek(7, -2655, SEEK_CUR) = 1441
  8. read(7, "\n(defvar exec-path-from-shell-de"..., 4096) = 4096

這很明顯是跟 exec-path-from-shell 有關(guān)啊。

通過(guò)查看 exec-path-from-shell 的實(shí)現(xiàn),發(fā)現(xiàn) exec-path-from-shell 的實(shí)現(xiàn)原理是通過(guò)實(shí)際調(diào)啟一個(gè) shell,然后輸出 PATH 和 MANPATH 的值的。 而且對(duì)于 bash 來(lái)說(shuō),默認(rèn)的啟動(dòng)參數(shù)為 -i -l(可以通過(guò)exec-path-from-shell-arguments來(lái)設(shè)置)。也就是說(shuō) bash 會(huì)作為交互式的登錄shell來(lái)啟動(dòng)的,因此會(huì)加載 .bash_profile 和 .bashrc

既然發(fā)現(xiàn)跟 exec-path-from-shell 這個(gè)包有關(guān),而且據(jù)說(shuō)這個(gè)包對(duì) Linux 其實(shí)意義不大,那不如直接禁用掉好了。

  1. dotspacemacs-excluded-packages '(exec-path-from-shell) 

再次重啟Emacs,發(fā)現(xiàn)這次啟動(dòng)速度明顯快了許多了。

 

責(zé)任編輯:龐桂玉 來(lái)源: Linux中國(guó)
相關(guān)推薦

2011-10-31 10:24:03

Linux死機(jī)

2010-08-18 13:58:46

路由器啟動(dòng)順序

2022-12-09 11:04:14

straceLinux

2009-06-30 13:58:00

Java啟動(dòng)器

2020-11-10 09:21:29

MySQL數(shù)據(jù)庫(kù)SQL

2012-11-06 10:38:18

.NETCLRProfiler

2022-12-29 07:33:44

Strace故障排除

2018-11-26 10:23:51

網(wǎng)絡(luò)故障路由器

2019-12-12 13:50:27

strace追蹤系統(tǒng)調(diào)用Linux

2009-10-26 11:11:33

linux Emacs

2024-07-09 08:31:26

2021-06-04 18:14:15

阻塞非阻塞tcp

2011-07-20 10:18:41

EmacsShell

2011-07-05 17:29:56

2009-07-31 09:14:01

WinCE啟動(dòng)失敗

2016-03-11 18:16:16

混合云集成

2009-07-19 10:01:37

linuxlinux安全后門

2024-12-12 09:40:27

Strace命令監(jiān)控

2011-09-16 11:08:54

Emacstwitter微博

2020-02-26 13:47:57

Emacs電子郵件開源
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)

主站蜘蛛池模板: 中文字幕第九页 | 麻豆久久久9性大片 | 欧美日韩在线免费观看 | 香蕉一区 | 中文字幕成人av | 欧美人人| 亚洲人在线观看视频 | 黄色片亚洲 | 99久久免费精品国产免费高清 | 国产在线精品一区二区三区 | 国产一区二区在线免费 | 精品国产一区二区三区成人影院 | 国产一级免费视频 | 午夜一区二区三区在线观看 | 欧美一级在线 | 午夜电影合集 | 久草免费电影 | 亚洲日韩中文字幕 | 青青草一区二区三区 | 一区二区三区免费 | 国产亚洲精品久久久优势 | 精品国产一区二区在线 | 亚洲精品黄色 | 国产精品久久国产精品99 | 亚洲精品美女在线观看 | 台湾a级理论片在线观看 | 91久久精品一区二区二区 | 国产1区2区 | 欧美日韩亚洲国产 | 狠狠涩| 国产成人av在线 | 欧美中文字幕在线观看 | av在线免费看网址 | 国产目拍亚洲精品99久久精品 | 欧美在线a | 精品国产一区二区三区免费 | 日本一区二区三区视频在线 | 在线观看成人小视频 | 国产精品精品视频一区二区三区 | 成人日韩| 波多野结衣在线观看一区二区三区 |