From d1c22b6ac4efbf767837905432d9c98829f9ec84 Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Thu, 18 Dec 2025 14:05:08 +0100 Subject: [PATCH 1/5] fixes --- JetStreamDriver.js | 10 +++++++++- cli.js | 4 ++++ utils/params.js | 2 ++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/JetStreamDriver.js b/JetStreamDriver.js index 80cd74ee..f8e84670 100644 --- a/JetStreamDriver.js +++ b/JetStreamDriver.js @@ -30,8 +30,13 @@ const measureTotalTimeAsSubtest = false; // Once we move to preloading all resou const defaultIterationCount = 120; const defaultWorstCaseCount = 4; -if (!JetStreamParams.prefetchResources && isInBrowser) +if (!JetStreamParams.prefetchResources && isInBrowser) { console.warn("Disabling resource prefetching! All compressed files must have been decompressed using `npm run decompress`"); +} + +if (JetStreamParams.forceGC && typeof globalThis.gc === "undefined") { + console.warn("Force-gc is set, but globalThis.gc() is not available."); +} if (!isInBrowser && JetStreamParams.prefetchResources) { // Use the wasm compiled zlib as a polyfill when decompression stream is @@ -982,6 +987,9 @@ class Benchmark { magicFrame.contentDocument.close(); else if (isD8) Realm.dispose(magicFrame); + + if (JetStreamParams.forceGC) + globalThis?.gc(); } async doLoadBlob(resource) { diff --git a/cli.js b/cli.js index e1ff625f..e79bc59e 100644 --- a/cli.js +++ b/cli.js @@ -81,6 +81,10 @@ const CLI_PARAMS = { help: "Custom code to run after each iteration.", param: "customPostIterationCode", }, + "force-gc": { + help: "Force garbage collection after each benchmark run, requires engine support.", + param: "forceGC", + }, }; const cliParams = new Map(); diff --git a/utils/params.js b/utils/params.js index 11923ca0..92a632e9 100644 --- a/utils/params.js +++ b/utils/params.js @@ -43,6 +43,7 @@ class Params { groupDetails = false RAMification = false; + forceGC = false; dumpJSONResults = false; dumpTestList = false; // Override iteration and worst-case counts per workload. @@ -70,6 +71,7 @@ class Params { this.dumpJSONResults = this._parseBooleanParam(sourceParams, "dumpJSONResults"); this.groupDetails = this._parseBooleanParam(sourceParams, "groupDetails"); this.dumpTestList = this._parseBooleanParam(sourceParams, "dumpTestList"); + this.forceGC = this._parseBooleanParam(sourceParams, "forceGC"); this.customPreIterationCode = this._parseStringParam(sourceParams, "customPreIterationCode"); this.customPostIterationCode = this._parseStringParam(sourceParams, "customPostIterationCode"); From a33e3e28e25daa320a7c86b2a4842d9050176450 Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Thu, 18 Dec 2025 14:06:45 +0100 Subject: [PATCH 2/5] cleanup --- JetStreamDriver.js | 7 ++++--- cli.js | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/JetStreamDriver.js b/JetStreamDriver.js index f8e84670..869cb3b7 100644 --- a/JetStreamDriver.js +++ b/JetStreamDriver.js @@ -918,6 +918,10 @@ class Benchmark { if (this.isDone) throw new Error(`Cannot run Benchmark ${this.name} twice`); this._state = BenchmarkState.PREPARE; + + if (JetStreamParams.forceGC) + globalThis?.gc(); + const scripts = isInBrowser ? new BrowserScripts(this.preloads) : new ShellScripts(this.preloads); if (!!this.plan.deterministicRandom) @@ -987,9 +991,6 @@ class Benchmark { magicFrame.contentDocument.close(); else if (isD8) Realm.dispose(magicFrame); - - if (JetStreamParams.forceGC) - globalThis?.gc(); } async doLoadBlob(resource) { diff --git a/cli.js b/cli.js index e79bc59e..945bb0a8 100644 --- a/cli.js +++ b/cli.js @@ -82,7 +82,7 @@ const CLI_PARAMS = { param: "customPostIterationCode", }, "force-gc": { - help: "Force garbage collection after each benchmark run, requires engine support.", + help: "Force garbage collection before each benchmark run, requires engine support.", param: "forceGC", }, }; From 9ee02896fec86e53ef7ff76ae9cf23c49030833f Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Thu, 18 Dec 2025 14:07:28 +0100 Subject: [PATCH 3/5] typo --- cli.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli.js b/cli.js index 945bb0a8..c5a51dfa 100644 --- a/cli.js +++ b/cli.js @@ -82,7 +82,7 @@ const CLI_PARAMS = { param: "customPostIterationCode", }, "force-gc": { - help: "Force garbage collection before each benchmark run, requires engine support.", + help: "Force garbage collection before each benchmark, requires engine support.", param: "forceGC", }, }; From 28c34fd8fca93c43ba1f1a44b8ed27040c6f59d5 Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Thu, 18 Dec 2025 18:43:47 +0100 Subject: [PATCH 4/5] add GroupedBenchmarks comment --- JetStreamDriver.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/JetStreamDriver.js b/JetStreamDriver.js index 869cb3b7..deaa26eb 100644 --- a/JetStreamDriver.js +++ b/JetStreamDriver.js @@ -919,8 +919,12 @@ class Benchmark { throw new Error(`Cannot run Benchmark ${this.name} twice`); this._state = BenchmarkState.PREPARE; - if (JetStreamParams.forceGC) + if (JetStreamParams.forceGC) { + // This will trigger for individual benchmarks in + // GroupedBenchmarks since they delegate .run() to their inner + // benchmarks. globalThis?.gc(); + } const scripts = isInBrowser ? new BrowserScripts(this.preloads) : new ShellScripts(this.preloads); From 97f9c2acdc52e1975a08f5025562d457630988a2 Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Thu, 18 Dec 2025 18:44:10 +0100 Subject: [PATCH 5/5] improve comment --- JetStreamDriver.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JetStreamDriver.js b/JetStreamDriver.js index deaa26eb..1d4c401d 100644 --- a/JetStreamDriver.js +++ b/JetStreamDriver.js @@ -922,7 +922,7 @@ class Benchmark { if (JetStreamParams.forceGC) { // This will trigger for individual benchmarks in // GroupedBenchmarks since they delegate .run() to their inner - // benchmarks. + // non-grouped benchmarks. globalThis?.gc(); }