Skip to content

fix(db): disable SQLite mmap to prevent DB size inflating RSS#22553

Closed
zhumengzhu wants to merge 1 commit intoanomalyco:devfrom
zhumengzhu:fix/sqlite-mmap-maxlisteners
Closed

fix(db): disable SQLite mmap to prevent DB size inflating RSS#22553
zhumengzhu wants to merge 1 commit intoanomalyco:devfrom
zhumengzhu:fix/sqlite-mmap-maxlisteners

Conversation

@zhumengzhu
Copy link
Copy Markdown

@zhumengzhu zhumengzhu commented Apr 15, 2026

Issue for this PR

Ref #22428 (same fix, that PR is still open — this supersedes it).

Type of change

  • Bug fix

What does this PR do?

Bun enables SQLite memory-mapped I/O by default, mapping the entire DB file
into the process address space. A 1.1 GB database adds ~1.8 GB to RSS
regardless of how much data is actually accessed. One line added to the
existing PRAGMA initialization block in src/storage/db.ts:

db.run("PRAGMA mmap_size = 0")

Same fix as proposed by @jiangliang79 in #22428.

How did you verify your code works?

  • Full test suite passes (1890 pass, pre-existing 1 fail unrelated to this change)
  • Confirmed mmap_size PRAGMA was not previously set in the codebase

Screenshots / recordings

N/A

Checklist

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

Bun enables SQLite memory-mapped I/O by default, mapping the entire DB
file into the process address space. A 1.1 GB database adds ~1.8 GB to
RSS regardless of how much data is actually accessed.

Add PRAGMA mmap_size = 0 to the existing PRAGMA initialization block.

Ref anomalyco#22428

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions github-actions bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Apr 15, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Related PR Found:

Why it's related: This is the exact PR mentioned in the current PR's description. PR #22553 is explicitly stated to supersede #22428 as it implements the same fix (adding PRAGMA mmap_size = 0 to prevent SQLite memory-mapped I/O from inflating RSS). The current PR is the updated version that should be merged instead of #22428.

@github-actions github-actions bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Apr 15, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@zhumengzhu
Copy link
Copy Markdown
Author

Closing in favor of #22428 which proposes the identical fix with more detailed analysis (macOS ARM64 footprint measurements). Please consider merging that one.

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.

1 participant