rust-lang / rust-lang/rust-mode

Bad performance with adaptive-wrap-prefix-mode

Open
#558 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Emacs Lisp
Stars
1.3k
Forks
198
PR merge metrics
No merged PRs in 30d

Description

rust-mode's performance is extremely bad with adaptive-wrap-prefix-mode enabled. The profiler shows most of the time is spent in rust-in-comment-paragraph and in turn syntax-ppss.

rust-ts-mode does not suffer from this, but rust-mode is much more portable so I think a fix is still worth it. I'm not sure if it's really fixable, though.

edit: In rust-in-comment-paragraph, there are multiple calls to syntax-ppss-flush-cache. This problem can be fixed by removing them.

         618  52% - redisplay_internal (C function)
         477  40%  - jit-lock-function
         477  40%   - jit-lock-fontify-now
         477  40%    - jit-lock--run-functions
         477  40%     - #<compiled -0x156e01748b5230c3>
         477  40%      - adaptive-wrap-prefix-function
         477  40%       - adaptive-wrap-fill-context-prefix
         477  40%        - fill-context-prefix
         457  38%         - fill-match-adaptive-prefix
         427  36%          - rust-find-fill-prefix
         427  36%           - rust-in-comment-paragraph
         417  35%            - syntax-ppss
         387  32%             - syntax-propertize
         357  30%              - rust-syntax-propertize
         357  30%               - rust-ordinary-lt-gt-p
         237  20%                - rust-is-lt-char-operator
         207  17%                 - rust-is-in-expression-context
         167  14%                  - rust-is-in-expression-context
          68   5%                   + rust-rewind-qualified-ident
          59   5%                   + rust-rewind-irrelevant
          40   3%                   + rust-paren-level
          30   2%                  + rust-rewind-irrelevant
          30   2%                 + rust-rewind-irrelevant
          75   6%                - rust-in-macro
          56   4%                   syntax-ppss
          19   1%                 + rust-looking-back-macro-rules
          45   3%                - rust-in-str-or-cmnt
          45   3%                   syntax-ppss
          10   0%              #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_15>
          30   2%          + current-left-margin

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the rust-in-comment-paragraph entry point and inspect its calls to syntax-ppss-flush-cache, using the adaptive-wrap-prefix-mode scenario described in the report. Done means rust-mode no longer shows the reported performance problem while handling Rust comments correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
emacs-lisp, rust
Domain
performance, tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.