From dfc877615b1b32ad69f92a8d6bf1a0ab1afa9609 Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Tue, 26 Aug 2025 11:40:14 +0200 Subject: [PATCH 1/4] update workloads --- JetStreamDriver.js | 15 +++++++++++++++ tests/unit-tests.js | 40 ++++++++++++++++++++++++++++++++++++++++ worker/async-task.js | 2 +- worker/segmentation.js | 2 +- 4 files changed, 57 insertions(+), 2 deletions(-) diff --git a/JetStreamDriver.js b/JetStreamDriver.js index f979c43c..4d16bfec 100644 --- a/JetStreamDriver.js +++ b/JetStreamDriver.js @@ -711,6 +711,7 @@ class Benchmark { this.tags = this.processTags(plan.tags) this.iterations = getIterationCount(plan); this.isAsync = !!plan.isAsync; + this.allowUtf16 = !!plan.allowUtf16; this.scripts = null; this.preloads = null; this.results = []; @@ -1663,6 +1664,7 @@ let BENCHMARKS = [ babylonBlob: "./ARES-6/Babylon/babylon-blob.js", }, tags: ["Default", "ARES"], + allowUtf16: true, }), // CDJS new DefaultBenchmark({ @@ -1958,6 +1960,7 @@ let BENCHMARKS = [ iterations: 4, worstCaseCount: 1, deterministicRandom: true, + allowUtf16: true, tags: ["BigIntNoble"], }), new AsyncBenchmark({ @@ -1968,6 +1971,7 @@ let BENCHMARKS = [ "./bigint/noble-benchmark.js", ], deterministicRandom: true, + allowUtf16: true, tags: ["BigIntNoble"], }), new AsyncBenchmark({ @@ -1979,6 +1983,7 @@ let BENCHMARKS = [ ], iterations: 30, deterministicRandom: true, + allowUtf16: true, tags: ["Default", "BigIntNoble"], }), new DefaultBenchmark({ @@ -2229,6 +2234,7 @@ let BENCHMARKS = [ async: true, deterministicRandom: true, exposeBrowserTest: true, + allowUtf16: true, tags: ["Wasm"], }), new WasmLegacyBenchmark({ @@ -2250,6 +2256,7 @@ let BENCHMARKS = [ async: true, deterministicRandom: true, exposeBrowserTest: true, + allowUtf16: true, tags: ["Wasm"], }), new WasmEMCCBenchmark({ @@ -2264,6 +2271,7 @@ let BENCHMARKS = [ iterations: 30, worstCaseCount: 3, deterministicRandom: true, + allowUtf16: true, tags: ["Default", "Wasm"], }), // WorkerTests @@ -2302,6 +2310,8 @@ let BENCHMARKS = [ stringUnpackCode: "./worker/bomb-subtests/string-unpack-code.js", regexpDNA: "./worker/bomb-subtests/regexp-dna.js", }, + // FIXME: Potentially fix the sources. + allowUtf16: true, tags: ["Default", "WorkerTests"], }), new AsyncBenchmark({ @@ -2548,11 +2558,15 @@ for (const test of SUNSPIDER_TESTS) { files: [ `./SunSpider/${test}.js` ], + // FIXME: Potentially fix the sources. + allowUtf16: true, tags: [], })); } BENCHMARKS.push(new GroupedBenchmark({ name: "Sunspider", + // FIXME: Potentially fix the sources. + allowUtf16: true, tags: ["Default", "SunSpider"], }, SUNSPIDER_BENCHMARKS)) @@ -2577,6 +2591,7 @@ for (const name of WTB_TESTS) { ], iterations: 5, worstCaseCount: 1, + allowUtf16: true, tags: ["Default", "WTB"], })); } diff --git a/tests/unit-tests.js b/tests/unit-tests.js index 9c476841..746c4cee 100644 --- a/tests/unit-tests.js +++ b/tests/unit-tests.js @@ -102,3 +102,43 @@ function assertEquals(actual, expected, message) { assertTrue(name in allScores); } })(); + + +(function checkUtf16Sources() { + // Test that only explicitly UTF16-enabled benchmarks can have sources + // with non-8-byte characters. + const twoByteCharsRegex = /[^\x00-\xFF]/g; + const jsFileRegex = /\.(js|mjs)$/; + + function checkFile(benchmarkName, file, type) { + if (!jsFileRegex.test(file)) + return; + const content = readFile(file); + const match = content.match(twoByteCharsRegex); + if (!match) + return; + const uniqueMatches = Array.from(new Set(match)); + const offendingChars = uniqueMatches.map(char => { + const hex = char.charCodeAt(0).toString(16).padStart(4, "0"); + return `\n - \\u${hex}: '${char}'`; + }).join(""); + throw new Error( + `Benchmark '${benchmarkName}' has two-byte characters in ${type} '${file}':\n` + + ` Offending characters: ${offendingChars}`); + } + + for (const benchmark of BENCHMARKS) { + if (benchmark.allowUtf16) + continue; + + for (const file of benchmark.files) { + checkFile(benchmark.name, file, "file"); + } + + if (benchmark.plan.preload) { + for (const [name, file] of Object.entries(benchmark.plan.preload)) { + checkFile(benchmark.name, file, `preload.${name}`); + } + } + } +})(); diff --git a/worker/async-task.js b/worker/async-task.js index 9ca26759..35460e5f 100644 --- a/worker/async-task.js +++ b/worker/async-task.js @@ -123,7 +123,7 @@ var Statistics = new (function () { var sumOfSampleVarianceOverSampleSize = stat1.variance / stat1.size + stat2.variance / stat2.size; var t = Math.abs((stat1.mean - stat2.mean) / Math.sqrt(sumOfSampleVarianceOverSampleSize)); - // http://en.wikipedia.org/wiki/Welch–Satterthwaite_equation + // http://en.wikipedia.org/wiki/Welch-Satterthwaite_equation var degreesOfFreedom = sumOfSampleVarianceOverSampleSize * sumOfSampleVarianceOverSampleSize / (stat1.variance * stat1.variance / stat1.size / stat1.size / stat1.degreesOfFreedom + stat2.variance * stat2.variance / stat2.size / stat2.size / stat2.degreesOfFreedom); diff --git a/worker/segmentation.js b/worker/segmentation.js index 17d04e2f..bf98fd25 100644 --- a/worker/segmentation.js +++ b/worker/segmentation.js @@ -125,7 +125,7 @@ var Statistics = new (function () { var sumOfSampleVarianceOverSampleSize = stat1.variance / stat1.size + stat2.variance / stat2.size; var t = Math.abs((stat1.mean - stat2.mean) / Math.sqrt(sumOfSampleVarianceOverSampleSize)); - // http://en.wikipedia.org/wiki/Welch–Satterthwaite_equation + // http://en.wikipedia.org/wiki/Welch-Satterthwaite_equation var degreesOfFreedom = sumOfSampleVarianceOverSampleSize * sumOfSampleVarianceOverSampleSize / (stat1.variance * stat1.variance / stat1.size / stat1.size / stat1.degreesOfFreedom + stat2.variance * stat2.variance / stat2.size / stat2.size / stat2.degreesOfFreedom); From 179b1da5e7647bff41f831df9814843f35f04d65 Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Tue, 26 Aug 2025 11:44:59 +0200 Subject: [PATCH 2/4] fix bigint sources --- JetStreamDriver.js | 3 --- bigint/noble-bls12-381-bundle.js | 4 ++-- bigint/noble-ed25519-bundle.js | 4 ++-- bigint/noble-secp256k1-bundle.js | 4 ++-- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/JetStreamDriver.js b/JetStreamDriver.js index 4d16bfec..c52fc3d6 100644 --- a/JetStreamDriver.js +++ b/JetStreamDriver.js @@ -1960,7 +1960,6 @@ let BENCHMARKS = [ iterations: 4, worstCaseCount: 1, deterministicRandom: true, - allowUtf16: true, tags: ["BigIntNoble"], }), new AsyncBenchmark({ @@ -1971,7 +1970,6 @@ let BENCHMARKS = [ "./bigint/noble-benchmark.js", ], deterministicRandom: true, - allowUtf16: true, tags: ["BigIntNoble"], }), new AsyncBenchmark({ @@ -1983,7 +1981,6 @@ let BENCHMARKS = [ ], iterations: 30, deterministicRandom: true, - allowUtf16: true, tags: ["Default", "BigIntNoble"], }), new DefaultBenchmark({ diff --git a/bigint/noble-bls12-381-bundle.js b/bigint/noble-bls12-381-bundle.js index 2a0c163f..ae3383b4 100644 --- a/bigint/noble-bls12-381-bundle.js +++ b/bigint/noble-bls12-381-bundle.js @@ -3,7 +3,7 @@ // Copyright (c) 2019 Paul Miller (https://paulmillr.com) // Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the “Software”), to deal +// of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is @@ -12,7 +12,7 @@ // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. -// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER diff --git a/bigint/noble-ed25519-bundle.js b/bigint/noble-ed25519-bundle.js index 6bc6385b..1449601f 100644 --- a/bigint/noble-ed25519-bundle.js +++ b/bigint/noble-ed25519-bundle.js @@ -3,7 +3,7 @@ // Copyright (c) 2019 Paul Miller (https://paulmillr.com) // Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the “Software”), to deal +// of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is @@ -12,7 +12,7 @@ // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. -// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER diff --git a/bigint/noble-secp256k1-bundle.js b/bigint/noble-secp256k1-bundle.js index 6aba8704..85937614 100644 --- a/bigint/noble-secp256k1-bundle.js +++ b/bigint/noble-secp256k1-bundle.js @@ -3,7 +3,7 @@ // Copyright (c) 2019 Paul Miller (https://paulmillr.com) // Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the “Software”), to deal +// of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is @@ -12,7 +12,7 @@ // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. -// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER From 9b88f41b3d3257a91301387fca338ba35a068575 Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Tue, 26 Aug 2025 12:01:34 +0200 Subject: [PATCH 3/4] fix test --- tests/unit-tests.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit-tests.js b/tests/unit-tests.js index 746c4cee..f247fb3b 100644 --- a/tests/unit-tests.js +++ b/tests/unit-tests.js @@ -113,7 +113,7 @@ function assertEquals(actual, expected, message) { function checkFile(benchmarkName, file, type) { if (!jsFileRegex.test(file)) return; - const content = readFile(file); + const content = read(file); const match = content.match(twoByteCharsRegex); if (!match) return; From 8ca0a520ef1fe45584f28a2456a983c9fe058387 Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Tue, 26 Aug 2025 12:04:11 +0200 Subject: [PATCH 4/4] fix sunspider sources --- JetStreamDriver.js | 6 ------ SunSpider/crypto-aes.js | 4 ++-- worker/bomb-subtests/crypto-aes.js | 4 ++-- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/JetStreamDriver.js b/JetStreamDriver.js index c52fc3d6..0ef099ba 100644 --- a/JetStreamDriver.js +++ b/JetStreamDriver.js @@ -2307,8 +2307,6 @@ let BENCHMARKS = [ stringUnpackCode: "./worker/bomb-subtests/string-unpack-code.js", regexpDNA: "./worker/bomb-subtests/regexp-dna.js", }, - // FIXME: Potentially fix the sources. - allowUtf16: true, tags: ["Default", "WorkerTests"], }), new AsyncBenchmark({ @@ -2555,15 +2553,11 @@ for (const test of SUNSPIDER_TESTS) { files: [ `./SunSpider/${test}.js` ], - // FIXME: Potentially fix the sources. - allowUtf16: true, tags: [], })); } BENCHMARKS.push(new GroupedBenchmark({ name: "Sunspider", - // FIXME: Potentially fix the sources. - allowUtf16: true, tags: ["Default", "SunSpider"], }, SUNSPIDER_BENCHMARKS)) diff --git a/SunSpider/crypto-aes.js b/SunSpider/crypto-aes.js index 1e19dd14..49795d6f 100644 --- a/SunSpider/crypto-aes.js +++ b/SunSpider/crypto-aes.js @@ -57,12 +57,12 @@ function ShiftRows(s, Nb) { // shift row r of state S left by r bytes [§5.1. function MixColumns(s, Nb) { // combine bytes of each col of state S [§5.1.3] for (var c=0; c<4; c++) { var a = new Array(4); // 'a' is a copy of the current column from 's' - var b = new Array(4); // 'b' is a•{02} in GF(2^8) + var b = new Array(4); // 'b' is a dot {02} in GF(2^8) for (var i=0; i<4; i++) { a[i] = s[i][c]; b[i] = s[i][c]&0x80 ? s[i][c]<<1 ^ 0x011b : s[i][c]<<1; } - // a[n] ^ b[n] is a•{03} in GF(2^8) + // a[n] ^ b[n] is a dot {03} in GF(2^8) s[0][c] = b[0] ^ a[1] ^ b[1] ^ a[2] ^ a[3]; // 2*a0 + 3*a1 + a2 + a3 s[1][c] = a[0] ^ b[1] ^ a[2] ^ b[2] ^ a[3]; // a0 * 2*a1 + 3*a2 + a3 s[2][c] = a[0] ^ a[1] ^ b[2] ^ a[3] ^ b[3]; // a0 + a1 + 2*a2 + 3*a3 diff --git a/worker/bomb-subtests/crypto-aes.js b/worker/bomb-subtests/crypto-aes.js index ad666abb..6b3fb2b6 100644 --- a/worker/bomb-subtests/crypto-aes.js +++ b/worker/bomb-subtests/crypto-aes.js @@ -57,12 +57,12 @@ function ShiftRows(s, Nb) { // shift row r of state S left by r bytes [§5.1. function MixColumns(s, Nb) { // combine bytes of each col of state S [§5.1.3] for (var c=0; c<4; c++) { var a = new Array(4); // 'a' is a copy of the current column from 's' - var b = new Array(4); // 'b' is a•{02} in GF(2^8) + var b = new Array(4); // 'b' is a dot {02} in GF(2^8) for (var i=0; i<4; i++) { a[i] = s[i][c]; b[i] = s[i][c]&0x80 ? s[i][c]<<1 ^ 0x011b : s[i][c]<<1; } - // a[n] ^ b[n] is a•{03} in GF(2^8) + // a[n] ^ b[n] is a dot {03} in GF(2^8) s[0][c] = b[0] ^ a[1] ^ b[1] ^ a[2] ^ a[3]; // 2*a0 + 3*a1 + a2 + a3 s[1][c] = a[0] ^ b[1] ^ a[2] ^ b[2] ^ a[3]; // a0 * 2*a1 + 3*a2 + a3 s[2][c] = a[0] ^ a[1] ^ b[2] ^ a[3] ^ b[3]; // a0 + a1 + 2*a2 + 3*a3