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

Bad performance with adaptive-wrap-prefix-mode #558

Open
ksqsf opened this issue Sep 13, 2024 · 2 comments
Open

Bad performance with adaptive-wrap-prefix-mode #558

ksqsf opened this issue Sep 13, 2024 · 2 comments

Comments

@ksqsf
Copy link
Contributor

ksqsf commented Sep 13, 2024

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
@ksqsf
Copy link
Contributor Author

ksqsf commented Sep 13, 2024

The code was introduced in 5b34e59 (11 years ago). The assumptions made then probably should be revisited.

@psibi
Copy link
Member

psibi commented Sep 27, 2024

I would be happy to accept a PR with some tests if possible.

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

2 participants