perf(useRegistry): optimize unregister operations with deferred reindexing#48
Merged
johnleider merged 4 commits intomasterfrom Nov 24, 2025
Conversation
…exing - Add deferred reindexing with indexDependentCount tracking to avoid O(n²) complexity - Add offboard() method for batch unregistration with single reindex - Optimize onboard() to batch cache invalidation and event emission - Use collection.values() iterator directly in reindex() to avoid array allocation Benchmark improvements: - unregister with explicit values: 104x faster (59ms → 0.57ms for 1000 items) - offboard with index values: 111x faster (deferred reindex) - offboard with explicit values: 93x faster
- Implement incremental reindexing from minDirtyIndex instead of full rebuild - Revert onboard to simple version for proper inheritance by extending composables - Full reindex only when called explicitly or starting from index 0
|
commit: |
There was a problem hiding this comment.
Pull request overview
This PR introduces significant performance optimizations to the useRegistry composable by implementing deferred reindexing with indexDependentCount tracking. The optimization reduces complexity from O(n²) to O(n) for batch unregistration operations by avoiding redundant reindexing after each deletion.
Key changes:
- Deferred reindexing system that only triggers when index-dependent values need updating
- New
offboard()batch method for removing multiple tickets with a single reindex operation - Partial reindexing optimization that only processes affected tickets from the dirty index onwards
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/0/src/composables/useRegistry/index.ts | Implements deferred reindexing with indexDependentCount tracking, adds offboard() batch unregistration method, and optimizes reindex() for partial updates |
| packages/0/src/composables/useRegistry/index.bench.ts | Adds comprehensive benchmarks for the new optimization, including separate tests for explicit values and index values in register/unregister/onboard/offboard operations |
c536dd7 to
1b5e3b7
Compare
d81e68c to
3ccc5f9
Compare
…r inheritance - useSelection: add onboard override to use custom register with enroll logic - useSelection: add offboard override to clean up selectedIds - useQueue: add offboard override to clear timeouts and handle resume
3ccc5f9 to
7483cf4
Compare
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.
Benchmark improvements: