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

Pressing <down> makes emacs lag in some YAML files #48

Closed
ZelphirKaltstahl opened this issue Apr 26, 2017 · 7 comments
Closed

Pressing <down> makes emacs lag in some YAML files #48

ZelphirKaltstahl opened this issue Apr 26, 2017 · 7 comments

Comments

@ZelphirKaltstahl
Copy link

I installed yaml-mode from Melpa stable version ``. I don't know exactly when this happens, but in some YAML files, when I hold <down>, it makes emacs use 100% CPU. This does not happen when opening a YAML file in an emacs instance started with `emacs -Q`. In that case these is no special `yaml-mode` and no such CPU usage happens when scrolling through the file. I could not construct an example file yet to make this more reproducible.
It seems there is some unusual computation going on when pressing down.

@wasamasa
Copy link
Collaborator

Please record a profiler run, otherwise it's impossible to tell what the problem is:

  • M-x profiler-start, pick the CPU option
  • Reproduce the slowness, ideally for prolonged time
  • M-x profiler-report
  • C-u TAB
  • Copy the whole report and attach it into your reply
  • M-x profiler-stop

@ZelphirKaltstahl
Copy link
Author

- command-execute                                                2497  95%
 - call-interactively                                            2497  95%
  - next-line                                                    2439  93%
   - funcall                                                     2439  93%
    - #<compiled 0x437913>                                       2439  93%
     - line-move                                                 2439  93%
      - line-move-partial                                        2400  91%
       - default-line-height                                       36   1%
          default-font-height                                      36   1%
       - window-screen-lines                                       14   0%
        - default-line-height                                      14   0%
           default-font-height                                     12   0%
         default-font-height                                       12   0%
       - pos-visible-in-window-p                                    9   0%
          file-remote-p                                             7   0%
        - eval                                                      2   0%
           if                                                       2   0%
       - posn-at-point                                              2   0%
        - eval                                                      2   0%
           if                                                       2   0%
        line-move-visual                                           19   0%
      - default-line-height                                        12   0%
         default-font-height                                       12   0%
  - byte-code                                                      27   1%
   - read-extended-command                                         27   1%
    - completing-read                                              27   1%
     - completing-read-default                                     27   1%
      - read-from-minibuffer                                       25   0%
       - timer-event-handler                                        1   0%
          timer-activate-when-idle                                  1   0%
  - minibuffer-complete                                            26   0%
   - completion-in-region                                          26   0%
    - completion--in-region                                        26   0%
     - #<compiled 0xa18fbb>                                        26   0%
      - apply                                                      26   0%
       - #<compiled 0x247e21>                                      26   0%
        - completion--in-region-1                                  26   0%
         - completion--do-completion                               26   0%
          - completion-try-completion                              23   0%
           - completion--nth-completion                            23   0%
            - completion--some                                     23   0%
             - funcall                                             23   0%
              - #<compiled 0xa16b97>                               23   0%
               - #<compiled 0xa16f9b>                              23   0%
                  completion-basic-try-completion                  23   0%
          - minibuffer-completion-help                              3   0%
           - completion-all-completions                             3   0%
            - completion--nth-completion                            3   0%
             - completion--some                                     3   0%
              - funcall                                             3   0%
               - #<compiled 0x9efd2b>                               3   0%
                - #<compiled 0x9f012f>                              3   0%
                 - completion-basic-all-completions                  3   0%
                    completion-pcm--all-completions                  3   0%
  - execute-extended-command                                        5   0%
   - command-execute                                                5   0%
    - call-interactively                                            5   0%
     - profiler-report                                              5   0%
      - profiler-report-cpu                                         5   0%
         profiler-cpu-profile                                       5   0%
- redisplay_internal (C function)                                  62   2%
 - jit-lock-function                                               62   2%
  - jit-lock-fontify-now                                           62   2%
   - funcall                                                       62   2%
    - #<compiled 0x9d8b77>                                         62   2%
     - run-hook-with-args                                          62   2%
      - font-lock-fontify-region                                   62   2%
       - font-lock-default-fontify-region                          62   2%
        - font-lock-fontify-keywords-region                        35   1%
           yaml-font-lock-block-literals                           10   0%
           whitespace-trailing-regexp                              10   0%
        - font-lock-fontify-syntactically-region                   27   1%
           looking-back                                            10   0%
- ...                                                              42   1%
   Automatic GC                                                    42   1%
- whitespace-post-command-hook                                     14   0%
   jit-lock-refontify                                              14   0%
- delete-selection-pre-hook                                         4   0%
   use-region-p                                                     4   0%

@ZelphirKaltstahl
Copy link
Author

And here is the profiling in emacs -Q:

- command-execute                                                  81  85%
 - call-interactively                                              81  85%
  - byte-code                                                      35  36%
   - read-extended-command                                         35  36%
    - completing-read                                              35  36%
     - completing-read-default                                     35  36%
        read-from-minibuffer                                       27  28%
  - next-line                                                      24  25%
   - funcall                                                       11  11%
    - #<compiled 0x49ee9f>                                         11  11%
     - line-move                                                   11  11%
      - line-move-partial                                           6   6%
       - default-line-height                                        6   6%
          default-font-height                                       6   6%
      - default-line-height                                         4   4%
         default-font-height                                        4   4%
        line-move-visual                                            1   1%
  - minibuffer-complete                                            20  21%
   - completion-in-region                                          20  21%
    - completion--in-region                                        20  21%
     - #<compiled 0x4d0833>                                        20  21%
      - apply                                                      20  21%
       - #<compiled 0x247e21>                                      20  21%
        - completion--in-region-1                                  20  21%
         - completion--do-completion                               20  21%
          - minibuffer-completion-help                             15  15%
           - completion-all-completions                            11  11%
            - completion--nth-completion                           11  11%
             - completion--some                                    11  11%
              - funcall                                            11  11%
               - #<compiled 0x4d1c3b>                              11  11%
                - #<compiled 0x4d1843>                             11  11%
                 - completion-basic-all-completions                 11  11%
                    completion-pcm--all-completions                 11  11%
           - internal-temp-output-buffer-show                       4   4%
            - display-buffer                                        4   4%
             - display-buffer--maybe-pop-up-frame-or-window                  4   4%
              - display-buffer-pop-up-window                        4   4%
               - window--try-to-split-window                        4   4%
                - funcall                                           4   4%
                 - split-window-sensibly                            4   4%
                  - split-window-below                              4   4%
                   - split-window                                   4   4%
                    - byte-code                                     4   4%
                     - window--check                                4   4%
                      - window--side-check                          4   4%
                       - byte-code                                  4   4%
                        - walk-window-tree                          4   4%
                           walk-window-tree-1                       4   4%
          - completion-try-completion                               5   5%
           - completion--nth-completion                             5   5%
            - completion--some                                      5   5%
             - funcall                                              5   5%
              - #<compiled 0x2f906b>                                5   5%
               - #<compiled 0x71f17f>                               5   5%
                  completion-basic-try-completion                   5   5%
  - execute-extended-command                                        2   2%
   - command-execute                                                2   2%
    - call-interactively                                            2   2%
     - profiler-report                                              2   2%
      - profiler-report-cpu                                         2   2%
         profiler-cpu-profile                                       2   2%
- redisplay_internal (C function)                                   5   5%
 - and                                                              4   4%
  - or                                                              4   4%
     and                                                            4   4%
 - eval                                                             1   1%
    if                                                              1   1%
- timer-event-handler                                               5   5%
 - timer-activate                                                   5   5%
  - timer--activate                                                 5   5%
     timerp                                                         5   5%
- ...                                                               4   4%
   Automatic GC                                                     4   4%

@wasamasa
Copy link
Collaborator

Hm, doesn't look particularly enlightening. Could you try running a minimal session with emacs -Q, then enable packages with M-x package-initialize, open a YAML file, enable yaml-mode and then try reproducing the problem? If it's gone in that configuration and otherwise present, chances are you've enabled something in your own personal config that makes line movement a lot slower.

@ZelphirKaltstahl
Copy link
Author

The issue does not appear when I do that, so I think you are right. It seems to be something else related to YAML in my emacs configuration.

@wasamasa
Copy link
Collaborator

OK, feel free to write here again if you manage finding the culprit via bisection.

@ZelphirKaltstahl
Copy link
Author

The issue is with a theme. I fiddled around with the emacs desktop file, because I tried to disable all themes. Although I commented them out in my init.el file, emacs still loaded the theme. When I commented out (desktop-save-mode 1), it did not do that anymore. So I figured I'd simply delete the emacs desktop file and reopen all my buffers, to get rid of the theme. When I open the YAML file without theme, the high CPU usage does not happen anymore. When I reenable the theme, the CPU usage is there again.
The theme is suscolors.

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