summaryrefslogtreecommitdiff
path: root/cli/tools/bench.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-07-17 23:17:28 +0200
committerGitHub <noreply@github.com>2023-07-17 21:17:28 +0000
commit298e4149368b23fee573fa27f1a00e0c50828c8c (patch)
tree0c19422b12b3d04f944bddfb99c891b6d59c45b0 /cli/tools/bench.rs
parent4ebe3bdb06a4d539cc8991e1241aa3150100f866 (diff)
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.
Diffstat (limited to 'cli/tools/bench.rs')
-rw-r--r--cli/tools/bench.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/cli/tools/bench.rs b/cli/tools/bench.rs
index f926cec5a..fd686a938 100644
--- a/cli/tools/bench.rs
+++ b/cli/tools/bench.rs
@@ -95,6 +95,7 @@ pub struct BenchDescription {
pub group: Option<String>,
pub ignore: bool,
pub only: bool,
+ pub warmup: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -194,6 +195,10 @@ impl BenchReporter for JsonReporter {
fn report_output(&mut self, _output: &str) {}
fn report_result(&mut self, desc: &BenchDescription, result: &BenchResult) {
+ if desc.warmup {
+ return;
+ }
+
let maybe_bench = self.0.benches.iter_mut().find(|bench| {
bench.origin == desc.origin
&& bench.group == desc.group
@@ -326,6 +331,10 @@ impl BenchReporter for ConsoleReporter {
}
fn report_result(&mut self, desc: &BenchDescription, result: &BenchResult) {
+ if desc.warmup {
+ return;
+ }
+
let options = self.options.as_ref().unwrap();
match result {