From 298e4149368b23fee573fa27f1a00e0c50828c8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Mon, 17 Jul 2023 23:17:28 +0200 Subject: fix(bench): run warmup benchmark to break JIT bias (#19844) Closes https://github.com/denoland/deno/issues/15277 This commit adds a single "warmup" run of empty function when running `deno bench`. This change will break so-called "JIT bias" which makes V8 optimize the first function and then bail out of optimization on second function. In essence the "warmup" function is getting optimized and then all user benches are bailed out of optimization. --- cli/ops/bench.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'cli/ops') diff --git a/cli/ops/bench.rs b/cli/ops/bench.rs index f569a8cbb..0f7509751 100644 --- a/cli/ops/bench.rs +++ b/cli/ops/bench.rs @@ -101,6 +101,8 @@ struct BenchInfo<'s> { group: Option, ignore: bool, only: bool, + #[serde(default)] + warmup: bool, } #[derive(Debug, Serialize)] @@ -128,6 +130,7 @@ fn op_register_bench<'a>( group: info.group, ignore: info.ignore, only: info.only, + warmup: info.warmup, }; let function: v8::Local = info.function.v8_value.try_into()?; let function = v8::Global::new(scope, function); -- cgit v1.2.3