Skip to content
Source
Sign inSign up
TanStack/db

ci: benchmark PRs against main with the incremental update suite #1650

Mergedkevin-dp(GitHub profile, opens in a new tab)merged 4 commits intomain fromrefs/pull/1650/headmerged by KyleAMathews

Summary

Extracts the incremental update benchmark from #1648 into a standalone suite and adds a CI workflow that automatically measures the performance impact of PRs against main.

What's included

  • scripts/bench/incremental-update.ts — the benchmark from #1648, with the opt-in perf-tracing removed (those trace hooks only exist on that branch's instrumented code paths, so the extracted benchmark relies purely on its own wall-clock timing and runs against any revision). It measures per-write latency (median/p75/p95/min/max/stddev) plus cold hydrate time for five live-query shapes — filtered+ordered list, join, aggregate subquery, nested includes, detail view — across fixture scales (100/1k/10k rows), source index modes (none/manual), and mutation modes (synced/optimistic).
  • scripts/bench/compare-incremental-update.ts — compares two benchmark reports and emits a markdown summary: per-case deltas with significance flags (default: >20% relative and >0.05ms absolute, so sub-ms jitter isn't flagged), plus geometric-mean ratios overall and per group to surface consistent shifts that are individually below the noise floor.
  • .github/workflows/benchmark.yml — runs on non-draft PRs that touch packages/db, packages/db-ivm, or the benchmark itself (and on workflow_dispatch). It benchmarks the PR merge commit and its merge-base with main back-to-back on the same runner using the same benchmark code for both sides, then publishes the comparison as a job summary, uploads the raw reports as artifacts, and posts/updates a sticky PR comment (skipped gracefully for fork PRs, whose token is read-only — the job summary always has the results).

Trigger choice

Draft PRs are skipped, so the benchmark starts when a PR is opened/marked ready for review and re-runs on pushes to it (with concurrency cancellation). Easy to tighten later (e.g. label-gated or on approval only) by changing the on:/if: conditions.

Validation

  • Benchmark runs green against current main (the suite is decoupled from #1648's code changes).
  • Compared two same-code runs: overall geomean 1.01×, no significant changes flagged — the noise floor holds.
  • Compared #1648's branch against main with this tooling: overall geomean 0.86× with consistent per-group improvements at the 10k scale (down to 0.5× medians), demonstrating that real perf changes are clearly visible in the report. (It also flagged a >3× median regression for the issue detail + comments case with optimistic writes at 10k scale on that branch — worth a look over there.)
  • Full local run takes ~12s (M2); the CI config uses 100 iterations + 20 warmup writes per case, so the whole job should stay in the low minutes.
  • Workflow passes zizmor with no findings.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added a new Benchmark workflow that runs on pull requests and manual dispatch, generating baseline vs. candidate benchmark outputs and summaries.
    • Introduced an incremental update benchmark runner with configurable scenarios, warmups, iterations, and detailed runtime metrics.
    • Added a comparison tool that produces a Markdown report with regression/improvement detection and rich per-case breakdowns.
  • Bug Fixes
    • Improved handling for draft and forked pull requests when skipping runs and updating PR comments.
  • Documentation
    • Benchmark results are now posted to PR comments and included in job summaries for easier review.
    1. github-actions[bot](GitHub profile, opens in a new tab)commented

      Incremental update benchmark

      Comparing b3988488 (this PR) against de8d0f1b (base). Times are per-write medians over 100 iterations (20 warmup writes).

      1 regression(s), 1 improvement(s) (threshold: ±20% and >0.05ms).

      Overall median write time vs base: 1.01× (geometric mean of per-case ratios; lower is faster).

      QueryΔ median (geomean)Best caseWorst caseFlags
      list: newest 50 open-3.8%-46.4%+17.5%—
      list + author+1.7%-40.5%+69.9%—
      list + comment count+5.7%-13.0%+31.7%—
      list + 3 recent comments+3.1%-56.0%+142.0%1 🔴 1 🟢
      issue detail + comments+0.2%-37.2%+80.0%—

      Each row aggregates the 12 scale/index/write-mode configurations of that query; per-configuration tables below.

      100 rows/collection | source indexes: none | synced writes — geomean 1.08×
      QueryBase medianPR medianΔ medianBase p95PR p95Δ p95
      list: newest 50 open0.088ms0.093ms+6.4%0.230ms0.228ms-1.1%
      list + author0.117ms0.128ms+9.9%0.259ms0.251ms-3.1%
      list + comment count0.316ms0.348ms+10.2%0.513ms0.501ms-2.3%
      list + 3 recent comments0.118ms0.146ms+23.4%0.251ms0.321ms+28.1%
      issue detail + comments0.081ms0.075ms-7.9%0.192ms0.162ms-15.4%
      100 rows/collection | source indexes: none | optimistic writes — geomean 1.09×
      QueryBase medianPR medianΔ medianBase p95PR p95Δ p95
      list: newest 50 open0.047ms0.052ms+11.8%0.119ms0.110ms-6.8%
      list + author0.059ms0.073ms+24.2%0.138ms0.136ms-1.1%
      list + comment count0.121ms0.159ms+31.7%0.275ms0.253ms-8.1%
      list + 3 recent comments0.078ms0.070ms-10.0%0.184ms0.147ms-20.1%
      issue detail + comments0.047ms0.044ms-6.7%0.099ms0.109ms+9.8%
      100 rows/collection | source indexes: manual | synced writes — geomean 0.94×
      QueryBase medianPR medianΔ medianBase p95PR p95Δ p95
      list: newest 50 open0.059ms0.032ms-46.4%0.078ms0.067ms-14.2%
      list + author0.042ms0.043ms+0.4%0.065ms0.093ms+43.0%
      list + comment count0.200ms0.174ms-13.0%0.266ms0.228ms-14.1%
      list + 3 recent comments0.078ms0.122ms+57.6%0.155ms0.161ms+4.1%
      issue detail + comments0.047ms0.047ms-0.4%0.091ms0.080ms-12.5%
      100 rows/collection | source indexes: manual | optimistic writes — geomean 0.90×
      QueryBase medianPR medianΔ medianBase p95PR p95Δ p95
      list: newest 50 open0.037ms0.037ms+0.5%0.085ms0.069ms-18.4%
      list + author0.090ms0.053ms-40.5%0.125ms0.128ms+2.7%
      list + comment count0.087ms0.088ms+0.9%0.210ms0.193ms-8.3%
      list + 3 recent comments0.061ms0.059ms-2.4%0.094ms0.124ms+31.6%
      issue detail + comments0.044ms0.043ms-1.2%0.076ms0.064ms-15.5%
      1,000 rows/collection | source indexes: none | synced writes — geomean 1.05×
      QueryBase medianPR medianΔ medianBase p95PR p95Δ p95
      list: newest 50 open0.029ms0.029ms+0.4%0.043ms0.055ms+28.3%
      list + author0.071ms0.068ms-4.5%0.088ms0.075ms-14.3%
      list + comment count0.110ms0.106ms-3.8%0.201ms0.220ms+9.3%
      list + 3 recent comments0.079ms0.062ms-21.5%0.261ms0.078ms-70.2%
      issue detail + comments0.041ms0.074ms+80.0%0.056ms0.088ms+59.4%
      1,000 rows/collection | source indexes: none | optimistic writes — geomean 0.96×
      QueryBase medianPR medianΔ medianBase p95PR p95Δ p95
      list: newest 50 open0.039ms0.046ms+17.5%0.084ms0.176ms+108.9%
      list + author0.086ms0.084ms-1.9%0.175ms0.122ms-30.3%
      list + comment count0.088ms0.093ms+5.4%0.147ms0.147ms+0.0%
      list + 3 recent comments0.054ms0.057ms+6.5%0.113ms0.075ms-33.1%
      issue detail + comments0.066ms0.042ms-37.2%0.092ms0.060ms-34.3%
      1,000 rows/collection | source indexes: manual | synced writes — geomean 1.02×
      QueryBase medianPR medianΔ medianBase p95PR p95Δ p95
      list: newest 50 open0.028ms0.026ms-7.0%0.061ms0.029ms-52.7%
      list + author0.038ms0.037ms-2.6%0.051ms0.071ms+37.7%
      list + comment count0.109ms0.121ms+11.1%0.127ms0.174ms+36.8%
      list + 3 recent comments0.065ms0.070ms+7.5%0.128ms0.142ms+11.0%
      issue detail + comments0.041ms0.042ms+2.4%0.052ms0.064ms+24.0%
      1,000 rows/collection | source indexes: manual | optimistic writes — geomean 1.06×
      QueryBase medianPR medianΔ medianBase p95PR p95Δ p95
      list: newest 50 open0.033ms0.032ms-3.2%0.038ms0.041ms+8.3%
      list + author0.046ms0.048ms+5.2%0.056ms0.083ms+49.8%
      list + comment count0.084ms0.104ms+23.9%0.110ms0.163ms+48.2%
      list + 3 recent comments0.059ms0.056ms-4.2%0.107ms0.093ms-13.1%
      issue detail + comments0.040ms0.044ms+8.5%0.053ms0.087ms+63.7%
      10,000 rows/collection | source indexes: none | synced writes — geomean 1.07×
      QueryBase medianPR medianΔ medianBase p95PR p95Δ p95
      list: newest 50 open0.028ms0.027ms-5.1%0.032ms0.030ms-6.4%
      list + author0.040ms0.068ms+69.9%0.048ms0.087ms+82.0%
      list + comment count0.102ms0.110ms+7.4%0.138ms0.218ms+57.6%
      list + 3 recent comments0.080ms0.069ms-14.2%0.151ms0.134ms-10.9%
      issue detail + comments0.041ms0.038ms-5.8%0.049ms0.048ms-2.4%
      10,000 rows/collection | source indexes: none | optimistic writes — geomean 1.01×
      QueryBase medianPR medianΔ medianBase p95PR p95Δ p95
      list: newest 50 open0.037ms0.035ms-5.2%0.054ms0.053ms-3.0%
      list + author0.050ms0.049ms-1.8%0.095ms0.097ms+1.7%
      list + comment count0.109ms0.108ms-0.8%0.151ms0.190ms+25.8%
      list + 3 recent comments0.056ms0.060ms+7.0%0.071ms0.074ms+3.7%
      issue detail + comments0.041ms0.044ms+7.4%0.098ms0.098ms-0.5%
      10,000 rows/collection | source indexes: manual | synced writes — geomean 1.24×, 1 change(s)
      QueryBase medianPR medianΔ medianBase p95PR p95Δ p95
      list: newest 50 open0.025ms0.028ms+14.8%0.047ms0.044ms-6.9%
      list + author0.037ms0.038ms+0.7%0.090ms0.090ms-0.1%
      list + comment count0.115ms0.123ms+7.0%0.223ms0.246ms+10.7%
      list + 3 recent comments0.064ms0.155ms+142.0%0.119ms0.209ms+74.9%🔴
      issue detail + comments0.047ms0.045ms-3.6%0.093ms0.062ms-32.9%
      10,000 rows/collection | source indexes: manual | optimistic writes — geomean 0.81×, 1 change(s)
      QueryBase medianPR medianΔ medianBase p95PR p95Δ p95
      list: newest 50 open0.038ms0.034ms-10.8%0.095ms0.061ms-35.9%
      list + author0.050ms0.047ms-6.9%0.097ms0.087ms-10.8%
      list + comment count0.119ms0.114ms-3.9%0.161ms0.189ms+17.4%
      list + 3 recent comments0.140ms0.062ms-56.0%0.212ms0.140ms-33.8%🟢
      issue detail + comments0.051ms0.050ms-1.3%0.099ms0.097ms-2.5%
      Runner: node v24.8.0, linux 6.17.0-1022-azure, AMD EPYC 9V45 96-Core Processor. Timings on shared CI runners are noisy; treat small deltas as indicative only.
    2. pkg-pr-new[bot](GitHub profile, opens in a new tab)commented
      More templates

      @tanstack/angular-db

      npm i https://pkg.pr.new/@tanstack/angular-db@1650

      @tanstack/browser-db-sqlite-persistence

      npm i https://pkg.pr.new/@tanstack/browser-db-sqlite-persistence@1650

      @tanstack/capacitor-db-sqlite-persistence

      npm i https://pkg.pr.new/@tanstack/capacitor-db-sqlite-persistence@1650

      @tanstack/cloudflare-durable-objects-db-sqlite-persistence

      npm i https://pkg.pr.new/@tanstack/cloudflare-durable-objects-db-sqlite-persistence@1650

      @tanstack/db

      npm i https://pkg.pr.new/@tanstack/db@1650

      @tanstack/db-ivm

      npm i https://pkg.pr.new/@tanstack/db-ivm@1650

      @tanstack/db-sqlite-persistence-core

      npm i https://pkg.pr.new/@tanstack/db-sqlite-persistence-core@1650

      @tanstack/electric-db-collection

      npm i https://pkg.pr.new/@tanstack/electric-db-collection@1650

      @tanstack/electron-db-sqlite-persistence

      npm i https://pkg.pr.new/@tanstack/electron-db-sqlite-persistence@1650

      @tanstack/expo-db-sqlite-persistence

      npm i https://pkg.pr.new/@tanstack/expo-db-sqlite-persistence@1650

      @tanstack/node-db-sqlite-persistence

      npm i https://pkg.pr.new/@tanstack/node-db-sqlite-persistence@1650

      @tanstack/offline-transactions

      npm i https://pkg.pr.new/@tanstack/offline-transactions@1650

      @tanstack/powersync-db-collection

      npm i https://pkg.pr.new/@tanstack/powersync-db-collection@1650

      @tanstack/query-db-collection

      npm i https://pkg.pr.new/@tanstack/query-db-collection@1650

      @tanstack/react-db

      npm i https://pkg.pr.new/@tanstack/react-db@1650

      @tanstack/react-native-db-sqlite-persistence

      npm i https://pkg.pr.new/@tanstack/react-native-db-sqlite-persistence@1650

      @tanstack/react-router-with-db

      npm i https://pkg.pr.new/@tanstack/react-router-with-db@1650

      @tanstack/rxdb-db-collection

      npm i https://pkg.pr.new/@tanstack/rxdb-db-collection@1650

      @tanstack/solid-db

      npm i https://pkg.pr.new/@tanstack/solid-db@1650

      @tanstack/svelte-db

      npm i https://pkg.pr.new/@tanstack/svelte-db@1650

      @tanstack/tauri-db-sqlite-persistence

      npm i https://pkg.pr.new/@tanstack/tauri-db-sqlite-persistence@1650

      @tanstack/trailbase-db-collection

      npm i https://pkg.pr.new/@tanstack/trailbase-db-collection@1650

      @tanstack/vue-db

      npm i https://pkg.pr.new/@tanstack/vue-db@1650

      commit: 926faa0

    3. github-actions[bot](GitHub profile, opens in a new tab)commented

      Size Change: 0 B

      Total Size: 125 kB

      ℹ️ View Unchanged
      FilenameSize
      packages/db/dist/esm/collection/change-events.js1.43 kB
      packages/db/dist/esm/collection/changes.js1.38 kB
      packages/db/dist/esm/collection/cleanup-queue.js810 B
      packages/db/dist/esm/collection/events.js434 B
      packages/db/dist/esm/collection/index.js3.62 kB
      packages/db/dist/esm/collection/indexes.js1.99 kB
      packages/db/dist/esm/collection/lifecycle.js1.69 kB
      packages/db/dist/esm/collection/mutations.js2.47 kB
      packages/db/dist/esm/collection/state.js5.4 kB
      packages/db/dist/esm/collection/subscription.js3.74 kB
      packages/db/dist/esm/collection/sync.js2.88 kB
      packages/db/dist/esm/collection/transaction-metadata.js144 B
      packages/db/dist/esm/deferred.js207 B
      packages/db/dist/esm/errors.js5.1 kB
      packages/db/dist/esm/event-emitter.js748 B
      packages/db/dist/esm/index.js3.1 kB
      packages/db/dist/esm/indexes/auto-index.js829 B
      packages/db/dist/esm/indexes/base-index.js767 B
      packages/db/dist/esm/indexes/basic-index.js2.06 kB
      packages/db/dist/esm/indexes/btree-index.js2.19 kB
      packages/db/dist/esm/indexes/index-registry.js820 B
      packages/db/dist/esm/indexes/reverse-index.js557 B
      packages/db/dist/esm/local-only.js916 B
      packages/db/dist/esm/local-storage.js2.12 kB
      packages/db/dist/esm/optimistic-action.js359 B
      packages/db/dist/esm/paced-mutations.js496 B
      packages/db/dist/esm/proxy.js3.75 kB
      packages/db/dist/esm/query/builder/functions.js1.47 kB
      packages/db/dist/esm/query/builder/index.js5.84 kB
      packages/db/dist/esm/query/builder/ref-proxy.js1.24 kB
      packages/db/dist/esm/query/compiler/evaluators.js1.89 kB
      packages/db/dist/esm/query/compiler/expressions.js430 B
      packages/db/dist/esm/query/compiler/group-by.js3.56 kB
      packages/db/dist/esm/query/compiler/index.js6.67 kB
      packages/db/dist/esm/query/compiler/joins.js2.5 kB
      packages/db/dist/esm/query/compiler/lazy-targets.js923 B
      packages/db/dist/esm/query/compiler/order-by.js1.74 kB
      packages/db/dist/esm/query/compiler/select.js1.53 kB
      packages/db/dist/esm/query/effect.js4.77 kB
      packages/db/dist/esm/query/expression-helpers.js1.43 kB
      packages/db/dist/esm/query/ir.js1.25 kB
      packages/db/dist/esm/query/live-query-collection.js360 B
      packages/db/dist/esm/query/live/collection-config-builder.js9.1 kB
      packages/db/dist/esm/query/live/collection-registry.js264 B
      packages/db/dist/esm/query/live/collection-subscriber.js1.93 kB
      packages/db/dist/esm/query/live/internal.js145 B
      packages/db/dist/esm/query/live/utils.js1.81 kB
      packages/db/dist/esm/query/optimizer.js2.92 kB
      packages/db/dist/esm/query/predicate-utils.js2.97 kB
      packages/db/dist/esm/query/query-once.js359 B
      packages/db/dist/esm/query/subset-dedupe.js960 B
      packages/db/dist/esm/scheduler.js1.3 kB
      packages/db/dist/esm/SortedMap.js1.3 kB
      packages/db/dist/esm/strategies/debounceStrategy.js247 B
      packages/db/dist/esm/strategies/queueStrategy.js428 B
      packages/db/dist/esm/strategies/throttleStrategy.js246 B
      packages/db/dist/esm/transactions.js3.04 kB
      packages/db/dist/esm/utils.js927 B
      packages/db/dist/esm/utils/array-utils.js273 B
      packages/db/dist/esm/utils/browser-polyfills.js304 B
      packages/db/dist/esm/utils/btree.js5.61 kB
      packages/db/dist/esm/utils/comparison.js1.11 kB
      packages/db/dist/esm/utils/cursor.js457 B
      packages/db/dist/esm/utils/index-optimization.js2.39 kB
      packages/db/dist/esm/utils/type-guards.js157 B
      packages/db/dist/esm/utils/uuid.js449 B
      packages/db/dist/esm/virtual-props.js360 B
      compressed-size-action::db-package-size
    4. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Review Change Stack

      📝 Walkthrough

      Walkthrough

      Adds a benchmark runner for incremental-update scenarios, a comparison script for base versus candidate reports, and a GitHub Actions workflow that runs both on pull requests and manual dispatches, publishes artifacts, and updates a PR comment.

      Changes

      Benchmark Suite

      Layer / File(s)Summary
      Benchmark runner: types, CLI args, and query cases
      scripts/bench/incremental-update.ts
      Defines fixture and result types, parses benchmark CLI options, and declares the live-query benchmark cases and write functions.
      Benchmark execution and fixture management
      scripts/bench/incremental-update.ts
      Runs each benchmark case, builds manual-sync collections and fixtures, applies source indexes, performs mutation scenarios, and finalizes write cleanup.
      Statistics and report formatting
      scripts/bench/incremental-update.ts
      Computes timing statistics, gathers runtime metadata, and formats the textual benchmark report output.
      Base/candidate comparison script
      scripts/bench/compare-incremental-update.ts
      Loads benchmark reports, matches runs by composite key, classifies regressions and improvements, computes aggregate ratios, renders Markdown output, and parses comparison CLI options.
      CI workflow wiring
      .github/workflows/benchmark.yml
      Adds the Benchmark workflow, runs the benchmark on PR head and base commits, publishes comparison artifacts, and updates a PR comment.

      Estimated code review effort: 4 (Complex) | ~60 minutes

      Sequence Diagram(s)

      sequenceDiagram
        participant GitHub as GitHub Actions
        participant Benchmark as benchmark.yml
        participant Runner as incremental-update.ts
        participant Compare as compare-incremental-update.ts
        participant PullRequest as PR comment
        GitHub->>Benchmark: trigger on PR or dispatch
        Benchmark->>Runner: generate candidate.json and base.json
        Benchmark->>Compare: generate comparison.md
        Benchmark->>PullRequest: post or update comment
      🚥 Pre-merge checks | ✅ 5
      ✅ Passed checks (5 passed)
      Check nameStatusExplanation
      Title check✅ PassedThe title clearly summarizes the new CI benchmark workflow comparing PRs against main.
      Description check✅ PassedIt describes the benchmark extraction, workflow, triggers, and validation, though it doesn't use the repo's exact template sections.
      Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
      Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes check✅ PassedCheck 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 `kevin/perf-benchmark-ci`

      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.
    5. github-actions[bot](GitHub profile, opens in a new tab)commented

      Size Change: 0 B

      Total Size: 4.26 kB

      ℹ️ View Unchanged
      FilenameSize
      packages/react-db/dist/esm/index.js249 B
      packages/react-db/dist/esm/useLiveInfiniteQuery.js1.32 kB
      packages/react-db/dist/esm/useLiveQuery.js1.37 kB
      packages/react-db/dist/esm/useLiveQueryEffect.js355 B
      packages/react-db/dist/esm/useLiveSuspenseQuery.js567 B
      packages/react-db/dist/esm/usePacedMutations.js401 B
      compressed-size-action::react-db-package-size
    6. Actionable comments posted: 2

      🧹 Nitpick comments (3)
      scripts/bench/compare-incremental-update.ts (2)

      97-108: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low value

      Key joining without escaping risks collisions.

      resultKey concatenates fields with | without any escaping or type prefixes. If any label/query string ever contains |, boundaries between fields shift and unrelated results could be matched incorrectly.

      As per coding guidelines, "When converting keys to strings, ensure no collisions by using proper encoding with type prefixes."

      🤖 Prompt for AI Agents
      Verify each finding against current code. Fix only still-valid issues, skip the
      rest with a brief reason, keep changes minimal, and validate.
      
      In `@scripts/bench/compare-incremental-update.ts` around lines 97 - 108, The
      resultKey helper is building a composite string key by joining raw RunResult
      fields with a plain delimiter, which can collide if any value contains that
      delimiter. Update resultKey to use a collision-safe encoding with explicit type
      prefixes or escaped/serialized fields so each RunResult property remains
      unambiguous, and keep the matching logic in compare-incremental-update.ts
      aligned with the new key format.

      Source: Coding guidelines


      159-179: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

      isRegression/isImprovement are near-duplicate logic.

      Both functions share the same significance check and only differ in ratio direction; could be collapsed into a single classify helper returning 'regression' | 'improvement' | 'none' to avoid recomputing isSignificant twice per comparison in formatMarkdown.

      🤖 Prompt for AI Agents
      Verify each finding against current code. Fix only still-valid issues, skip the
      rest with a brief reason, keep changes minimal, and validate.
      
      In `@scripts/bench/compare-incremental-update.ts` around lines 159 - 179, The
      isRegression and isImprovement helpers duplicate the same significance logic and
      cause isSignificant to be evaluated twice for each Comparison in formatMarkdown.
      Refactor the comparison classification in compare-incremental-update.ts into a
      single helper (for example, a classify-style function) that checks significance
      once and returns regression, improvement, or none based on medianRatio
      direction, then update formatMarkdown to use that shared result instead of
      calling both helpers separately.
      .github/workflows/benchmark.yml (1)

      22-28: 🩺 Stability & Availability | 🔵 Trivial | 💤 Low value

      Consider a job-level timeout.

      No timeout-minutes is set; a hung pnpm install/build/benchmark could occupy the runner up to GitHub's default (6h) before failing.

      🤖 Prompt for AI Agents
      Verify each finding against current code. Fix only still-valid issues, skip the
      rest with a brief reason, keep changes minimal, and validate.
      
      In @.github/workflows/benchmark.yml around lines 22 - 28, The benchmark job
      currently has no execution limit, so a hung install/build/benchmark can hold a
      runner until GitHub’s default timeout. Add a job-level timeout setting to the
      benchmark job in the workflow definition alongside the existing if/runs-on
      fields, using the benchmark job identifier to keep the limit explicit and
      prevent runaway runs.
      🤖 Prompt for all review comments with AI agents
      Verify each finding against current code. Fix only still-valid issues, skip the
      rest with a brief reason, keep changes minimal, and validate.
      
      Inline comments:
      In `@scripts/bench/compare-incremental-update.ts`:
      - Around line 15-52: The local type copies in compare-incremental-update.ts are
      drifting from the shared incremental-update.ts contract, and
      sourceIndexMode/mutationMode have been widened to string. Replace the duplicated
      Summary, FixtureScale, RunResult, and Report definitions by importing the shared
      types from incremental-update.ts, or export them there if needed, so
      compare-incremental-update stays aligned with the canonical SourceIndexMode and
      MutationMode unions and preserves type safety.
      - Around line 204-296: The footer in formatMarkdown is incorrectly reading
      runtime data from the outer candidate closure instead of the candidateReport
      parameter, which breaks the function’s explicit data flow. Update the Runner
      line to use candidateReport.metadata for node, platform, and cpu so
      formatMarkdown depends only on its arguments and remains testable/reusable. Keep
      the rest of the function consistent with the existing use of baseReport and
      candidateReport.
      
      ---
      
      Nitpick comments:
      In @.github/workflows/benchmark.yml:
      - Around line 22-28: The benchmark job currently has no execution limit, so a
      hung install/build/benchmark can hold a runner until GitHub’s default timeout.
      Add a job-level timeout setting to the benchmark job in the workflow definition
      alongside the existing if/runs-on fields, using the benchmark job identifier to
      keep the limit explicit and prevent runaway runs.
      
      In `@scripts/bench/compare-incremental-update.ts`:
      - Around line 97-108: The resultKey helper is building a composite string key by
      joining raw RunResult fields with a plain delimiter, which can collide if any
      value contains that delimiter. Update resultKey to use a collision-safe encoding
      with explicit type prefixes or escaped/serialized fields so each RunResult
      property remains unambiguous, and keep the matching logic in
      compare-incremental-update.ts aligned with the new key format.
      - Around line 159-179: The isRegression and isImprovement helpers duplicate the
      same significance logic and cause isSignificant to be evaluated twice for each
      Comparison in formatMarkdown. Refactor the comparison classification in
      compare-incremental-update.ts into a single helper (for example, a
      classify-style function) that checks significance once and returns regression,
      improvement, or none based on medianRatio direction, then update formatMarkdown
      to use that shared result instead of calling both helpers separately.
      🪄 Autofix (Beta)

      Fix all unresolved CodeRabbit comments on this PR:

      • Push a commit to this branch (recommended)
      • Create a new PR with the fixes

      ℹ️ Review info
      ⚙️ Run configuration

      Configuration used: defaults

      Review profile: CHILL

      Plan: Pro

      Run ID: db0f6f77-810d-4a17-a5e2-33d8c19ebc76

      📥 Commits

      Reviewing files that changed from the base of the PR and between 3ec3e7ae1b2fa5ab9fee3ebaebb6d97c9487d29b and 4c1de9506159ebd2bb8df2e20781cbe48bd67e82.

      📒 Files selected for processing (3)
      • .github/workflows/benchmark.yml
      • scripts/bench/compare-incremental-update.ts
      • scripts/bench/incremental-update.ts
      @@ -0,0 +32,21 @@
      32+type RunResult = {
      33+ query: string
      34+ scenario: string
      35+ scale: FixtureScale
      36+ sourceIndexMode: string
      37+ mutationMode: string
      38+ coldHydrateMs: number
      39+ writeSummary: Summary
      40+}
      41+
      42+type Report = {
      43+ metadata: {
      44+ node: string
      45+ platform: string
      46+ cpu: string
      47+ gitSha: string
      48+ iterations: number
      49+ warmup: number
      50+ }
      51+ results: Array<RunResult>
      52+}
      coderabbitai[bot](GitHub profile, opens in a new tab)commented

      📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

      Duplicated types drift from the upstream contract.

      Summary, FixtureScale, and RunResult are copy-pasted from scripts/bench/incremental-update.ts. Worse, sourceIndexMode/mutationMode are widened here to string instead of the SourceIndexMode/MutationMode literal unions used upstream (per the shared contract in incremental-update.ts:85-121), so this file loses type safety and both copies can silently diverge as the runner evolves.

      Consider exporting the shared types from incremental-update.ts and importing them here.

      As per coding guidelines, "Extract common logic into utility functions when identical or near-identical code blocks appear in multiple places."

      🤖 Prompt for AI Agents
      Verify each finding against current code. Fix only still-valid issues, skip the
      rest with a brief reason, keep changes minimal, and validate.
      
      In `@scripts/bench/compare-incremental-update.ts` around lines 15 - 52, The local
      type copies in compare-incremental-update.ts are drifting from the shared
      incremental-update.ts contract, and sourceIndexMode/mutationMode have been
      widened to string. Replace the duplicated Summary, FixtureScale, RunResult, and
      Report definitions by importing the shared types from incremental-update.ts, or
      export them there if needed, so compare-incremental-update stays aligned with
      the canonical SourceIndexMode and MutationMode unions and preserves type safety.

      Source: Coding guidelines

      @@ -0,0 +276,21 @@
      276+ comparison.medianRatio,
      277+ )} | ${formatMs(comparison.base.writeSummary.p95Ms)} | ${formatMs(
      278+ comparison.candidate.writeSummary.p95Ms,
      279+ )} | ${formatDelta(comparison.p95Ratio)} | ${marker(
      280+ comparison,
      281+ threshold,
      282+ )} |`,
      283+ )
      284+ }
      285+ lines.push(``)
      286+ lines.push(`</details>`)
      287+ lines.push(``)
      288+ }
      289+
      290+ lines.push(
      291+ `<sub>Runner: node ${candidate.metadata.node}, ${candidate.metadata.platform}, ${candidate.metadata.cpu}. ` +
      292+ `Timings on shared CI runners are noisy; treat small deltas as indicative only.</sub>`,
      293+ )
      294+
      295+ return lines.join(`\n`)
      296+}
      coderabbitai[bot](GitHub profile, opens in a new tab)commented

      📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

      Uses closure variable candidate instead of the candidateReport parameter.

      Lines 290-293 reference the top-level candidate variable rather than the candidateReport parameter that the rest of the function correctly uses (e.g. lines 221-224). It happens to work today because they point to the same object, but it breaks the function's parameter contract and hurts testability if this function is ever reused/tested independently.

      As per coding guidelines, "Prefer explicit function parameters over closures to improve testability and clarify data flow dependencies."

      ♻️ Proposed fix
         lines.push(
      -    `<sub>Runner: node ${candidate.metadata.node}, ${candidate.metadata.platform}, ${candidate.metadata.cpu}. ` +
      +    `<sub>Runner: node ${candidateReport.metadata.node}, ${candidateReport.metadata.platform}, ${candidateReport.metadata.cpu}. ` +
             `Timings on shared CI runners are noisy; treat small deltas as indicative only.</sub>`,
         )
      📝 Committable suggestion

      ‼️ IMPORTANT Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

      Suggested change
      204+ lines.push(
      205+ `<sub>Runner: node ${candidateReport.metadata.node}, ${candidateReport.metadata.platform}, ${candidateReport.metadata.cpu}. ` +
      206+ `Timings on shared CI runners are noisy; treat small deltas as indicative only.</sub>`,
      207+ )
      🤖 Prompt for AI Agents
      Verify each finding against current code. Fix only still-valid issues, skip the
      rest with a brief reason, keep changes minimal, and validate.
      
      In `@scripts/bench/compare-incremental-update.ts` around lines 204 - 296, The
      footer in formatMarkdown is incorrectly reading runtime data from the outer
      candidate closure instead of the candidateReport parameter, which breaks the
      function’s explicit data flow. Update the Runner line to use
      candidateReport.metadata for node, platform, and cpu so formatMarkdown depends
      only on its arguments and remains testable/reusable. Keep the rest of the
      function consistent with the existing use of baseReport and candidateReport.

      Source: Coding guidelines

    7. ⚠️ No Changeset found

      Latest commit: 926faa0c1a882a9d0a23be6a29cc073037ac19dc

      Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

      This PR includes no changesets

      When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

      Click here to learn what changesets are, and how to add one.

      Click here if you're a maintainer who wants to add a changeset to this PR

    8. I merged main into this branch (a normal merge, no conflicts). The benchmark and compare scripts run unchanged on today's main. A smoke run of the full matrix passes, and a same-code comparison reports 1.00×.

      Against your July baseline, the suite shows main is now slower in three places:

      • Ordered + limit, add/remove pair: about 12× slower. This started with #1896.
      • Cold hydrate of a join with no index, 10k rows: about 22× slower. This started with #1740.
      • Steady-state writes: about 1.5× slower by geomean. This started with #1797, then drifted further.

      Fixes for these will follow as separate PRs. This workflow will show their before-and-after numbers.

      This pull request comment was written by Isaac.

    9. Size Change: 0 B

      Total Size: 190 kB

      ℹ️ View Unchanged
      FilenameSize
      packages/db/dist/esm/client.js3.61 kB
      packages/db/dist/esm/collection-options.js236 B
      packages/db/dist/esm/collection/change-events.js1.64 kB
      packages/db/dist/esm/collection/changes.js2.38 kB
      packages/db/dist/esm/collection/cleanup-queue.js808 B
      packages/db/dist/esm/collection/config-errors.js547 B
      packages/db/dist/esm/collection/events.js481 B
      packages/db/dist/esm/collection/index.js4.66 kB
      packages/db/dist/esm/collection/indexes.js2.06 kB
      packages/db/dist/esm/collection/lifecycle.js2.82 kB
      packages/db/dist/esm/collection/mutations.js2.96 kB
      packages/db/dist/esm/collection/state.js6.9 kB
      packages/db/dist/esm/collection/subscription.js8.44 kB
      packages/db/dist/esm/collection/sync.js5.2 kB
      packages/db/dist/esm/collection/validate-config.js1.11 kB
      packages/db/dist/esm/deferred.js207 B
      packages/db/dist/esm/errors.js5.67 kB
      packages/db/dist/esm/event-emitter.js961 B
      packages/db/dist/esm/index.js4.08 kB
      packages/db/dist/esm/indexes/auto-index.js841 B
      packages/db/dist/esm/indexes/base-index.js1.25 kB
      packages/db/dist/esm/indexes/basic-index.js2.01 kB
      packages/db/dist/esm/indexes/btree-index.js2.3 kB
      packages/db/dist/esm/indexes/index-registry.js820 B
      packages/db/dist/esm/indexes/reverse-index.js370 B
      packages/db/dist/esm/live-query-adapter.js338 B
      packages/db/dist/esm/live-query-observer.js4.6 kB
      packages/db/dist/esm/live-query-options.js1.06 kB
      packages/db/dist/esm/live-query-window-controller.js4.13 kB
      packages/db/dist/esm/local-only.js1.08 kB
      packages/db/dist/esm/local-storage.js2.18 kB
      packages/db/dist/esm/optimistic-action.js359 B
      packages/db/dist/esm/paced-mutations.js702 B
      packages/db/dist/esm/persisted-readiness.js195 B
      packages/db/dist/esm/proxy.js3.17 kB
      packages/db/dist/esm/query/builder/clone-query.js766 B
      packages/db/dist/esm/query/builder/functions.js1.45 kB
      packages/db/dist/esm/query/builder/index.js6.75 kB
      packages/db/dist/esm/query/builder/query-ir.js116 B
      packages/db/dist/esm/query/builder/ref-proxy-identity.js292 B
      packages/db/dist/esm/query/builder/ref-proxy.js1.48 kB
      packages/db/dist/esm/query/builder/wrapper-identity.js221 B
      packages/db/dist/esm/query/compiler/evaluators.js2.1 kB
      packages/db/dist/esm/query/compiler/expressions.js604 B
      packages/db/dist/esm/query/compiler/group-by.js4.2 kB
      packages/db/dist/esm/query/compiler/index.js9.39 kB
      packages/db/dist/esm/query/compiler/joins.js3.2 kB
      packages/db/dist/esm/query/compiler/lazy-targets.js1.14 kB
      packages/db/dist/esm/query/compiler/order-by.js2 kB
      packages/db/dist/esm/query/compiler/parent-routes.js319 B
      packages/db/dist/esm/query/compiler/query-equivalence.js448 B
      packages/db/dist/esm/query/compiler/route-metadata.js1.24 kB
      packages/db/dist/esm/query/compiler/select.js1.59 kB
      packages/db/dist/esm/query/effect.js4.86 kB
      packages/db/dist/esm/query/equality-conjunct.js486 B
      packages/db/dist/esm/query/equality-value-identity.js591 B
      packages/db/dist/esm/query/expression-helpers.js1.45 kB
      packages/db/dist/esm/query/ir-stable-identity.js4.2 kB
      packages/db/dist/esm/query/ir.js1.7 kB
      packages/db/dist/esm/query/join-conditions.js257 B
      packages/db/dist/esm/query/live-query-collection.js391 B
      packages/db/dist/esm/query/live/bucket-facade-adapter.js2.67 kB
      packages/db/dist/esm/query/live/collection-config-builder.js6.47 kB
      packages/db/dist/esm/query/live/collection-registry.js264 B
      packages/db/dist/esm/query/live/collection-subscriber.js2.05 kB
      packages/db/dist/esm/query/live/graph-scheduler.js305 B
      packages/db/dist/esm/query/live/internal.js145 B
      packages/db/dist/esm/query/live/materialized-pipeline.js2.32 kB
      packages/db/dist/esm/query/live/ordered-source-loader.js4.14 kB
      packages/db/dist/esm/query/live/subset-demand-controller.js1.65 kB
      packages/db/dist/esm/query/live/utils.js1.2 kB
      packages/db/dist/esm/query/optimizer.js2.91 kB
      packages/db/dist/esm/query/pooled-live-query.js4.06 kB
      packages/db/dist/esm/query/query-once.js359 B
      packages/db/dist/esm/query/runtime-reference-identity.js630 B
      packages/db/dist/esm/query/subset-dedupe.js493 B
      packages/db/dist/esm/scheduler.js1.13 kB
      packages/db/dist/esm/SortedMap.js1.6 kB
      packages/db/dist/esm/strategies/debounceStrategy.js331 B
      packages/db/dist/esm/strategies/queueStrategy.js488 B
      packages/db/dist/esm/strategies/throttleStrategy.js386 B
      packages/db/dist/esm/sync-persistence.js540 B
      packages/db/dist/esm/sync-receipt.js211 B
      packages/db/dist/esm/transactions.js3.89 kB
      packages/db/dist/esm/utils.js1.49 kB
      packages/db/dist/esm/utils/array-utils.js270 B
      packages/db/dist/esm/utils/browser-polyfills.js304 B
      packages/db/dist/esm/utils/btree.js3.02 kB
      packages/db/dist/esm/utils/callbacks.js174 B
      packages/db/dist/esm/utils/comparison.js1.59 kB
      packages/db/dist/esm/utils/cursor.js677 B
      packages/db/dist/esm/utils/error.js167 B
      packages/db/dist/esm/utils/get-or-create.js155 B
      packages/db/dist/esm/utils/index-optimization.js2.42 kB
      packages/db/dist/esm/utils/source-record.js140 B
      packages/db/dist/esm/utils/type-guards.js230 B
      packages/db/dist/esm/utils/uuid.js449 B
      packages/db/dist/esm/virtual-props.js413 B
      packages/react-db/dist/esm/DbProvider.js317 B
      packages/react-db/dist/esm/development.js190 B
      packages/react-db/dist/esm/HydrationBoundary.js263 B
      packages/react-db/dist/esm/index.js330 B
      packages/react-db/dist/esm/live-query-internals.js282 B
      packages/react-db/dist/esm/useLiveInfiniteQuery.js1.94 kB
      packages/react-db/dist/esm/useLiveQuery.js3.6 kB
      packages/react-db/dist/esm/useLiveQueryEffect.js355 B
      packages/react-db/dist/esm/useLiveSuspenseQuery.js1.33 kB
      packages/react-db/dist/esm/usePacedMutations.js401 B
      compressed-size-action::db-and-react-package-size
    10. KyleAMathews merged this65992aa

    11. KyleAMathews closed this

Sign in to join this conversation.