-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
feat(core): initialize SQLite off-main-thread #18401
Conversation
6dc1a14
to
c0619c4
Compare
9797b6f
to
2538c9c
Compare
2538c9c
to
f4d3d39
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks really good! I just have a few small comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice 👍
1855b71
to
574b1ce
Compare
14e12f5
to
7ce8b92
Compare
d3874c8
to
514313c
Compare
@mmastrac could you post latest benchmark results against |
I ran some benchmarks w/different journal modes, as I believe we're going to have to move from There's another optimization that wins us a few milliseconds - just dropping the SQLite connection without running cleanup. I want to hold that one back until I can confirm that we're not going to risk corruption with it, but there's no reason it should be any different than crashing, which is already safe w/SQLite. Summary:
Raw results:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
46bfb0d
to
9c12488
Compare
Co-authored-by: David Sherret <[email protected]>
…ons, so try a second time silently
9c12488
to
01575ab
Compare
…t in CacheDB (#18469) Fast-follow on #18401 -- the reason that some tests were panicking in the `CacheDB` `impl Drop` was that the cache itself was being dropped during panic and the runtime may or may not still exist at that point. We can reduce the actual tokio runtime testing to where it's needed. In addition, we return the journal mode to `TRUNCATE` to avoid the risk of data corruption.
This gets SQLite off the flamegraph and reduces initialization time by somewhere between 0.2ms and 0.5ms. In addition, I took the opportunity to move all the cache management code to a single place and reduce duplication. While the PR has a net gain of lines, much of that is just being a bit more deliberate with how we're recovering from errors. The existing caches had various policies for dealing with cache corruption, so I've unified them and tried to isolate the decisions we make for recovery in a single place (see `open_connection` in `CacheDB`). The policy I chose was: 1. Retry twice to open on-disk caches 2. If that fails, try to delete the file and recreate it on-disk 3. If we fail to delete the file or re-create a new cache, use a fallback strategy that can be chosen per-cache: InMemory (temporary cache for the process run), BlackHole (ignore writes, return empty reads), or Error (fail on every operation). The caches all use the same general code now, and share the cache failure recovery policy. In addition, it cleans up a TODO in the `NodeAnalysisCache`.
…t in CacheDB (#18469) Fast-follow on #18401 -- the reason that some tests were panicking in the `CacheDB` `impl Drop` was that the cache itself was being dropped during panic and the runtime may or may not still exist at that point. We can reduce the actual tokio runtime testing to where it's needed. In addition, we return the journal mode to `TRUNCATE` to avoid the risk of data corruption.
This gets SQLite off the flamegraph and reduces initialization time by somewhere between 0.2ms and 0.5ms. In addition, I took the opportunity to move all the cache management code to a single place and reduce duplication. While the PR has a net gain of lines, much of that is just being a bit more deliberate with how we're recovering from errors.
The existing caches had various policies for dealing with cache corruption, so I've unified them and tried to isolate the decisions we make for recovery in a single place (see
open_connection
inCacheDB
). The policy I chose was:The caches all use the same general code now, and share the cache failure recovery policy.
In addition, it cleans up a TODO in the
NodeAnalysisCache
.