Skip to content

At after-save-hook schedule file for idle update#1032

Merged
jethrokuan merged 10 commits intoorg-roam:masterfrom
cpbotha:cpb-update-db-when-idle
Aug 12, 2020
Merged

At after-save-hook schedule file for idle update#1032
jethrokuan merged 10 commits intoorg-roam:masterfrom
cpbotha:cpb-update-db-when-idle

Conversation

@cpbotha
Copy link
Contributor

@cpbotha cpbotha commented Aug 11, 2020

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-file as 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.

@cpbotha
Copy link
Contributor Author

cpbotha commented Aug 11, 2020

Please let me know if I should put this save-when-idle behaviour behind a customize variable, defaulting to the current immediate save behaviour.

@cpbotha cpbotha force-pushed the cpb-update-db-when-idle branch from 2f91686 to b17131f Compare August 12, 2020 06:03
@cpbotha
Copy link
Contributor Author

cpbotha commented Aug 12, 2020

Thank you for your review @jethrokuan ! I have taken care of all issues, rebased on current master, and automated tests are all green.

@jethrokuan jethrokuan merged commit 11aac39 into org-roam:master Aug 12, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 7, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants