Skip to content

perf_hooks: add binary export/import to Histogram - #65434

Open
jasnell wants to merge 4 commits into
nodejs:mainfrom
jasnell:jasnell/more-histogram-fun-2
Open

perf_hooks: add binary export/import to Histogram#65434
jasnell wants to merge 4 commits into
nodejs:mainfrom
jasnell:jasnell/more-histogram-fun-2

Conversation

@jasnell

@jasnell jasnell commented Aug 20, 2026

Copy link
Copy Markdown
Member

Stacks on: #65416

Pay attention only to the last two commits.

@jasnell
jasnell requested review from Qard and mcollina August 20, 2026 14:32
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/performance
  • @nodejs/tsc

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Aug 20, 2026
@jasnell
jasnell force-pushed the jasnell/more-histogram-fun-2 branch from 00936d8 to fbcb489 Compare August 20, 2026 15:51
@codecov

codecov Bot commented Aug 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.10526% with 94 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.13%. Comparing base (449b950) to head (dfaacaf).
⚠️ Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
src/histogram.cc 87.11% 12 Missing and 75 partials ⚠️
src/histogram-inl.h 86.36% 3 Missing and 3 partials ⚠️
lib/internal/histogram.js 99.55% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #65434      +/-   ##
==========================================
+ Coverage   90.11%   90.13%   +0.01%     
==========================================
  Files         752      752              
  Lines      252208   253239    +1031     
  Branches    47447    47627     +180     
==========================================
+ Hits       227274   228245     +971     
- Misses      16219    16230      +11     
- Partials     8715     8764      +49     
Files with missing lines Coverage Δ
lib/perf_hooks.js 100.00% <100.00%> (ø)
src/histogram.h 72.72% <100.00%> (+4.30%) ⬆️
lib/internal/histogram.js 96.11% <99.55%> (+1.34%) ⬆️
src/histogram-inl.h 85.13% <86.36%> (+3.82%) ⬆️
src/histogram.cc 84.47% <87.11%> (+2.80%) ⬆️

... and 45 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jasnell
jasnell force-pushed the jasnell/more-histogram-fun-2 branch from fbcb489 to 5d9f7ce Compare August 20, 2026 19:20
@jasnell
jasnell requested a review from legendecas August 20, 2026 20:30
Welch's t-test, Mann-Whitney U test, Cohen's d, and Cliff's delta,
and and handful of others

These methods enable in-process benchmark comparison and regression
detection without external dependencies.

No new dependencies.

Tests and docs created by the AI agent.

Signed-off-by: James M Snell <jasnell@gmail.com>
Assisted-by: Opencode/Opus
Add an --analyze flag that performs statistical analysis directly
after benchmarks complete, eliminating the need for R and compare.R.

When --analyze is specified, compare.js collects the rate data during
the run and prints a statistical summary table instead of CSV output.
The table matches the format of compare.R: improvement percentage,
significance stars (* p<0.05, ** p<0.01, *** p<0.001), and confidence
intervals at three risk levels.

Also adds a --max-regression N option that causes the compare.js to
exit with 1 (error) when the `--new` is N% slower. Useful for CI
use to detect regressions.

Uses the histogram API's welchTest() and cohensD() methods introduced
in the previous commit. Benchmark rates are scaled to integers for
HdrHistogram recording; the --scale option (default 1000) controls
the multiplier for precision.

Usage:
  node benchmark/compare.js --old ./node-old --new ./node-new \
    --analyze url

Signed-off-by: James M Snell <jasnell@gmail.com>
Assisted-by: Opencode/Opus
@jasnell
jasnell force-pushed the jasnell/more-histogram-fun-2 branch from 5d9f7ce to dfaacaf Compare August 20, 2026 20:36
@jasnell jasnell added notable-change PRs with changes that should be highlighted in changelogs. semver-minor PRs that contain new features and should be released in the next minor version. labels Aug 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

The notable-change PRs with changes that should be highlighted in changelogs. label has been added by @jasnell.

Please suggest a text for the release notes if you'd like to include a more detailed summary, then proceed to update the PR description with the text or a link to the notable change suggested text comment. Otherwise, the commit will be placed in the Other Notable Changes section.

@jasnell

jasnell commented Aug 20, 2026

Copy link
Copy Markdown
Member Author

Notes for the notable change:

This PR gives Histogram a new binary interchange format

@jasnell jasnell added the commit-queue-rebase Add this label to allow the Commit Queue to land a PR in several commits. label Aug 20, 2026
Comment thread src/histogram.cc
}

// -----------------------------------------------------------------------
// Minimal CBOR encoder/decoder (RFC 8949) -- just enough types for

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe we should get deps/inspector_protocol/crdtp/cbor.h into core...

Comment thread src/histogram.cc
Provide a binary export/import mechanism for histograms.

Since there is no standard interchange format for histograms,
using CBOR is meant to make the format as platform/runtime
agnostic as possible while producing a compact/efficient
result. No new dependency is introduced, we just encode
the CBOR directly.

Signed-off-by: James M Snell <jasnell@gmail.com>
Assisted-by: Opencode/Opus
Signed-off-by: James M Snell <jasnell@gmail.com>
@jasnell
jasnell force-pushed the jasnell/more-histogram-fun-2 branch from dfaacaf to 28eb138 Compare August 20, 2026 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. commit-queue-rebase Add this label to allow the Commit Queue to land a PR in several commits. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. notable-change PRs with changes that should be highlighted in changelogs. semver-minor PRs that contain new features and should be released in the next minor version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants