-
-
Notifications
You must be signed in to change notification settings - Fork 669
chore: improve fast timers #4593
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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 improves the performance and reliability of fast timers by replacing the array-based timer management with a binary min-heap data structure and refactoring the timer processing logic.
- Replaces the linear array-based timer storage with an efficient binary min-heap for O(log n) insertion/removal operations
- Separates pending timers from active timers using dedicated data structures to improve processing efficiency
- Adds comprehensive test coverage for edge cases including concurrent timer operations, heap ordering, and timer lifecycle management
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
lib/util/timers.js | Implements TimerHeap class and refactors timer management logic from array-based to heap-based approach |
test/timers.js | Adds extensive test coverage for timer edge cases, heap operations, and concurrent timer scenarios |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4593 +/- ##
==========================================
+ Coverage 92.93% 92.96% +0.03%
==========================================
Files 106 106
Lines 33094 33270 +176
==========================================
+ Hits 30756 30931 +175
- Misses 2338 2339 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
const node = heap[i] | ||
|
||
while (i > 0) { | ||
const parentIndex = Math.floor((i - 1) / 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not bitwise operators?
This relates to...
Rationale
Changes
Features
Bug Fixes
Breaking Changes and Deprecations
Status