Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ki827 opened this issue May 30, 2024 · 10 comments
Open

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

ki827 opened this issue May 30, 2024 · 10 comments

Comments

@ki827
Copy link

ki827 commented May 30, 2024

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.

@ki827 ki827 changed the title rust-mode on emcas 29 and above is very slowly rust-mode on emacs 29 and above is very slowly May 30, 2024
@psibi
Copy link
Member

psibi commented Jun 1, 2024

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
Copy link

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
Copy link

Possibly related to #417

@psibi
Copy link
Member

psibi commented Aug 22, 2024

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

@ki827
Copy link
Author

ki827 commented Sep 27, 2024

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
Copy link
Member

psibi commented Sep 27, 2024

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
Copy link
Author

ki827 commented Sep 28, 2024

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
Copy link
Member

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
Copy link
Author

ki827 commented Sep 28, 2024

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
Copy link
Member

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. 🫣

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants