Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Swiper takes over a second to start on very long files #416
This happens before I even start to type anything. Everytime I invoke swiper on a very large file (11k lines), it takes about 2 seconds to until the prompt shows up.
Swiper traverses the whole buffer to collect the lines. This can be a lengthy operation for large buffers.
However, having just tested org.el (25k lines), it takes < 0.5s to start up.
Another known issue is with
I suggest trying with minimal config - 2s sounds way too long for 11k lines. Perhaps also try
Or maybe my laptop is just slower than yours. :-)
Anyway, I've only just enabled swiper. I'll just keep using it for now and
Thanks for the package
On Fri, Mar 4, 2016 at 5:01 AM Oleh Krehel firstname.lastname@example.org wrote:
I have the same issue with several of my large Org-mode files. On my
So on my side, it is clearly not a second as mentioned in the title of this issue. It's so slow, that it's basically useless to me.
However, I do like Swiper very much. Therefore, as a workaround, I plan to switch my search method according to the number of lines of the current buffer. As an Elisp amateur, I let you know when I've got something working here.
Best case - of course - would be to find the reason for this performance lag. To shed some objective light on this issue, I did a profiler report for the time between invoking Swiper and the display of the search buffer before I start typing my search query:
Let me know when I can help you finding more information on this issue.
Thanks for your great work!
See the function from my config. It combines the best for
(global-set-key "\C-s" 'ora-swiper) (defun ora-swiper () (interactive) (if (and (buffer-file-name) (not (ignore-errors (file-remote-p (buffer-file-name)))) (if (eq major-mode 'org-mode) (> (buffer-size) 60000) (> (buffer-size) 300000))) (progn (save-buffer) (counsel-grep)) (swiper--ivy (swiper--candidates))))
I've been using it for weeks now, it's really convenient. The start-up time for
For a 60MB file consisting of
So I suggest you try the code above, let me know how it goes.
You're welcome, of course. I'm glad people like it.
Thanks for the ultra-fast response!
I do get issues with your code snippet though:
Remark: "I found #404" is really funny - pun not indented.
pushed a commit
Apr 10, 2016
added a commit
Apr 14, 2016
To wrap this up, the new function
Here's what I get in the package buffer (4143 lines):
0.5s start-up time is bearable to me. PRs to improve the speed of
Having investigated it a bit further, it seems
So only twice as fast start-up. Not good enough to be worth the effort, especially considering the there are bigger buffers.
Here's my draft implementation of an async swiper, if anyone wants to try it:
(defun ivy-isearch-function (s) (when (> (length s) 0) (let ((re (setq ivy--old-re (ivy--regex-plus s))) res) (with-ivy-window (goto-char (point-min)) (while (re-search-forward re nil t) (push (propertize (buffer-substring-no-properties (line-beginning-position) (line-end-position)) 'pos (match-end 0)) res)) (nreverse res))))) (defun ivy-isearch-action (x) (let ((pt (and x (get-text-property 0 'pos x)))) (when pt (goto-char pt)))) (defun ivy--isearch-update-input () (when ivy--old-re (swiper--cleanup) (with-ivy-window (ivy-isearch-action (ivy-state-current ivy-last)) (swiper--add-overlays ivy--old-re (window-start) (window-end (selected-window) t))))) (defun ivy-isearch () (interactive) (ivy-read "Swiper: " #'ivy-isearch-function :dynamic-collection t :action #'ivy-isearch-action :update-fn #'ivy--isearch-update-input :unwind #'swiper--cleanup :preselect (buffer-substring-no-properties (line-beginning-position) (line-end-position))))
It still needs some refinement.