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

perf: calculate anzu count faster and with less memory #725

Merged
merged 1 commit into from
Jun 24, 2024

Conversation

kisaragi-hiu
Copy link
Contributor

Instead of allocating a list with N items and returning its length, just keep a tally of the number directly. This can also avoid generating lots of garbage that has to be collected.

The performance impact can be tested with this when using Evil:

(benchmark-run 10 ; or some other number of repetitions
  (let ((last-kbd-macro [?/ ?. return])) ; initiate an evil search for the pattern "."
    (call-last-kbd-macro)))

On my machine in a 2.3 MB file, this went from 27.06 seconds (2.7 seconds per iteration) to 25.98 seconds (2.6 seconds per iteration), but before this change I also sometimes experience lockups where the search inexplicably takes several times longer.

Instead of allocating a list with N items and returning its length, just
keep a tally of the number directly. This can also avoid generating lots
of garbage that has to be collected.

The performance impact can be tested with this:

  (benchmark-run 10 ; or some other number of repetitions
    (let ((last-kbd-macro [?/ ?. return]))
      (call-last-kbd-macro)))
@seagle0128 seagle0128 merged commit 1a13abc into seagle0128:master Jun 24, 2024
10 of 12 checks passed
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

Successfully merging this pull request may close these issues.

None yet

2 participants