GeezerVison is showing github.com — perf_hooks: add NODE_PERFORMANCE_GC_MINOR_MARK_SWEEP constant · nodejs/node@f90f1bd
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: doc/api/perf_hooks.md +2Lines changed: 2 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -643,6 +643,7 @@ The value may be one of: | 643 | 643 |
| 644 | 644 | * `perf_hooks.constants.NODE_PERFORMANCE_GC_MAJOR` | 645 | 645 | * `perf_hooks.constants.NODE_PERFORMANCE_GC_MINOR` | | 646 | +* `perf_hooks.constants.NODE_PERFORMANCE_GC_MINOR_MARK_SWEEP` | 646 | 647 | * `perf_hooks.constants.NODE_PERFORMANCE_GC_INCREMENTAL` | 647 | 648 | * `perf_hooks.constants.NODE_PERFORMANCE_GC_WEAKCB` | 648 | 649 |
| @@ -654,6 +655,7 @@ When `performanceEntry.type` is equal to `'gc'`, the | 654 | 655 | * `kind` {number} One of: | 655 | 656 | * `perf_hooks.constants.NODE_PERFORMANCE_GC_MAJOR` | 656 | 657 | * `perf_hooks.constants.NODE_PERFORMANCE_GC_MINOR` | | 658 | + * `perf_hooks.constants.NODE_PERFORMANCE_GC_MINOR_MARK_SWEEP` | 657 | 659 | * `perf_hooks.constants.NODE_PERFORMANCE_GC_INCREMENTAL` | 658 | 660 | * `perf_hooks.constants.NODE_PERFORMANCE_GC_WEAKCB` | 659 | 661 | * `flags` {number} One of: | |
Collapse file Copy file name to clipboardExpand all lines: src/node_perf.cc +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -365,6 +365,7 @@ void CreatePerContextProperties(Local<Object> target, | 365 | 365 |
| 366 | 366 | NODE_DEFINE_CONSTANT(constants, NODE_PERFORMANCE_GC_MAJOR); | 367 | 367 | NODE_DEFINE_CONSTANT(constants, NODE_PERFORMANCE_GC_MINOR); | | 368 | + NODE_DEFINE_CONSTANT(constants, NODE_PERFORMANCE_GC_MINOR_MARK_SWEEP); | 368 | 369 | NODE_DEFINE_CONSTANT(constants, NODE_PERFORMANCE_GC_INCREMENTAL); | 369 | 370 | NODE_DEFINE_CONSTANT(constants, NODE_PERFORMANCE_GC_WEAKCB); | 370 | 371 |
| |
Collapse file Copy file name to clipboardExpand all lines: src/node_perf.h +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -63,6 +63,7 @@ inline PerformanceEntryType ToPerformanceEntryTypeEnum( | 63 | 63 | enum PerformanceGCKind { | 64 | 64 | NODE_PERFORMANCE_GC_MAJOR = v8::GCType::kGCTypeMarkSweepCompact, | 65 | 65 | NODE_PERFORMANCE_GC_MINOR = v8::GCType::kGCTypeScavenge, | | 66 | + NODE_PERFORMANCE_GC_MINOR_MARK_SWEEP = v8::GCType::kGCTypeMinorMarkSweep, | 66 | 67 | NODE_PERFORMANCE_GC_INCREMENTAL = v8::GCType::kGCTypeIncrementalMarking, | 67 | 68 | NODE_PERFORMANCE_GC_WEAKCB = v8::GCType::kGCTypeProcessWeakCallbacks | 68 | 69 | }; | |
Collapse file Copy file name to clipboard +36Lines changed: 36 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +// Flags: --expose-gc --no-warnings --minor-ms | | 2 | +'use strict'; | | 3 | + | | 4 | +// When V8's Minor Mark-Sweep collector is enabled (--minor-ms), minor garbage | | 5 | +// collections are reported with kind NODE_PERFORMANCE_GC_MINOR_MARK_SWEEP | | 6 | +// rather than NODE_PERFORMANCE_GC_MINOR. | | 7 | + | | 8 | +const common = require('../common'); | | 9 | +const assert = require('assert'); | | 10 | +const { gcUntil } = require('../common/gc'); | | 11 | +const { | | 12 | + PerformanceObserver, | | 13 | + constants | | 14 | +} = require('perf_hooks'); | | 15 | + | | 16 | +const { | | 17 | + NODE_PERFORMANCE_GC_MINOR_MARK_SWEEP | | 18 | +} = constants; | | 19 | + | | 20 | +let observed = false; | | 21 | +const obs = new PerformanceObserver(common.mustCallAtLeast((list) => { | | 22 | + for (const entry of list.getEntries()) { | | 23 | + // Other GC kinds (e.g. a scheduled or incremental GC) may be observed in | | 24 | + // between; only the minor mark-sweep entry is relevant here. | | 25 | + if (entry.detail.kind === NODE_PERFORMANCE_GC_MINOR_MARK_SWEEP) { | | 26 | + assert.strictEqual(entry.name, 'gc'); | | 27 | + assert.strictEqual(entry.entryType, 'gc'); | | 28 | + observed = true; | | 29 | + obs.disconnect(); | | 30 | + return; | | 31 | + } | | 32 | + } | | 33 | +})); | | 34 | +obs.observe({ entryTypes: ['gc'] }); | | 35 | + | | 36 | +gcUntil('minor gc event', () => observed, 10, { type: 'minor' }); |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-performance-gc.js +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -11,6 +11,7 @@ const { | 11 | 11 | const { | 12 | 12 | NODE_PERFORMANCE_GC_MAJOR, | 13 | 13 | NODE_PERFORMANCE_GC_MINOR, | | 14 | + NODE_PERFORMANCE_GC_MINOR_MARK_SWEEP, | 14 | 15 | NODE_PERFORMANCE_GC_INCREMENTAL, | 15 | 16 | NODE_PERFORMANCE_GC_WEAKCB, | 16 | 17 | NODE_PERFORMANCE_GC_FLAGS_FORCED | @@ -19,6 +20,7 @@ const { | 19 | 20 | const kinds = [ | 20 | 21 | NODE_PERFORMANCE_GC_MAJOR, | 21 | 22 | NODE_PERFORMANCE_GC_MINOR, | | 23 | + NODE_PERFORMANCE_GC_MINOR_MARK_SWEEP, | 22 | 24 | NODE_PERFORMANCE_GC_INCREMENTAL, | 23 | 25 | NODE_PERFORMANCE_GC_WEAKCB, | 24 | 26 | ]; | |
|