rust-lang / rust-mode

Emacs configuration for Rust
Apache License 2.0
1.13k stars 181 forks source link

rust-mode on emacs 29 and above is very slowly #548

Open ki827 opened 6 months ago

ki827 commented 6 months ago

I clean my config and use package-install to install the ust-mode, company-mode. Active eglot-mode and company-mode, rust-mode, without additional configuration, I found that emacs slowly.

psibi commented 5 months ago

It's very had to help with minimal information. This could be issue with any of the modes including rust-mode. Can you disable each of the modes and try to see which one is causing the issue ?

Also, once you have identified it - can you include the profiling report: https://www.gnu.org/software/emacs/manual/html_node/elisp/Profiling.html

appetrosyan commented 3 months ago

I can confirm that this is an issue, and report the profiling data shortly.

Based on my previous observations, thereā€™s very frequent calls to redisplay

appetrosyan commented 3 months ago

Possibly related to #417

psibi commented 3 months ago

Does this also happen with enabling tree sitter: https://github.com/rust-lang/rust-mode?tab=readme-ov-file#tree-sitter ?

ki827 commented 2 months ago

It's very had to help with minimal information. This could be issue with any of the modes including rust-mode. Can you disable each of the modes and try to see which one is causing the issue ?

Also, once you have identified it - can you include the profiling report: https://www.gnu.org/software/emacs/manual/html_node/elisp/Profiling.html

Here my profiler report.

MEM

176,743,961  80% + company-post-command
 18,247,711   8% + command-execute
 14,139,894   6% + jsonrpc--process-filter
  6,596,763   3% + timer-event-handler
  3,385,206   1% + redisplay_internal (C function)
    261,952   0% + eldoc-pre-command-refresh-echo-area
    177,992   0% + jit-lock--antiblink-post-command
     10,560   0% + #<compiled 0x175deadf29cdd836>
      8,980   0% + #<compiled -0x133aa427fdece4b1>
      4,248   0% + eldoc-schedule-timer
      2,112   0% + yas--post-command-handler
      1,056   0% + undo-auto--add-boundary
        252   0% + internal-default-process-filter
          0   0%   ...

CPU

    6335  71% + timer-event-handler
    1243  14% + ...
     776   8% + command-execute
     387   4% + jsonrpc--process-filter
      41   0% + redisplay_internal (C function)
      18   0% + eldoc-pre-command-refresh-echo-area
      11   0% + company-post-command
       1   0% + #<compiled -0x133aa427fdece4b1>
       1   0% + jit-lock--antiblink-post-command
psibi commented 2 months ago

Thanks, did you try this:

This could be issue with any of the modes including rust-mode. Can you disable each of the modes and try to see which one is causing the issue ?

ki827 commented 1 month ago

Thanks, did you try this:

This could be issue with any of the modes including rust-mode. Can you disable each of the modes and try to see which one is causing the issue ?

OS

Mac os sonoma 14.6.1, Apple M1

emacs

Emacs 29.4, Homebrew

config

Minimal config to reproduce this problem.

;; Enable use-package (built-in for Emacs 29+)
(require 'use-package)

;; Optional: Enable use-package ensure by default
(setq use-package-always-ensure t)

;; Rust mode
(use-package rust-mode
  :init (setq rust-format-on-save t))

;; Eglot for LSP features (built-in for Emacs 29+)
(use-package eglot
  :hook (rust-mode . eglot-ensure)
  :config
  (add-to-list 'eglot-server-programs '(rust-mode . ("rust-analyzer"))))

(use-package company
  :hook (rust-mode . company-mode)
  :config 
  (setq company-idle-delay 0.1
        company-minimum-prefix-length 1))

I found that if without company mode everything works well, but with the company it will be slow.

jcs090218 commented 1 month ago

I found that if without company mode everything works well, but with the company it will be slow.

176,743,961 80% + company-post-command

It's clear that the company mode used up a lot of memory. šŸ¤” I'm using the older company mode inĀ https://github.com/elp-revive/company-modeĀ since there were some performance problems after this commit: company-mode/company-mode@b5db193. But I'm not sure if that is relevant to this issue.

ki827 commented 1 month ago

I found that if without company mode everything works well, but with the company it will be slow. 176,743,961 80% + company-post-command

It's clear that the company mode used up a lot of memory. šŸ¤” I'm using the older company mode inĀ https://github.com/elp-revive/company-modeĀ since there were some performance problems after this commit: company-mode/company-mode@b5db193. But I'm not sure if that is relevant to this issue.

I have the same idea. But using company mode with other prog modes, such as go mode, c mode, etc., will not cause Emacs to run slowly.

jcs090218 commented 1 month ago

I have the same idea. But using company mode with other prog modes, such as go mode, c mode, etc., will not cause Emacs to run slowly.

Yeah, you are right. Sorry, I wasn't thinking straight. šŸ«£