perf(db): explore incremental update hot paths#1648
Draft
samwillis wants to merge 32 commits into
Draft
Conversation
applyMutations did a findIndex scan over the existing mutations array for every incoming mutation, making bulk operations quadratic: a single insert() of 50k rows spent most of its time in this scan. Merge through a globalKey-keyed Map instead, preserving insertion order and rebuilding the array in place to keep its identity for external holders. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Draft scope
This is the original exploratory branch from the incremental update benchmark investigation. It is intentionally broad and should be reviewed as a bundle of instrumentation, benchmark tooling, and candidate performance changes rather than as a narrow production fix.
The branch currently contains 32 commits over
mainacross 43 files.What it contains
Instrumentation and benchmark tooling
scripts/bench/incremental-update.tsfor reproducing the issue-style benchmark shapes and source-size experiments.INCREMENTAL_UPDATE_INSTRUMENTATION_PLAN.mdINCREMENTAL_UPDATE_FINDINGS.mdDB collection and sync hot paths
Transaction.applyMutationslinear rather than repeatedly shifting work from the front of an array.Query/live graph hot paths
Index/sorted map/hash/db-ivm changes
SortedMapupdates and duplicate lookup avoidance.Why
The benchmark shared during the investigation showed very slow steady-state incremental updates for query shapes that look like filtered lists plus joins/includes/counts. The main question was whether the time was in source collection update application, hashing, live query scheduling, or the db-ivm query graph.
This branch keeps the instrumentation used to answer that question and the candidate optimizations that were explored from those traces.
Review notes
Validation performed during the investigation
No fresh full CI run was performed immediately before opening this draft PR.