Skip to content

Tune client bootstrap sqlite cache size#2790

Merged
graphite-app[bot] merged 1 commit into
mainfrom
arda/sqlite-cache-size-bootstrap
Jun 29, 2026
Merged

Tune client bootstrap sqlite cache size#2790
graphite-app[bot] merged 1 commit into
mainfrom
arda/sqlite-cache-size-bootstrap

Conversation

@findolor

@findolor findolor commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Motivation

Browser local DB bootstrap spends most of its time applying the downloaded SQL dump through sqlite-web. Benchmarks with the real schema and 186,170-statement dump showed that increasing SQLite's connection-local page cache before dump execution significantly improves bootstrap time.

What changed

  • Added a client bootstrap helper that runs PRAGMA cache_size = -25000 through the existing local DB query path immediately before applying a dump.
  • Reused that helper for both dump application paths in ClientBootstrapAdapter::engine_run: fresh DB bootstrap and threshold-triggered rebootstrap.
  • Updated unit tests to assert the pragma runs before the dump SQL.

What intentionally did not change

  • Did not use sqlite-web transaction(); this continues to rely only on the existing query() callback path.
  • Did not add unsafe pragmas such as journal_mode = OFF or synchronous = OFF.
  • Did not change the CLI/producer bootstrap path.
  • Did not restore cache_size after bootstrap; this setting is intentionally left connection-local for the app session.

Verification

  • cargo test -p raindex_common raindex_client::local_db::pipeline::bootstrap
  • cargo test -p raindex_common
  • cargo check --target wasm32-unknown-unknown -p raindex_common
  • nix develop -c rainix-rs-static
  • Staged local review round with 2 read-only reviewers; both reported no actionable findings.

Reviewer notes

The key behavior to check is ordering: PRAGMA cache_size = -25000 should execute only when a bootstrap dump is about to be applied, and immediately before execute_batch(dump_stmt).

Summary by CodeRabbit

  • Bug Fixes
    • Improved database bootstrap behavior by applying a cache-related setting before loading imported data/schema dumps.
    • Made initialization more reliable across fresh database setup and rebuilds after size limits are exceeded.

Copy link
Copy Markdown
Collaborator Author

How to use the Graphite Merge Queue

Add the label Raindex-queue to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f18e08c0-9d0b-413a-a0a9-e9ae42bcc759

📥 Commits

Reviewing files that changed from the base of the PR and between 8fed043 and 5670a84.

📒 Files selected for processing (1)
  • crates/common/src/raindex_client/local_db/pipeline/bootstrap.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/common/src/raindex_client/local_db/pipeline/bootstrap.rs

📝 Walkthrough

Walkthrough

Bootstrap now runs a SQLite cache-size pragma before applying dump SQL during startup, and the affected tests were updated to match the new call order.

Changes

Bootstrap dump flow

Layer / File(s) Summary
Dump preamble and wiring
crates/common/src/raindex_client/local_db/pipeline/bootstrap.rs
Adds a cache-size pragma, wraps dump execution in apply_dump, and uses that helper in the fresh-database and threshold-exceeded branches.
Call-order tests
crates/common/src/raindex_client/local_db/pipeline/bootstrap.rs
Updates both bootstrap tests to expect the cache-size pragma before the dump SQL batch.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • 0xgleb
  • JuaniRios
  • hardyjosh

Poem

A rabbit hopped through SQLite night,
Then set cache size just right.
Thump, then the dump,
No skipped little bump,
And startup sailed onward in light. 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: adjusting the client bootstrap SQLite cache size.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch arda/sqlite-cache-size-bootstrap

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@findolor findolor self-assigned this Jun 26, 2026
@findolor findolor requested review from 0xgleb and JuaniRios June 26, 2026 13:02
@graphite-app

graphite-app Bot commented Jun 29, 2026

Copy link
Copy Markdown

Merge activity

graphite-app Bot pushed a commit that referenced this pull request Jun 29, 2026
## Motivation

Browser local DB bootstrap spends most of its time applying the downloaded SQL dump through sqlite-web. Benchmarks with the real schema and 186,170-statement dump showed that increasing SQLite's connection-local page cache before dump execution significantly improves bootstrap time.

## What changed

- Added a client bootstrap helper that runs `PRAGMA cache_size = -25000` through the existing local DB query path immediately before applying a dump.
- Reused that helper for both dump application paths in `ClientBootstrapAdapter::engine_run`: fresh DB bootstrap and threshold-triggered rebootstrap.
- Updated unit tests to assert the pragma runs before the dump SQL.

## What intentionally did not change

- Did not use sqlite-web `transaction()`; this continues to rely only on the existing `query()` callback path.
- Did not add unsafe pragmas such as `journal_mode = OFF` or `synchronous = OFF`.
- Did not change the CLI/producer bootstrap path.
- Did not restore `cache_size` after bootstrap; this setting is intentionally left connection-local for the app session.

## Verification

- `cargo test -p raindex_common raindex_client::local_db::pipeline::bootstrap`
- `cargo test -p raindex_common`
- `cargo check --target wasm32-unknown-unknown -p raindex_common`
- `nix develop -c rainix-rs-static`
- Staged local review round with 2 read-only reviewers; both reported no actionable findings.

## Reviewer notes

The key behavior to check is ordering: `PRAGMA cache_size = -25000` should execute only when a bootstrap dump is about to be applied, and immediately before `execute_batch(dump_stmt)`.

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

* **Bug Fixes**
  * Improved database bootstrap behavior by applying a cache-related setting before loading imported data.
  * Made initialization more reliable when setting up a fresh database or rebuilding after size limits are exceeded.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@graphite-app graphite-app Bot force-pushed the arda/sqlite-cache-size-bootstrap branch from 399c7ae to 8fed043 Compare June 29, 2026 07:17
## Motivation

Browser local DB bootstrap spends most of its time applying the downloaded SQL dump through sqlite-web. Benchmarks with the real schema and 186,170-statement dump showed that increasing SQLite's connection-local page cache before dump execution significantly improves bootstrap time.

## What changed

- Added a client bootstrap helper that runs `PRAGMA cache_size = -25000` through the existing local DB query path immediately before applying a dump.
- Reused that helper for both dump application paths in `ClientBootstrapAdapter::engine_run`: fresh DB bootstrap and threshold-triggered rebootstrap.
- Updated unit tests to assert the pragma runs before the dump SQL.

## What intentionally did not change

- Did not use sqlite-web `transaction()`; this continues to rely only on the existing `query()` callback path.
- Did not add unsafe pragmas such as `journal_mode = OFF` or `synchronous = OFF`.
- Did not change the CLI/producer bootstrap path.
- Did not restore `cache_size` after bootstrap; this setting is intentionally left connection-local for the app session.

## Verification

- `cargo test -p raindex_common raindex_client::local_db::pipeline::bootstrap`
- `cargo test -p raindex_common`
- `cargo check --target wasm32-unknown-unknown -p raindex_common`
- `nix develop -c rainix-rs-static`
- Staged local review round with 2 read-only reviewers; both reported no actionable findings.

## Reviewer notes

The key behavior to check is ordering: `PRAGMA cache_size = -25000` should execute only when a bootstrap dump is about to be applied, and immediately before `execute_batch(dump_stmt)`.

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

* **Bug Fixes**
  * Improved database bootstrap behavior by applying a cache-related setting before loading imported data.
  * Made initialization more reliable when setting up a fresh database or rebuilding after size limits are exceeded.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@findolor findolor force-pushed the arda/sqlite-cache-size-bootstrap branch from 8fed043 to 5670a84 Compare June 29, 2026 10:28
@graphite-app graphite-app Bot merged commit 5670a84 into main Jun 29, 2026
19 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

@coderabbitai assess this PR size classification for the totality of the PR with the following criterias and report it in your comment:

S/M/L PR Classification Guidelines:

This guide helps classify merged pull requests by effort and complexity rather than just line count. The goal is to assess the difficulty and scope of changes after they have been completed.

Small (S)

Characteristics:

  • Simple bug fixes, typos, or minor refactoring
  • Single-purpose changes affecting 1-2 files
  • Documentation updates
  • Configuration tweaks
  • Changes that require minimal context to review

Review Effort: Would have taken 5-10 minutes

Examples:

  • Fix typo in variable name
  • Update README with new instructions
  • Adjust configuration values
  • Simple one-line bug fixes
  • Import statement cleanup

Medium (M)

Characteristics:

  • Feature additions or enhancements
  • Refactoring that touches multiple files but maintains existing behavior
  • Breaking changes with backward compatibility
  • Changes requiring some domain knowledge to review

Review Effort: Would have taken 15-30 minutes

Examples:

  • Add new feature or component
  • Refactor common utility functions
  • Update dependencies with minor breaking changes
  • Add new component with tests
  • Performance optimizations
  • More complex bug fixes

Large (L)

Characteristics:

  • Major feature implementations
  • Breaking changes or API redesigns
  • Complex refactoring across multiple modules
  • New architectural patterns or significant design changes
  • Changes requiring deep context and multiple review rounds

Review Effort: Would have taken 45+ minutes

Examples:

  • Complete new feature with frontend/backend changes
  • Protocol upgrades or breaking changes
  • Major architectural refactoring
  • Framework or technology upgrades

Additional Factors to Consider

When deciding between sizes, also consider:

  • Test coverage impact: More comprehensive test changes lean toward larger classification
  • Risk level: Changes to critical systems bump up a size category
  • Team familiarity: Novel patterns or technologies increase complexity

Notes:

  • the assessment must be for the totality of the PR, that means comparing the base branch to the last commit of the PR
  • the assessment output must be exactly one of: S, M or L (single-line comment) in format of: SIZE={S/M/L}
  • do not include any additional text, only the size classification
  • your assessment comment must not include tips or additional sections
  • do NOT tag me or anyone else on your comment

@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

SIZE=M

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