-
-
Notifications
You must be signed in to change notification settings - Fork 485
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
(feature): use sqlite as backing database #200
Conversation
5f9b949
to
3986d21
Compare
e37c9fd
to
fe8f663
Compare
Hopefully this is a one-time degradation, which then remains mostly constant as the size of the roam db grows. And memory usage gets capped too. |
The size of the Roam DB grows really slowly (all text, from one person). RAM usage is basically nothing. As for disk memory, it's now at 400kb for my database. |
with this setup, on quit I am now asked about quiting active processes. I assume its ok to say yes to that, right? |
Yes, but it's not a graceful kill of the database process. Maybe a hook should be added to kill-emacs to call for a DB connection shutdown. |
So the check for active processes happens before hooks for |
@jethrokuan Not sure if this would necessarily be appropriate for this case, but I've used this before, and if it works here, it would be simpler. So FYI:
|
SIGHUP actually sounds alright. So all that extra machinery is redundant. |
How long should the db take to build, first time? An org-roam.db file is there, but after 20 minutes it remains empty and I see...
Seems like it's trying, but I'm guessing 20 minutes isn't normal :). I have eventually restarted Emacs but still nothing. |
I should perhaps mention that my roam directory has fewer than 200 files. |
@jackbaty 5 seconds maybe? Mine has more than that, and takes 5 seconds. Probably a bug somewhere. Do the following steps in order:
Edit: you probably didn't manually run |
That did it, thanks! I'm not sure what I might have done to confuse things first launch so I may not be much help with debugging, sorry. One thing I did notice after my last comment is that today's file was in the db, but it was the only one. |
Since |
It alls seems to work quite well. I haven't had any problems with upgrading. Is there anything else that I could test? |
awesome, that's good to hear! I guess just keep on the lookout any performance degradations or bugs. I'm going to make a couple more breaking changes and simplifications, and then probably release it as 1.0.0. |
I also had to rebuild the graph the first time, I presume as a "first time" step. When I run |
the graph produced is a materialized view of what the SQL database contains, so I suppose so. |
Is there a way to scan the directory and pick up the links? My mental model of the system assumed this would be the case, or was the case with the prior version. I admit I did not use the graph before, so I could be off base here. |
Sorry, I don't really understand. Is the graph not showing you the same as what you're seeing before? Because it should be exactly the same. |
I did not use the graph before today. But the graph only shows links between items that I added today, after the sqlite db update came into use, nothing from my earlier notes that I added. |
that's not right. Could you run |
I had already done I just explored the db with So I guess sqlite is not the problem. |
Digging further, the |
seems like a bug there, could be a double quote char messing up the dot output. |
Yes, that is exactly what I found |
i tried the graph before using the sqlite db and then after. before all the docs were there and after only some were. I have no docs with quotes in the titles. where do i look for the dot file? |
It's at |
Graceful shutdown is already guaranteed via `kill-emacs-hook`. Refs org-roam#200
Graceful shutdown is already guaranteed via `kill-emacs-hook`. Refs org-roam#200
Graceful shutdown is already guaranteed via `kill-emacs-hook`. Refs org-roam#200
Graceful shutdown is already guaranteed via `kill-emacs-hook`. Refs #200 Co-authored-by: Jethro Kuan <jethrokuan95@gmail.com>
The documentation hasn't been updated on how to install, so when using current instructions with latest master there are errors on startup about emacsql not found. Any ideas, or can the documentation be updated? |
If you're using something like |
Addresses #199. We move the link storage to a SQL database, to aid maintainability. Here are some pros and cons.
Pros
The cache computes the sha1 of the buffer contents. If buffer contents have changed, the relevant parts of the caches are updated. If the files are no longer there, they are also removed from the cache. That is, the
files
table allows us to maintain a consistent view of the cache.The cache is also persisted to disk, which means no startup time.
Since full cache rebuilds happen only once, we may also remove the dependency on
async
, and all the potential bugs that come with it.Since the cache is stored outside of Emacs, it can be used across multiple Emacs instances.
The code is greatly simplified, and a layer of data abstraction is helpful for maintainability.
We can use the sqlite database for other fancy things (full text search)
Cons
Likely to be slower than the current approach of having them in-memory in Emacs. From my testing so far, I have not noticed any lag. PKMs generally don't grow very big, at least not big enough for SQL to become too slow.
Additional dependency on sqlite and emacsql. Not a big deal.
The org-roam databases are NOT machine-independent yet. The absolute file paths are still stored in the cache. However,
org-roam-build-cache
will ensure that it still works when changing machines, although that means a full cache rebuild. Ideally, we'd store relative paths. That at least makes the database work on the same platforms (Unix, Windows).Call for testers
I've been running on this the whole day, and it's been nice and fine so far. I'll likely leave this up for a while. I think this is going to break most PRs, and I want to have this merged in first.