perf: index-based constraint key scheduler for O(k) lookups#4678
perf: index-based constraint key scheduler for O(k) lookups#4678
Conversation
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. Review highlights: This PR represents an excellent algorithmic optimization with strong attention to performance principles: Algorithmic improvement: The shift from O(n²) total overhead to O(k) lookups is a significant performance win. Instead of scanning all waiting tests on every completion, only tests waiting on the specific released keys are examined. Design approach: The bidirectional index (
Concurrency correctness: All access to the index is properly serialized under CLAUDE.md compliance: The code adheres to all applicable rules:
The implementation demonstrates the kind of measured, performance-conscious design that aligns well with TUnit's principles. |
Replace O(n) full queue drain with WaitingTestIndex that maps constraint keys to waiting tests. When keys are released, only tests waiting on those specific keys are examined. This reduces per-completion work from O(n) to O(k) where k is the number of released keys, eliminating O(n^2) total overhead for n constrained tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
64e412f to
2950180
Compare
Summary
Test plan
🤖 Generated with Claude Code