Commit d7ea02dd5dc for nodejs

commit d7ea02dd5dc6dd7eda3997bc986e4c55ec0b610a
Author: Joyee Cheung <joyeec9h3@gmail.com>
Date:   Wed Sep 30 19:49:14 2026 +0200

    test: make histogram external memory test less overfitting

    The test assumes too much about V8 GC's internal mechanisms and
    thresholds that is no longer true on newer V8 versions and break
    future V8 updates. Update it to only detect the occurence of
    major GC to make it more future-proof and unblock V8 updates.

    Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
    PR-URL: https://github.com/nodejs/node/pull/66416
    Refs: https://github.com/nodejs/node/pull/65161
    Reviewed-By: James M Snell <jasnell@gmail.com>
    Reviewed-By: Filip Skokan <panva.ip@gmail.com>
    Reviewed-By: Richard Lau <richard.lau@ibm.com>

diff --git a/test/parallel/test-perf-hooks-histogram-external-memory.js b/test/parallel/test-perf-hooks-histogram-external-memory.js
index 0cca4a7a803..7e98bd206ec 100644
--- a/test/parallel/test-perf-hooks-histogram-external-memory.js
+++ b/test/parallel/test-perf-hooks-histogram-external-memory.js
@@ -9,30 +9,30 @@ const assert = require('assert');
 const { setImmediate: setImmediatePromise } = require('timers/promises');
 const {
   PerformanceObserver,
-  constants: { NODE_PERFORMANCE_GC_FLAGS_ALL_EXTERNAL_MEMORY },
+  constants: { NODE_PERFORMANCE_GC_MAJOR },
   createHistogram,
 } = require('perf_hooks');

-let externalMemoryGCs = 0;
+let majorGCs = 0;
 const observer = new PerformanceObserver((list) => {
   for (const entry of list.getEntries()) {
-    if (entry.detail.flags & NODE_PERFORMANCE_GC_FLAGS_ALL_EXTERNAL_MEMORY)
-      externalMemoryGCs++;
+    if (entry.detail.kind === NODE_PERFORMANCE_GC_MAJOR) majorGCs++;
   }
 });
 observer.observe({ entryTypes: ['gc'] });

 // With the default options, a histogram holds 45,056 64-bit counts, about
-// 352 KiB. V8 starts a garbage collection once external memory has grown by
-// 64 MiB, so 400 unreferenced snapshots (about 137 MiB) must trigger one.
+// 352 KiB, while its JavaScript wrapper is small. It should only
+// triggers a major GC if that memory is reported. The GC trigger and finalization
+// can vary depending on V8 internals, so only check the occurrence of a major GC here.
 const histogram = createHistogram();
 for (let i = 0; i < 400; i++) histogram.snapshot();

 (async () => {
   // Performance entries for garbage collections are delivered asynchronously.
-  for (let i = 0; i < 10 && externalMemoryGCs === 0; i++)
+  for (let i = 0; i < 10 && majorGCs === 0; i++)
     await setImmediatePromise();
   observer.disconnect();
-  assert.ok(externalMemoryGCs > 0,
-            'Expected a garbage collection caused by external memory');
+  assert.ok(majorGCs > 0,
+            'Expected a major garbage collection caused by histogram memory');
 })().then(common.mustCall());