Skip to content

perf_hooks: add NODE_PERFORMANCE_GC_MINOR_MARK_SWEEP constant#63877

Open
szegedi wants to merge 1 commit into
nodejs:mainfrom
szegedi:feat/perf-hooks-gc-minor-mark-sweep
Open

perf_hooks: add NODE_PERFORMANCE_GC_MINOR_MARK_SWEEP constant#63877
szegedi wants to merge 1 commit into
nodejs:mainfrom
szegedi:feat/perf-hooks-gc-minor-mark-sweep

Conversation

@szegedi

@szegedi szegedi commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

V8's Minor Mark-Sweep collector (enabled with --minor-ms, the default young-generation collector since V8 12.x / Node 22) reports garbage collection performance entries with kind kGCTypeMinorMarkSweep (value 2). perf_hooks exposed constants for every other GC kind (major, minor, incremental, weakcb) but not this one, so consumers inspecting performanceEntry.detail.kind had no constant to compare against and saw an unmapped value.

With this PR I expose it as perf_hooks.constants.NODE_PERFORMANCE_GC_MINOR_MARK_SWEEP, mirroring the existing v8::GCType mappings, and document it alongside the other GC kinds.

V8's Minor Mark-Sweep collector (enabled with --minor-ms, the default
young-generation collector since V8 12.x / Node 22) reports garbage
collection performance entries with kind kGCTypeMinorMarkSweep (value 2).
perf_hooks exposed constants for every other GC kind (major, minor,
incremental, weakcb) but not this one, so consumers inspecting
performanceEntry.detail.kind had no constant to compare against and saw
an unmapped value.

Expose it as perf_hooks.constants.NODE_PERFORMANCE_GC_MINOR_MARK_SWEEP,
mirroring the existing v8::GCType mappings, and document it alongside the
other GC kinds.
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels Jun 12, 2026
@BridgeAR BridgeAR added the request-ci Add this label to start a Jenkins CI on a PR. label Jun 12, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 12, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

obs.observe({ entryTypes: ['gc'] });

globalThis.gc({ type: 'minor' });
// Keep the event loop alive to witness the GC async callback happen.

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.

Would you mind converting this to gcUntil from test/common/gc.js, reducing the flakiness on the gc timing?

This can be like:

let observed = fasel;
const obs = new PerformanceObserver(common.mustCallAtLeast((list) => {
   ...
   observed = true;
}));

gcUntil('minor gc event', () => observed, 10, { type: 'minor' });

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++. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants