redguardtoo / emacs.d

Fast and robust Emacs setup.
http://blog.binchen.org
GNU General Public License v3.0
2.39k stars 619 forks source link

It's very slow while opening company mode for editing large file with over 10000 lines. #1040

Open guoqinglei opened 1 year ago

guoqinglei commented 1 year ago

I wonder how to fix this problem ? Anyone any suggestion ?

redguardtoo commented 1 year ago

In major mode hook, you can (setq-local company-backends nil), you can use other value than nil.

If you know how to write your own company-backend (one chapter of tutorial https://edu.51cto.com/sd/de7e7 teach how to write it), you know the performance of company is dependent on backend. Some backend is just slower, maybe company-dabbrev is the trouble maker?

guoqinglei commented 1 year ago

Thank you for your reply. I would have a try to verify the problem.

Another operation that could invoke similar "slow" problem while ending a file with over 10000 lines is: press "Enter" key at the end of a comment line, e.g., "//this is a comment line ...". When I do this operation, Emacs is stalled while the cpu occupation is 100% for emacs. I do not know why this would happen ? Maybe indentation cause this problem ?

redguardtoo commented 1 year ago

Use profile-start to get the report and send it to me. See https://github.com/redguardtoo/emacs.d#why-opening-file-is-slow (replace open file code with forward-line or goto-char)

guoqinglei commented 1 year ago

Thanks for your advice. I have tried it. And the cause is function "indent-according-to-mode” which occupies 97% of cpu time, while I am editing a file with 100000 lines with verilog-mode.

Could I set the variable "evil-auto-indent" to nil to improve the performance ?

redguardtoo commented 1 year ago

Not sure. See doc of indent-according-to-mode, you might need set up indent-line-function.