Skip to content

perf(db): enable auto-vacuum and add periodic maintenance#23053

Open
BYK wants to merge 1 commit intoanomalyco:devfrom
BYK:perf/db-auto-vacuum
Open

perf(db): enable auto-vacuum and add periodic maintenance#23053
BYK wants to merge 1 commit intoanomalyco:devfrom
BYK:perf/db-auto-vacuum

Conversation

@BYK
Copy link
Copy Markdown
Contributor

@BYK BYK commented Apr 17, 2026

Issue for this PR

Closes #16729

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Enables incremental auto-vacuum on the SQLite database and adds periodic maintenance functions.

On first run, a one-time migration checks PRAGMA auto_vacuum — if it's 0 (none), it switches to incremental mode (PRAGMA auto_vacuum = 2) and runs a full VACUUM to restructure the file. Subsequent runs skip this.

Also adds exported checkpoint() (WAL checkpoint TRUNCATE) and vacuum() (incremental vacuum 500 pages) functions for periodic maintenance.

Without auto-vacuum, the database file only grows — deleted rows leave free pages that are never reclaimed. This is especially impactful for long-running instances with session retention cleanup.

How did you verify your code works?

  • Verified PRAGMA auto_vacuum switches from 0 to 2 on first run
  • Confirmed checkpoint and vacuum functions execute without errors
  • Tested that subsequent startups skip the migration

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions
Copy link
Copy Markdown
Contributor

Hey! Your PR title perf(db): enable auto-vacuum and add periodic maintenance doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

High memory usage and database bloat in long-running OpenCode instances

1 participant