Skip to content

perf(bench): add FTS trigger amplification benchmark (#1606 phase 1) - #1698

Merged
Sinity merged 1 commit into
masterfrom
feature/perf/fts-trigger-benchmark
May 28, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/perf/fts-trigger-benchmark

Conversation

@Sinity

@Sinity Sinity commented May 28, 2026 •

Copy link
Copy Markdown
Owner

Summary

Add two benchmark tests measuring content_blocks FTS trigger cost:

  1. test_content_blocks_fts_trigger_growth_is_subquadratic — incremental inserts (simulates live streaming O(N²) pattern)
  2. test_content_blocks_batch_insert_is_linear — batch insert baseline (simulates bulk catch-up linear scaling)

Both measure wall time for 20/50/100/200 block insertions and assert growth curves.

Ref #1658, ref #1606

Verification

  • nix develop -c pytest tests/benchmarks/test_fts_trigger_amplification.py -v → 2 passed
  • nix develop -c devtools verify --quick → exit_code 0

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Added performance benchmarks to validate SQLite FTS trigger behavior when inserting content blocks.
    • Ensures insert operations maintain predictable performance at scale, guarding against unexpected performance degradation.

Review Change Stack

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@Sinity
Sinity merged commit 8798b22 into master May 28, 2026
2 of 3 checks passed
@Sinity
Sinity deleted the feature/perf/fts-trigger-benchmark branch May 28, 2026 02:36
@coderabbitai

coderabbitai Bot commented May 28, 2026 •

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 4655f394-1445-48b7-85e7-c88d3002d23a

📥 Commits

Reviewing files that changed from the base of the PR and between 2253e25 and 7179e16.

📒 Files selected for processing (1)
  • tests/benchmarks/test_fts_trigger_amplification.py

📝 Walkthrough

Walkthrough

This PR adds a new benchmark module to measure and assert SQLite FTS trigger amplification behavior for content_blocks. A timing helper records per-insertion elapsed time, and two slow-marked benchmark tests compare insertion cost growth: incremental insertion (5× ratio bound at 200 vs. 20 blocks) and bulk insertion (3× ratio bound at 200 vs. 20 blocks).

Changes

FTS Trigger Amplification Benchmarks

Layer / File(s) Summary
Timing helper for block insertion
tests/benchmarks/test_fts_trigger_amplification.py
_timed_insert utility performs a single parameterized insert into content_blocks, commits immediately, and returns elapsed wall-clock time for the operation.
FTS trigger growth assertions
tests/benchmarks/test_fts_trigger_amplification.py
Two slow benchmark tests measure FTS trigger amplification: incremental insertion asserts mean per-block cost at 200 blocks is not >5× the mean at 20 blocks (guarding superlinear effects); batch insertion asserts per-block time ratio between 200 and 20 blocks stays <3× as a linear baseline.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

  • #1658: This PR directly implements the exact benchmark module and tests described in the issue to measure FTS trigger amplification for content_blocks.
  • #1606: The benchmark tests implement the requested FTS trigger amplification measurements and document the expected superlinear/O(N²) behavior referenced in this issue.

Poem

🐰 A rabbit hops through benchmarks bright,
Measuring triggers—are they tight?
FTS blooms with every block,
Five times costs? Let's check the clock!
Linear dreams and ratios bind,
Amplification measured, defined. ✨

✨ 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 feature/perf/fts-trigger-benchmark

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 and usage tips.

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.

1 participant