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

speed-up swiper with buffer-substring-no-properties #2986

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

digikar99
Copy link

Okay... So a couple of points; only the last is relevant for this PR:

  1. I tried swiper-isearch - it is fast, but I liked the line-based nature of swiper. I'm unsure how to get C-n to behave as per next-line even after I used the :bind option of use-package with swiper-isearch-map.

  2. I tried setting (setq swiper-use-visual-line nil) and (setq swiper-use-visual-line-p 'ignore) but this didn't seem to have much impact on performance.

  3. So, I ended up playing around with the swiper function and noted that swiper--line is causing substantial slowness. Ideally, avoiding concat and using buffer-substring-no-properties should get maximal performance. But avoiding concat causes the first character of each line to not be visible, and I'm unsure where else to tweak so that the first character remains visible; the first character does get used up for searches though! Until then and perhaps even then, using the no-properties versions should help with performance!

And thanks for the package!

@abo-abo
Copy link
Owner

abo-abo commented Sep 11, 2022

Could you please provide some test data so that I can benchmark this? I think the tradeoff here is to use the font-lock in the minibuffer for better performance?

@digikar99
Copy link
Author

I think the tradeoff here is to use the font-lock in the minibuffer for better performance?

Yes!

Could you please provide some test data so that I can benchmark this?

I'm using the *Packages* buffer created by M-x packages-list-packages.

ELISP> (setq swiper-candidates-no-properties nil)
nil
ELISP> (benchmark-run 1
         (with-current-buffer "*Packages*"
           (swiper--candidates)))
(0.147308866 0 0.0)

ELISP> (benchmark-run 1
         (with-current-buffer "*Packages*"
           (swiper--candidates)))
(0.147759028 0 0.0)

ELISP> (benchmark-run 1
         (with-current-buffer "*Packages*"
           (swiper--candidates)))
(0.45313882299999997 1 0.27991091999999895) ; additional time due to GC (ignore?)

ELISP> (benchmark-run 1
         (with-current-buffer "*Packages*"
           (swiper--candidates)))
(0.156065012 0 0.0)

ELISP> (setq swiper-candidates-no-properties t)
t
ELISP> (benchmark-run 1
         (with-current-buffer "*Packages*"
           (swiper--candidates)))
(0.040975122 0 0.0)

ELISP> (benchmark-run 1
         (with-current-buffer "*Packages*"
           (swiper--candidates)))
(0.8876974980000001 1 0.8258823290000006)  ; additional time due to GC (ignore?)

ELISP> (benchmark-run 1
         (with-current-buffer "*Packages*"
           (swiper--candidates)))
(0.041128011 0 0.0)

ELISP> (benchmark-run 1
         (with-current-buffer "*Packages*"
           (swiper--candidates)))
(0.039684066 0 0.0)

ELISP> (benchmark-run 1
         (with-current-buffer "*Packages*"
           (swiper--candidates)))
(0.059413401 0 0.0)

ELISP> (benchmark-run 1
         (with-current-buffer "*Packages*"
           (swiper--candidates)))
(0.058499278 0 0.0)

Even in terms of the responsiveness, the no-properties version is snappy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants