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

Restructure zk--id-list to take fuller advantage of passed zk-alist #61

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

boyechko
Copy link
Contributor

This is just a slight change in the logic, so nothing has changed aside from big performance improvement when ZK-ALIST is passed but STR is not.

@localauthor
Copy link
Owner

localauthor commented Jun 28, 2023

I can't find any cases where 'zk--id-list' is called with zk-alist but not str. Do you have some examples of where this improves performance?

There used to be several such cases, but they were all removed in 5f40cae.

edit: It actually seems that the zk-alist option in 'zk--id-list' is vestigial and could be safely removed. WDYT?

@boyechko
Copy link
Contributor Author

I started down this rabbit hole because of zk-desktop-make-buttons, which ought to be calling zk--id-list with ZK-ALIST but not STR (another commit to this pull request forthcoming). There is also potential to take advantage of this in zk-index-query-files, though that might be a separate PR down the line.

@@ -234,7 +234,7 @@ To quickly change this setting, call `zk-desktop-add-toggle'."
;; replace titles
(goto-char (point-min))
(let* ((zk-alist (zk--alist))
(ids (zk--id-list)))
(ids (zk--id-list nil zk-alist)))
Copy link
Owner

@localauthor localauthor Jun 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But if str is nil, then zk--alist function is never called, and not used; the function just goes straight to zk--parse-file, right? Am I missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was the point of d6be688: if zk-alist is passed to zk--id-list, no matter whether str is nil or not, the function uses the passed zk-alist rather than redoing all the work with zk--parse-file.

This is just a slight change in the logic, so nothing has changed aside from big
performance improvement when ZK-ALIST is passed but STR is not.
@boyechko boyechko force-pushed the feat/zk--id-list-performance-boost branch from 1c13fb1 to 46efaaf Compare July 16, 2023 22:27
A lot of these are very difficult to benchmark, but considering the following
benchmarks, there is potential to considerably speed up various zk-desktop and
zk-index commands. The change to `zk-index-query-files` will likely result in
greatest benefit, since we go from running `zk--alist` three times to running it
once. `zk--parse-id` did not pass on its zk-alist to `zk--id-list` either.

```
=== bm/zk--id-list+use-zk-alist (10 reps) at 2023-07-16 15:26 ===
((zk--id-list/orig))               =>  3049 results in 0.97 sec (inc. 0.56 sec for 0 GCs)
((zk--id-list))                    =>  3049 results in 0.95 sec (inc. 0.56 sec for 0 GCs)

((zk--id-list/orig nil zk-alist))  =>  3049 results in 0.98 sec (inc. 0.58 sec for 0 GCs)
((zk--id-list nil zk-alist))       =>  3049 results in 0.03 sec (inc. 0.02 sec for 0 GCs)
```
@boyechko
Copy link
Contributor Author

A lot of the commands are interactive and difficult to benchmark, but considering the following benchmarks, there is potential to considerably speed up various zk-desktop and zk-index commands. The change to zk-index-query-files will likely result in greatest benefit, since we go from running zk--alist three times to running it once. zk--parse-id did not pass on its zk-alist to zk--id-list either, so that would add further performance enhancements.

=== bm/zk--id-list+use-zk-alist (10 reps) at 2023-07-16 15:26 ===
((zk--id-list/orig))               =>  3049 results in 0.97 sec (inc. 0.56 sec for 0 GCs)
((zk--id-list))                    =>  3049 results in 0.95 sec (inc. 0.56 sec for 0 GCs)

((zk--id-list/orig nil zk-alist))  =>  3049 results in 0.98 sec (inc. 0.58 sec for 0 GCs)
((zk--id-list nil zk-alist))       =>  3049 results in 0.03 sec (inc. 0.02 sec for 0 GCs)

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