perf_hooks: implement SlidingWindowHistogram - #65825
Open
jasnell wants to merge 2 commits into
Open
Conversation
Collaborator
|
Review requested:
|
jasnell
marked this pull request as draft
September 5, 2026 16:57
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #65825 +/- ##
========================================
Coverage 89.98% 89.99%
========================================
Files 785 785
Lines 269282 269584 +302
Branches 51296 51370 +74
========================================
+ Hits 242323 242619 +296
+ Misses 17464 17430 -34
- Partials 9495 9535 +40
🚀 New features to boost your workflow:
|
The current recordable `Histogram` does not maintain any sense of time. Samples accumulate indefinitely as they are collected. This implements a relatively simple sliding-window mechanism that can be count or time based. The key benefit is that the window remains fixed/bounded while samples are recorded. The sliding window is chunk based. Internally, it maintains a ring buffer of a fixed number of individual histograms. When snapshot() is called, those are materialized into a single combined histogram. As the window slides, older chunks (and all of the samples they hold) are dropped from the window so the window drops however many samples happened to be in that chunk. This does mean that precision of the window is determined by the chunk size. Signed-off-by: James M Snell <jasnell@gmail.com> Assisted-by: Opencode
Signed-off-by: James M Snell <jasnell@gmail.com> Assisted-by: Opencode
jasnell
force-pushed
the
jasnell/perf-hooks-slidingwindowhistogram
branch
from
September 12, 2026 23:13
3d03781 to
e496081
Compare
jasnell
marked this pull request as ready for review
September 12, 2026 23:13
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.
Builds on #65806 ... this will remain draft until that lands. The first commit here is from 65806.
Implements
SlidingWindowHistogramAllows for count or time based windows. No timers are used. Validation and allocation are lazy. Uses a ring buffer internally to keep things bounded.
This completes the migration of my typical "performance analysis toolkit" that I've used for some time into built-in primitives.
Example of all this in use: https://github.com/jasnell/fastify-sliding-health