GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||
GeezerVison is showing github.com — refactor(core): enable incremental auto-vacuum before WAL initialization by dsadawq3 · Pull Request #56365 · anomalyco/opencode Conversation
|
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
The following comment was made by an LLM, it may be inaccurate: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The main storage change here doesn't work as described: incremental auto-vacuum is never enabled, for new or existing databases.
How I checked: I ran this PR's exact pragma sequence with bun:sqlite (the driver core uses on Bun):
PRAGMA auto_vacuum stays 0. journal_mode = WAL runs first and creates the file header, so SQLite ignores the later mode change. 2005 deleted pages were still on the freelist after reopening.0 and the freelist is unchanged, because switching from NONE needs a full VACUUM. incremental_vacuum(500) therefore has nothing to do.auto_vacuum = INCREMENTAL issued before journal_mode, a fresh database does get mode 2.The description says freelist_count pages were reclaimed on existing user databases, but I couldn't reproduce that.
The core database tests (32) pass and tsgo is clean.
Public API: unchanged. These are internal connection pragmas.
Other concerns, inline:
mmap_size brings back the memory growth earlier PRs tried to remove.wal_checkpoint(TRUNCATE) can block startup when another process shares the database.PRAGMA optimize runs before migrations.These are several unrelated tuning changes. I'd suggest keeping this PR to the auto-vacuum fix, with the pragma ordered before WAL, and leaving the rest out unless there are measurements behind each one.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| yield* db.run("PRAGMA cache_size = -64000") | ||
| yield* db.run("PRAGMA wal_checkpoint(PASSIVE)") | ||
| yield* db.run("PRAGMA temp_store = MEMORY") | ||
| yield* db.run("PRAGMA mmap_size = 268435456") |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
A 256 MB mmap maps up to 256 MB of opencode.db into every process that opens it (CLI, background service, desktop). Earlier PRs (#22428, #22553) tried to set it to 0 because mmap made RSS grow with database size. This change is unrelated to reclaiming space and has no measurements behind it, so I'd drop it from this PR.
This has no effect. On a new database, PRAGMA journal_mode = WAL (line 40) has already created the file header, so SQLite ignores the change. I got auto_vacuum = 0 with this exact sequence on a fresh file. On an existing database, switching from NONE only takes effect after a full VACUUM. As a result, incremental_vacuum(500) on line 49 never reclaims anything. For new databases, the mode has to be set before journal_mode = WAL. Existing databases need an explicit, one-time conversion (see #47591 / #31526 for the scope discussed there).
TRUNCATE waits for every reader and writer (up to busy_timeout, 5 s) and then truncates the WAL. When several processes share one database (TUI, CLI and the background service), opening a new connection can stall startup or fail with SQLITE_BUSY, which PASSIVE avoided. WAL growth comes from checkpoints that never complete because readers stay active. A blocking checkpoint only at startup doesn't address that.
PRAGMA optimize runs here before DatabaseMigration.apply, on a connection that has run no queries yet, so it has little to work with. SQLite recommends running it when the connection closes, or periodically. If you keep it, run it after migrations, or on close.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Before conversion, auto_vacuum: {
auto_vacuum: 0,
}
On open, current auto_vacuum: 0
After VACUUM, auto_vacuum: {
auto_vacuum: 2,
}
Freelist before incremental_vacuum: {
freelist_count: 124,
}
Freelist after incremental_vacuum: {
freelist_count: 0,
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Updated per feedback:
PRAGMA auto_vacuum = INCREMENTAL before PRAGMA journal_mode = WAL.disableWAL: true to sqliteLayer in Database.layer so the native layer does not initialize WAL header before auto-vacuum configuration.mmap_size, temp_store, and premature optimize pragmas to keep this PR strictly focused on the auto-vacuum fix.PRAGMA wal_checkpoint(PASSIVE) to prevent blocking concurrent processes.PRAGMA incremental_vacuum(500) after migrations.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
02d6cea to
843fc89
Compare
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.