Skip to content

Conversation

@pepperoni505
Copy link
Contributor

@pepperoni505 pepperoni505 commented Jan 30, 2026

Fixes #39

For some queries, SQLite needs to make a temporary file to store intermediate results. By default, this is set to be stored on the disk to avoid high memory usage, however it is possible to configure it to store this in-memory. The draw-back, obviously, is higher memory usage.

Due to complications with file permissions in the work folder in the sim, SQLite was not able to properly utilize the temporary dir that is set (even with manually setting sqlite3_temp_directory), so we are forced to move it to in-memory.

Using the query in #39, here is the WASM memory view before execution:
image
And here it is after:
image

The linear memory difference is 9.308MB (the query did not take up 100% of that difference, as there are other allocations that can bump that; however the query was the main contributor). The sim properly decommitted the pages shortly after. Running the query twice before the sim decommits the pages does not lead to an increase in the linear memory size, so SQLite is properly cleaning itself up in between.

Developers should be wary to avoid large queries that may result in larger allocations here.

@pepperoni505 pepperoni505 requested a review from a team as a code owner January 30, 2026 10:46
@pepperoni505 pepperoni505 mentioned this pull request Jan 30, 2026
@pepperoni505 pepperoni505 merged commit 9463f51 into main Jan 30, 2026
5 checks passed
@pepperoni505 pepperoni505 deleted the fix-tempdir branch January 30, 2026 11:51
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.

SQL execution error

3 participants