Optimize Image persistance queries#665
Merged
toksdotdev merged 3 commits intosuperradcompany:mainfrom May 4, 2026
Merged
Conversation
toksdotdev
reviewed
May 4, 2026
…and the metadata.manifest_digest matches then we skip all layer updates and do a single statement to update last_used_at column Co-authored-by: Cursor <cursoragent@cursor.com>
…ended for WAL mode.
716063b to
05d9b66
Compare
toksdotdev
approved these changes
May 4, 2026
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The biggest change in this PR is to add a fast path for the Image upserts that happen on sandbox creation. If a image is reused and already cached there should be no need to upsert all image layers. Currently the upserts happen everytime a sandbox is created. This PR checks if the Image already exists and if the manifest digest matches. If the manifest digest matches there is no point to upsert all rows and instead does a single update last_used_at column statement. For cached images it removes 25~30 statements for each upsert.
I also added the PRAGMA synchronous = NORMAL to the sqlite connection. This makes it so it only fsyncs on WAL checkpoints. This is recommended in WAL mode and should speed up global write lock.