At after-save-hook schedule file for idle update#1032
Merged
jethrokuan merged 10 commits intoorg-roam:masterfrom Aug 12, 2020
Merged
At after-save-hook schedule file for idle update#1032jethrokuan merged 10 commits intoorg-roam:masterfrom
jethrokuan merged 10 commits intoorg-roam:masterfrom
Conversation
Contributor
Author
|
Please let me know if I should put this save-when-idle behaviour behind a customize variable, defaulting to the current immediate save behaviour. |
jethrokuan
requested changes
Aug 11, 2020
2f91686 to
b17131f
Compare
These are not supposed to be a buffer-local variables.
Contributor
Author
|
Thank you for your review @jethrokuan ! I have taken care of all issues, rebased on current master, and automated tests are all green. |
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On my setup (Samsung 970 EVO Plus NVMe SSD, Core i7 8750H, emacs 26.3 on WSL1 of Windows 20H2 beta channel, so not too slow) I see on average about 0.5 seconds per 500 lines of orgmode spent in
org-roam-db--update-fileas measured with the Emacs Lisp Profiler (elp).As you can imagine, this is quite noticeable when you have files of a thousand or two lines. Many of my org-roam files are small, but my monthly journal files are usually in that range. Also, I habitually save quite often as I work.
I know I'm not the only one.
This PR moves the actual save-hook org-roam db updating into an idle handler. Every time you invoke save, the filename is added to an idle-save-list if it's not already there. Whenever the idle handler runs (it should do this after 2s of idle time as measured by Emacs), it will run through the idle-save list and do all of the database updating.
In my workflow, this makes a major difference to the interactivity, as saving is now instantaneous again.