加入收藏 | 设为首页 | 会员中心 | 我要投稿 辽源站长网 (https://www.0437zz.com/)- 云专线、云连接、智能数据、边缘计算、数据安全!
当前位置: 首页 > 服务器 > 搭建环境 > Windows > 正文

使用strace查找Emacs启动阻塞的原因

发布时间:2019-09-29 22:33:40 所属栏目:Windows 来源:Darksun
导读:之前就觉得我的 Emacs 启动好慢,查看启动日志会发现启动到一般的时候会有一个比较长时间的卡顿。 之前一直没有理会它,今天花了点时间探索了一下,发现罪魁祸首居然是 exec-path-from-shell 这个包。 现将探索的过程记录如下: 由于使用了 spacemacs 的配
副标题[/!--empirenews.page--]

使用strace查找Emacs启动阻塞的原因

之前就觉得我的 Emacs 启动好慢,查看启动日志会发现启动到一般的时候会有一个比较长时间的卡顿。 之前一直没有理会它,今天花了点时间探索了一下,发现罪魁祸首居然是 exec-path-from-shell 这个包。

现将探索的过程记录如下: 由于使用了 spacemacs 的配置,配置上比较复杂,不太想通过实验缩减配置的方式来摸索出问题的地方。刚好最近在学习使用 strace 工具,因此决定使用 strace 来看看 Emacs 到底卡在哪里。

strace emacs --fg-daemon

输出的内容特别多,这里只截取卡顿前的部分内容

  1. readlinkat(AT_FDCWD, "/home", 0x7ffd1d3abb50, 1024) = -1 EINVAL (无效的参数)
  2. readlinkat(AT_FDCWD, "/home/lujun9972", 0x7ffd1d3abf00, 1024) = -1 EINVAL (无效的参数)
  3. readlinkat(AT_FDCWD, "/home/lujun9972/.emacs.d", 0x7ffd1d3ac2b0, 1024) = -1 EINVAL (无效的参数)
  4. readlinkat(AT_FDCWD, "/home/lujun9972/.emacs.d/elpa", 0x7ffd1d3ac660, 1024) = -1 EINVAL (无效的参数)
  5. readlinkat(AT_FDCWD, "/home/lujun9972/.emacs.d/elpa/exec-path-from-shell-20180323.1904", 0x7ffd1d3aca10, 1024) = -1 EINVAL (无效的参数)
  6. readlinkat(AT_FDCWD, "/home/lujun9972/.emacs.d/elpa/exec-path-from-shell-20180323.1904/exec-path-from-shell.elc", 0x7ffd1d3acdc0, 1024) = -1 EINVAL (无效的参数)
  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, "23020526t22307310t!vC"211242"..., 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 (没有那个文件或目录)
  28. faccessat(AT_FDCWD, "/usr/local/sbin/printf", X_OK) = -1 ENOENT (没有那个文件或目录)
  29. faccessat(AT_FDCWD, "/usr/local/bin/printf", X_OK) = -1 ENOENT (没有那个文件或目录)
  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: 346227240346263225350256276345256232347273210347253257350277233347250213347273"..., 16384) = 74
  44. read(8, "bash: 346255244 shell 344270255346227240344273273345212241346216247345"..., 16310) = 35
  45. read(8, "setterm: 347273210347253257 xterm-256color 344"..., 16275) = 51
  46. read(8, "Couldn't get a file descriptor r"..., 16224) = 56
  47. read(8, "bash: [: 357274232351234200350246201346225264346225260350241250350276276345274"..., 16168) = 34
  48. read(8, "Your display number is 0n", 16134) = 25
  49. read(8, "Test whether fcitx is running co"..., 16109) = 53
  50. read(8, "Fcitx is running correctly.nn==="..., 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/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 (被中断的系统调用)
  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 (没有那个文件或目录)
  62. faccessat(AT_FDCWD, "/usr/local/sbin/printf", X_OK) = -1 ENOENT (没有那个文件或目录)
  63. faccessat(AT_FDCWD, "/usr/local/bin/printf", X_OK) = -1 ENOENT (没有那个文件或目录)
  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: 347273210347253257 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 0nTest wh"..., 16205) = 78
  81. read(8, "Fcitx is running correctly.nn==="..., 16127) = 104
  82. read(8, "stdin isn't a tty!n", 16023) = 19
  83. read(8, "__RESULTb269cd09e7ec4e8a115188c"..., 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 (被中断的系统调用)
  87. read(8,

很容易就可以看出,当 Emacs 卡顿时,它在尝试从 8 号文件句柄中读取内容。

(编辑:辽源站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

推荐文章
    热点阅读