-
-
Notifications
You must be signed in to change notification settings - Fork 16
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
Optimize #30
Optimize #30
Conversation
I think the problem is that you did not compile (defun minions--benchmark ()
(let ((minions-direct '(smerge-mode symbol-overlay-mode diff-minor-mode))
(fn (byte-compile (pcase-lambda (`(,mode))
(memq mode minions-direct)))))
(list
(cons "cl-loop "
(benchmark-run 1000 (cl-loop for mode in minor-mode-alist
if (memq (car mode) minions-direct)
collect mode)))
(cons "cl-remove-if-not lambda "
(benchmark-run 1000 (cl-remove-if-not (lambda (elt)
(memq (car elt) minions-direct))
minor-mode-alist)))
(cons "seq-filter lambda "
(benchmark-run 1000 (seq-filter (lambda (elt)
(memq (car elt) minions-direct))
minor-mode-alist)))
(cons "cl-remove-if-not pcase-lambda "
(benchmark-run 1000 (cl-remove-if-not (pcase-lambda (`(,mode))
(memq mode minions-direct))
minor-mode-alist)))
(cons "seq-filter pcase-lambda "
(benchmark-run 1000 (seq-filter (pcase-lambda (`(,mode))
(memq mode minions-direct))
minor-mode-alist)))
(cons "cl-remove-if-not pcase-lambda (compiled)"
(benchmark-run 1000 (cl-remove-if-not fn minor-mode-alist)))
(cons "seq-filter pcase-lambda (compiled)"
(benchmark-run 1000 (seq-filter fn minor-mode-alist)))))) Uncompiled:
Compiled:
Not sure why it makes whether the
Not sure what happened to the tags. I have pushed them again. I don't add a |
No, the problem is that the :eval expression is not compiled since it is a list literal. Of course I use a compiled minions package. But you are right that cl-loop is not the best choice here, but it matters much less than using compiled vs non-compiled evaluation for the :eval expression. |
I pushed an improved version which uses cl-remove-if-not.
What about MELPA Stable? |
Extract a separate function to allow compilation instead of slow evaluation. This optimization helps when scrolling through large documents, where previously the minions mode line eval appeared in the profile for redisplay. The bottleneck is `pcase-lambda', which performs horribly when not compiled. Because the whole file might not be compiled drop using it altogether. Also use `cl-filter-if-not' instead of `seq-filter', for an additional, though tiny speedup, and also because it allows dropping a dependency.
Ah sorry, I didn't read your description properly and immediately bounced on the switch to I improved the commit message a bit. Does this look okay to you? |
It gets the version from the latest version tag, not from the |
Yes, the commit message is better. Thanks! |
Thanks to you too! |
By the way, how did you get your hands on "the profile for redisplay"? |
I profiled a new package of mine which was quite slow during redisplay when scrolling around due to too many text properties. I was able to optimize the scroll redisplay a bit by reducing and sharing more of the attached properties. This minions issue was just an incidental finding. There was some high cost related to the mode line, eval and seq-filter. I am using a very simple mode line - basically only minions, so the issue was quickly found. Btw, thanks a lot for minions! I really like that I don't have to configure anything besides a few |
I was more wondering about how than why, as it would probably be a good idea to perform some redisplay benchmarking but I don't know how.
You are welcome! I like your packages too. 😄 |
Extract separate function to allow compilation instead of slow evaluation. Use
cl-loop instead of seq-filter. This optimization helps when scrolling through
large documents, where previously the minions mode line eval appeared in the
profile for redisplay.
(You may also want to consider tagging a version?)