Skip to content

perf(useRegistry): optimize unregister operations with deferred reindexing#48

Merged
johnleider merged 4 commits intomasterfrom
claude/review-useregistry-performance-01RzWaaJcdp92EhMUmL4YJYr
Nov 24, 2025
Merged

perf(useRegistry): optimize unregister operations with deferred reindexing#48
johnleider merged 4 commits intomasterfrom
claude/review-useregistry-performance-01RzWaaJcdp92EhMUmL4YJYr

Conversation

@johnleider
Copy link
Copy Markdown
Member

  • 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

…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
Copilot AI review requested due to automatic review settings November 21, 2025 18:30
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Nov 21, 2025

Open in StackBlitz

commit: 7483cf4

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@johnleider johnleider force-pushed the claude/review-useregistry-performance-01RzWaaJcdp92EhMUmL4YJYr branch 2 times, most recently from c536dd7 to 1b5e3b7 Compare November 21, 2025 21:14
@johnleider johnleider force-pushed the claude/review-useregistry-performance-01RzWaaJcdp92EhMUmL4YJYr branch 2 times, most recently from d81e68c to 3ccc5f9 Compare November 22, 2025 23:10
…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
@johnleider johnleider force-pushed the claude/review-useregistry-performance-01RzWaaJcdp92EhMUmL4YJYr branch from 3ccc5f9 to 7483cf4 Compare November 23, 2025 17:39
@johnleider johnleider merged commit 09e0b91 into master Nov 24, 2025
9 checks passed
@johnleider johnleider deleted the claude/review-useregistry-performance-01RzWaaJcdp92EhMUmL4YJYr branch November 24, 2025 15:32
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.

3 participants