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

Swiper is very slow on some files, but only when I have display-line-numbers 'visual #1748

Open
alienbogart opened this issue Sep 10, 2018 · 4 comments

Comments

@alienbogart
Copy link

alienbogart commented Sep 10, 2018

  • GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 2.24.31) of 2018-08-16
  • Swiper version 20180813.1625
  • init.el

Swiper performs very well on Org files, opening in less than 2 seconds on my 3400 init.org, but it takes five seconds to show up on a .vim file with 216 lines, and on an i3 config file with 392 lines. If I switch to text-mode it is still slow, but it works well if I change it to fundamental-mode. I use this functions to set relative numbers:

(defun line-numbers ()
  (interactive)
(setq display-line-numbers 'visual)
(setq display-line-numbers-widen nil)
(setq display-line-numbers-current-absolute nil))

  (defun noct:relative ()
    (setq-local display-line-numbers 'visual))
  (defun noct:absolute ()
    (setq-local display-line-numbers t))
  (custom-set-faces '(line-number-current-line ((t :weight bold
                                                   :foreground "goldenrod"

And I have the following hooks to enable it:

(add-hook 'text-mode-hook 'line-numbers)
(add-hook 'prog-mode-hook 'line-numbers)

When I disable the line numbers Swiper responds much faster, but still a bit slower. I tried changing (setq display-line-numbers 'visual) to (setq display-line-numbers 'relative), and the performance does improve, but I on my init org file the numbers are so high that it's unpractical to navigate by line number (I'm an Evil user).

@abo-abo
Copy link
Owner

abo-abo commented Sep 10, 2018

Please provide a sample file, .vim for instance.

@alienbogart
Copy link
Author

Here you go.

@abo-abo
Copy link
Owner

abo-abo commented Sep 12, 2018

I ran:

(benchmark-run 100
  (swiper--candidates))

on your init.vim file with relative line numbers. It took 0.2s for 100 runs, so that's 0.002s per run.
The issue is not reproducible on GNU Emacs 26.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.18.9).

@alienbogart
Copy link
Author

Thank you! Do you have any suggestions on how could I proceed to further debug this problem?

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