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

Visual block mode multi-insert is slow #5423

Closed
fivethousand opened this issue Mar 9, 2016 · 10 comments
Closed

Visual block mode multi-insert is slow #5423

fivethousand opened this issue Mar 9, 2016 · 10 comments
Labels
- Forum - Evil Performance stale marked as a stale issue/pr (usually by a bot)

Comments

@fivethousand
Copy link

Description

Inserting in visual block mode is very slow compared to vim. It gets even worse when files are larger and insert is repeated.

Reproduction guide

  • Start Emacs
  • [Open a large file to make the effect more dramatic, or] create a file with at least 30 lines (eg. iqwerty ESC yy 32p)
  • C-v 30j 32I x ESC (capital i after 32)

Observed behaviour:
Inserts 32x on each of the 30 subsequent lines. Takes multiple seconds and gets worse on larger files.

Expected behaviour:
Same. However, vim is significantly faster (<1 sec).

Is there anything we can do to improve the situation?
Is the overhead for operations like this so much higher for spacemacs, evil or even just for emacs?

System Info

  • CPU: i7 @ 3.2 GHz
  • OS: gnu/linux
  • Emacs: 24.5.1
  • Spacemacs: 0.105.13
  • Spacemacs branch: master (rev. 2c3e6b4)
  • Graphic display: t
  • Distribution: spacemacs
  • Editing style: vim
  • Completion: helm
@StreakyCobra
Copy link
Contributor

With stock emacs with just evil loaded this is fast, so there is probably something to improve there.

@fivethousand
Copy link
Author

Thanks. Were you also able to reproduce the slowdown?

@StreakyCobra
Copy link
Contributor

Yep

@fivethousand
Copy link
Author

Wow.. stock emacs with evil is even much faster than vim for this operation!

In the meantime I found out that it is at least partially caused by the line numbers. Disabling line numbers (SPC t n) makes it much faster.

@StreakyCobra
Copy link
Contributor

Oh, I tried without line numbers, and indeed with them it's even more slower.

@fbergroth
Copy link
Contributor

I can't reproduce it. Enable to profiler to see what's the culprit.

@StreakyCobra
Copy link
Contributor

It seems to be mostly due to outshine in my case, which is an additional package. Otherwise I suppose it's slower with spacemacs because there is many more hooks that are repetitively called than it stock emacs.

Of course line numbers are destroying performances, but this is nothing new here.


Without line numbers:

- command-execute                                                2751  75%
 - call-interactively                                            2751  75%
  - evil-normal-state                                            2014  55%
   - evil-change-state                                           2011  54%
    - evil-insert-state                                          2011  54%
     - run-hooks                                                 2009  54%
      - evil-cleanup-insert-state                                2009  54%
       - evil-execute-repeat-info                                2002  54%
        - execute-kbd-macro                                      1938  52%
         - command-execute                                       1057  28%
          - call-interactively                                   1057  28%
           + outshine-self-insert-command                        1057  28%
         + flyspell-post-command-hook                             698  19%
         + yas--post-command-handler                               48   1%
         + company-post-command                                    33   0%
         + hl-paren-initiate-highlight                             26   0%
         + sp--save-pre-command-state                              22   0%
         + winner-save-old-configurations                           7   0%
         + evil-repeat-pre-hook                                     7   0%
         + evil-escape-pre-command-hook                             6   0%
         + evil--jump-hook                                          5   0%
         + global-hl-line-highlight                                 4   0%
           flycheck-pos-tip-hide-messages                           3   0%

With line numbers:

- command-execute                                                6651  84%
 - call-interactively                                            6651  84%
  - evil-normal-state                                            6288  80%
   - evil-change-state                                           6280  79%
    - evil-insert-state                                          6280  79%
     - run-hooks                                                 6280  79%
      - evil-cleanup-insert-state                                6280  79%
       - evil-execute-repeat-info                                6277  79%
        - execute-kbd-macro                                      6225  79%
         + linum-update-current                                  4801  61%
         - command-execute                                        848  10%
          - call-interactively                                    848  10%
           + outshine-self-insert-command                         848  10%
         + flyspell-post-command-hook                             358   4%
         + sp--save-pre-command-state                              68   0%
         + yas--post-command-handler                               47   0%
         + company-post-command                                    27   0%
         + global-hl-line-highlight                                19   0%
         + which-key--hide-popup                                    8   0%
         + evil--jump-hook                                          8   0%
         + hl-paren-initiate-highlight                              7   0%
         + winner-save-old-configurations                           7   0%
         + evil-repeat-pre-hook                                     4   0%
         + sp--post-command-hook-handler                            4   0%
         + company-pre-command                                      3   0%

@quicknir
Copy link
Contributor

quicknir commented Jun 9, 2016

Currently for me, this is still very slow. From what I can see, a huge amount of time is being spent in smart parens, although even when I disabled it it still seemed to be spending time there.

It looks like block visual is actually inserting and running the hooks over, and over, and over. Can't it be treated as a single raw insert?

Edit: so for me, turning off both smart parens and line numbers gives acceptable performance. But it seems like a shame to have to turn these off. Isn't there some way to just prevent them running during this repetitive command? Should I ask the evil people if it's possible to have a separate set of hooks, say "run-repetitive-hooks" and "run-hooks"? Or can we just remove things by hand each time block visual insert is entered and re-add them at the end?

Edit2: maybe this is of interested: https://www.gnu.org/software/emacs/manual/html_node/elisp/Change-Hooks.html. Seems like emacs provides a way to do a bunch of edits and only run hooks once.

@simendsjo
Copy link
Contributor

For me it's flyspell mode.

- command-execute                                                 911  60%
 - call-interactively                                             911  60%
  - funcall-interactively                                         602  40%
   - evil-normal-state                                            566  37%
    - evil-change-state                                           558  37%
     - evil-insert-state                                          558  37%
      - run-hooks                                                 558  37%
       - evil-cleanup-insert-state                                536  35%
        - evil-execute-repeat-info                                536  35%
         - execute-kbd-macro                                      534  35%
          - flyspell-post-command-hook                            365  24%
           + flyspell-word                                        351  23%
           + flyspell-check-word-p                                  9   0%
           + flyspell-check-pre-word-p                              3   0%
          + command-execute                                       161  10%
          + company-post-command                                    2   0%
          + key-chord-input-method                                  2   0%
          + evil-repeat-pre-hook                                    2   0%
            company-pre-command                                     1   0%
          + global-hl-line-highlight                                1   0%
    + redisplay                                                     8   0%
   + org-self-insert-command                                       13   0%
   + undo-tree-undo                                                 7   0%
   + helm-M-x                                                       5   0%
   + evil-next-visual-line                                          4   0%
   + evil-change                                                    4   0%
   + evil-visual-block                                              3   0%
  - byte-code                                                     309  20%
   - helm-M-x-read-extended-command                               295  19%
    - helm-comp-read                                              295  19%
     - helm                                                       295  19%
      - apply                                                     295  19%
       - helm                                                     295  19%
        - apply                                                   295  19%
         - helm-internal                                          295  19%
          - helm-read-pattern-maybe                               283  18%
           - read-from-minibuffer                                 230  15%
            + timer-event-handler                                 111   7%
            + redisplay_internal (C function)                      21   1%
            + command-execute                                       5   0%
            + winum--update                                         1   0%
            + minibuffer-inactive-mode                              1   0%
            + helm--update-header-line                              1   0%
           + helm-update                                           10   0%
          + helm-initialize                                         9   0%
          + #<compiled 0x3b55387>                                   3   0%
   + completing-read                                               12   0%
   + evil-visual-rotate                                             2   0%
- flyspell-post-command-hook                                      286  19%
 - flyspell-check-word-p                                          174  11%
  - sit-for                                                       174  11%
   - redisplay                                                    156  10%
    + redisplay_internal (C function)                              35   2%
 + flyspell-word                                                  110   7%
+ ...                                                             113   7%
+ redisplay_internal (C function)                                  90   6%
+ evil-visual-post-command                                         63   4%
+ timer-event-handler                                              25   1%
+ evil-repeat-post-hook                                             2   0%
+ global-hl-line-highlight                                          2   0%
  evil-normal-post-command                                          1   0%
+ winner-save-old-configurations                                    1   0%

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!

@github-actions github-actions bot added the stale marked as a stale issue/pr (usually by a bot) label Feb 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- Forum - Evil Performance stale marked as a stale issue/pr (usually by a bot)
Projects
None yet
Development

No branches or pull requests

5 participants