jit-lock-function 消耗过多 CPU 并经常挂断我的 emacs。有人遇到过同样的问题吗?如何解决?
操作系统是 archlinux x64,CPU intel i7 4790,16GB RAM。除系统服务外,只有 emacs 在运行。
谢谢!
分析器报告给出了以下内容:
- redisplay_internal (C function) 2728 90%
- jit-lock-function 2724 89%
- jit-lock-fontify-now 2724 89%
- jit-lock--run-functions 2724 89%
- run-hook-wrapped 2724 89%
- #<compiled 0x40f2001> 2724 89%
- font-lock-fontify-region 2724 89%
- c-font-lock-fontify-region 2724 89%
- font-lock-default-fontify-region 2716 89%
- font-lock-fontify-keywords-region 2712 89%
- c-font-lock-declarations 1932 63%
- c-find-decl-spots 1912 63%
- #<compiled 0x22af545> 1148 37%
- c-get-fontification-context 732 24%
- c-looking-at-or-maybe-in-bracelist 504 16%
+ c-backward-token-2 472 15%
- c-back-over-member-initializers 108 3%
+ c-back-over-compound-identifier 56 1%
+ c-parse-state 32 1%
c-backward-sws 8 0%
+ c-back-over-compound-identifier 68 2%
+ c-backward-token-2 16 0%
c-backward-sws 4 0%
+ c-forward-decl-or-cast-1 240 7%
+ c-forward-label 60 1%
+ c-backward-token-2 16 0%
+ c-backward-sws 12 0%
+ c-font-lock-single-decl 8 0%
c-syntactic-re-search-forward 4 0%
+ c-bs-at-toplevel-p 672 22%
+ c-beginning-of-macro 28 0%
c-forward-sws 8 0%
c-backward-token-2 4 0%
c-font-lock-<>-arglists 304 10%
+ #<compiled 0x22b6359> 92 3%
#<compiled 0x22b6381> 68 2%
#<compiled 0x22b5fbd> 32 1%
#<compiled 0x22b62b9> 32 1%
#<compiled 0x22b625d> 28 0%
#<compiled 0x22b62fd> 28 0%
#<compiled 0x22b631d> 28 0%
#<compiled 0x22b63d5> 8 0%
+ c-font-lock-enclosing-decls 4 0%
c-font-lock-enum-body 4 0%
#<compiled 0x22b6669> 4 0%
font-lock-fontify-syntactically-region 4 0%
+ c-before-context-fl-expand-region 8 0%
答案1
你的说法有点不对:89% 的时间都花在了jit-lock-function
但所有这些时间也都花在了c-font-lock-fontify-region
(间接调用jit-lock-function
)上。
所以您的问题出在 c-font-lock 而不是 jit-lock 上。
请通过 将此作为错误报告M-x report-emacs-bug
。您可能希望提供有关其出现的缓冲区内容的详细信息(我假设它是一个 C++ 文件)。
如果这是使用 Emacs 26.3 之前的版本,那么在报告错误之前可能值得先尝试使用 Emacs-26.3,因为 c++ 模式下的字体锁定性能多年来一直在不断改进。