Skip to content

Optimize Image persistance queries#665

Merged
toksdotdev merged 3 commits intosuperradcompany:mainfrom
wellsbunk5:databaseQueryOptimizations
May 4, 2026
Merged

Optimize Image persistance queries#665
toksdotdev merged 3 commits intosuperradcompany:mainfrom
wellsbunk5:databaseQueryOptimizations

Conversation

@wellsbunk5
Copy link
Copy Markdown
Contributor

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.

Comment thread crates/microsandbox/lib/image/mod.rs
Comment thread crates/microsandbox/lib/image/mod.rs
wellsbunk5 and others added 3 commits May 4, 2026 16:00
…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>
@wellsbunk5 wellsbunk5 force-pushed the databaseQueryOptimizations branch from 716063b to 05d9b66 Compare May 4, 2026 22:01
@toksdotdev toksdotdev merged commit 46ad462 into superradcompany:main May 4, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants