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

Spacemacs is slow in moving cursor continuously in a big file #8905

Closed
ghost opened this issue May 16, 2017 · 27 comments
Closed

Spacemacs is slow in moving cursor continuously in a big file #8905

ghost opened this issue May 16, 2017 · 27 comments
Labels
stale marked as a stale issue/pr (usually by a bot)

Comments

@ghost
Copy link

ghost commented May 16, 2017

Hi,

I notice that when using the arrow keys to move the cursor continuously in a big file, such as .emacs.d/core/core-configuration-layer.el, the cursor movement often lags and is not smooth.

My guess is that during the cursor moving, there are some computations corresponding to the new cursor position, such as displaying eldoc, flycheck, flyspell... As the cursor continuously moves to a new position, these computations are performed again and again and this makes the cursor moving unsmooth.

Are there any ways to make the continuous cursor moving smooth?

If my guess is correct, is it possible to temporarily disable the events update during a continuous cursor moving?

Thanks for spending your time to look at my question!

@CeleritasCelery
Copy link
Contributor

It is smooth for me. Sounds like you may need a performance upgrade for your computer.

@ghost
Copy link
Author

ghost commented May 17, 2017

Not really. My computer's CPU is Intel Core i7 6700, with 16GB of RAM.
This slowness can happen when Emacs load many modules.

@scriptmode
Copy link

You could profile emacs to figure out which functions eats up most performance. And then selectivly deactivate stuff or optimize their behaviour.

@CeleritasCelery
Copy link
Contributor

Also keep in mind that Spacemacs can only optimize load time performance. The individual package owners control the preformace of their code. Therefore if a package or combination of packages are slowing you down, then there is not much Spacemacs can do. You can either disable packages or live with the preformace. @scriptmode's suggestion about profiling may be a good idea if you are looking for packages to disable. But you may just want to start with removing the packages and minor-modes you use the least.

@CeleritasCelery
Copy link
Contributor

On another note, if you ever dealing with really large files (over 10,000 lines) you should consider vlf-mode

@ghost
Copy link
Author

ghost commented May 19, 2017

@scriptmode, @CeleritasCelery: Thanks for your suggestions. These sound really logical. I will monitor my Emacs's performance.

@ghost
Copy link
Author

ghost commented May 19, 2017

Hi, just a follow-up question.

I profiled the CPU usage and found out that the CPU consumption for redisplay_internal is quite high, especially the feature spacline-ml-tddsg, which is a customized version of spaceline. Is abnormal for the redisplay function?

In addition, the CPU usage of spaceline-ml-tddsg is 17%, but all its sub-items add up to only 6%. (2% + 1% + 1% + 1% + 1%). Where is the other 11%?

- redisplay_internal (C function)                                 420  21%
 - eval                                                           389  19%
  - spaceline-ml-tddsg                                            355  17%
   + powerline-raw                                                 46   2%
   + powerline-buffer-id                                           35   1%
   + mapcar                                                        29   1%
   + flycheck-has-current-errors-p                                 27   1%
   + run-hooks                                                     20   1%
   + powerline-wave-right                                          19   0%
   + powerline-wave-left                                           14   0%
     powerline-render                                              11   0%
     vc-state                                                       8   0%
   + powerline-width                                                7   0%
   + s-trim                                                         5   0%
   + powerline-hud                                                  4   0%
     eyebrowse--get                                                 4   0%
     file-remote-p                                                  4   0%
     get-frame-persp                                                2   0%
  + concat                                                         14   0%
    if                                                              4   0%
 + jit-lock-function                                               31   1%

@CeleritasCelery
Copy link
Contributor

spaceline is notorious for causing problems with redisplay_internal (see #8462, #8060, #6120, #5063, #4730, or #4552). Some users have found that dotspacemacs-mode-line-unicode-symbols nil helps significantly. Others just disable the package all together. This seems to be a "works fine for some people, crashes everything for others" kind of problem.

@zeka0
Copy link

zeka0 commented Jun 4, 2017

I encountered similar problem, but the file I was editing is small (less than 50 lines).
Spacemacs is slow when moving cursors using j or w, and what is odd is that,
when you press j multiple times, the cursor simply disappeared then reappeared at the expected position.
I was running Spacemacs on a virtual machine consisting of only 2G ram with 4 threads 2 core CPU.
Any ideas what might cause the problem and how to improve it?

@CeleritasCelery
Copy link
Contributor

@zeka0 The problem is probably "running Spacemacs on a virtual machine consisting of only 2G ram with 4 threads 2 core CPU". You can take the advice mentioned above if you want to improve performance.

@armnrd
Copy link

armnrd commented Jul 13, 2019

Hi, just a follow-up question.

I profiled the CPU usage and found out that the CPU consumption for redisplay_internal is quite high, especially the feature spacline-ml-tddsg, which is a customized version of spaceline. Is abnormal for the redisplay function?

In addition, the CPU usage of spaceline-ml-tddsg is 17%, but all its sub-items add up to only 6%. (2% + 1% + 1% + 1% + 1%). Where is the other 11%?

- redisplay_internal (C function)                                 420  21%
 - eval                                                           389  19%
  - spaceline-ml-tddsg                                            355  17%
   + powerline-raw                                                 46   2%
   + powerline-buffer-id                                           35   1%
   + mapcar                                                        29   1%
   + flycheck-has-current-errors-p                                 27   1%
   + run-hooks                                                     20   1%
   + powerline-wave-right                                          19   0%
   + powerline-wave-left                                           14   0%
     powerline-render                                              11   0%
     vc-state                                                       8   0%
   + powerline-width                                                7   0%
   + s-trim                                                         5   0%
   + powerline-hud                                                  4   0%
     eyebrowse--get                                                 4   0%
     file-remote-p                                                  4   0%
     get-frame-persp                                                2   0%
  + concat                                                         14   0%
    if                                                              4   0%
 + jit-lock-function                                               31   1%

I am new to Emacs, and am not familiar with the profiler. Could you tell me how you did this?
My attempt:

M-x profiler-start
M-x profiler-stop
M-x profiler-report

This doesn't seem to do anything.

@duianto
Copy link
Contributor

duianto commented Jul 13, 2019

  • profiler-start
  • Choose cpu, mem or cpu+mem
  • Perform the action you want to profile
  • profiler-report opens the report buffer(s)
  • profiler-stop when your done profiling.

https://www.gnu.org/software/emacs/manual/html_node/elisp/Profiling.html

@armnrd
Copy link

armnrd commented Jul 13, 2019

Thanks, that helps.

@elvinzeng
Copy link

  • redisplay_internal (C function) 12618 76%
  • evil-escape-pre-command-hook 2158 13%
  • command-execute 703 4%
  • timer-event-handler 466 2%
  • ... 415 2%
  • flycheck-handle-signal 66 0%
  • flycheck-perform-deferred-syntax-check 6 0%
  • which-key--hide-popup 3 0%
  • evil--jump-hook 3 0%
    global-hl-line-unhighlight 3 0%

Mine is worse

@github-actions
Copy link

github-actions bot commented Jan 9, 2021

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 Jan 9, 2021
@darrenkenny
Copy link

I certainly experience a lot of lag when using either the spaceline or doom mode lines on MacOS - but only if running as a GUI, not if I use it in a terminal, in a terminal it flies along, but I lack the benefits then of the GUI mode.

In the reading that I've done this appears to be mainly down to the font rendering - suggestions that I've looked at has been to disable unicode characters and pick some specific fonts - some had minor benefits, but nothing reduced the lag as much as switching to the 'vanilla' mode line.

While not as pretty, it certainly helps for usability to avoid the lag.

@fab6
Copy link

fab6 commented Feb 19, 2021

Hi,
for me it is the same like @darrenkenny described. Using spacemacs development and emacs 27.1 on macos.

@lebensterben
Copy link
Contributor

@darrenkenny
There is middle ground between terminal Emacs and full-GUI Emacs.
If you run an Emacs server in background daemon mode, then you are able to launch "terminal" Emacs in a GUI window. That is to say, you still have GUI only features like menubar, scroll bar, etc. But meanwhile, it's actually an terminal Emacs sessionl.

@fab6
Copy link

fab6 commented Feb 20, 2021

@lebensterben Could you elaborate on this a bit more; I understand that I could start a server with emacs-gui with server-start and open a file using emacsclient from the terminal with emacsclient file.
Is this what you meant?
Thank you!

@duianto duianto removed the stale marked as a stale issue/pr (usually by a bot) label Feb 20, 2021
@lebensterben
Copy link
Contributor

@fab6
You can use systemd, for example, to register a service that starts emacs as a background daemon upon system starts.
Then, use "emacslient -a ''" to start the client. The additional option instructs it to start the server if it's not already on. You can create a new .desktop file with this command.

@fab6
Copy link

fab6 commented Feb 20, 2021

ok, thank you very much! I will check you I can get it to run with macos.. it seems that that the gui is not started from iterm, but the terminal emacs version.

@fab6
Copy link

fab6 commented Feb 20, 2021

and it looks actually here https://emacs.stackexchange.com/questions/18507/os-x-and-daemon-mode that this is not so easy to get the middle ground running on macos...

@lebensterben
Copy link
Contributor

@fab6
it's just a one time set-up.

@fab6
Copy link

fab6 commented Feb 20, 2021

@lebensterben yes, that would not be the problem but I understood this part
image
that it might not even possible to get this running on macos without be plainly using gui... but maybe I misunderstood it

@lebensterben
Copy link
Contributor

Best solution is to use Linux. bugOS is hard to use.

@fab6
Copy link

fab6 commented Feb 21, 2021

yes, that's right...

@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 Mar 14, 2022
@github-actions github-actions bot closed this as completed May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale marked as a stale issue/pr (usually by a bot)
Projects
None yet
Development

No branches or pull requests

9 participants