Unverified Commit 48e53d7d authored by Donny/강동윤's avatar Donny/강동윤 Committed by GitHub

chore(ci): Make turbopack benchmark less flaky (#79980)

### What?

Use mimalloc in the benchmark.

### Why?

I know it's a bit ridiculous, but using mimalloc stabilizes the benchmark. At least, it was the case for SWC.
parent 7973ff9d
...@@ -10157,6 +10157,7 @@ dependencies = [ ...@@ -10157,6 +10157,7 @@ dependencies = [
"turbo-tasks-build", "turbo-tasks-build",
"turbo-tasks-fs", "turbo-tasks-fs",
"turbo-tasks-hash", "turbo-tasks-hash",
"turbo-tasks-malloc",
"turbo-tasks-testing", "turbo-tasks-testing",
"turbopack-core", "turbopack-core",
"turbopack-resolve", "turbopack-resolve",
......
#![cfg_attr(not(codspeed), allow(unused))] #![cfg_attr(not(codspeed), allow(unused))]
extern crate turbo_tasks_malloc;
use std::{ use std::{
path::{Path, PathBuf}, path::{Path, PathBuf},
process::Command, process::Command,
}; };
use criterion::{Criterion, criterion_group, criterion_main}; use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main};
use turbopack_cli::{ use turbopack_cli::{
arguments::{BuildArguments, CommonArguments}, arguments::{BuildArguments, CommonArguments},
register, register,
...@@ -47,44 +49,47 @@ fn bench_small_apps(c: &mut Criterion) { ...@@ -47,44 +49,47 @@ fn bench_small_apps(c: &mut Criterion) {
let mut g = c.benchmark_group("turbopack/build/apps"); let mut g = c.benchmark_group("turbopack/build/apps");
for app in apps { for app in apps {
g.bench_function(app.to_string_lossy().to_string(), |b| { g.bench_function(
let apps_dir = apps_dir.clone(); BenchmarkId::new("build", app.file_name().unwrap().to_string_lossy()),
let app = app.clone(); |b| {
b.iter(move || {
let mut rt = tokio::runtime::Builder::new_multi_thread();
rt.enable_all().on_thread_stop(|| {
TurboMalloc::thread_stop();
});
let rt = rt.build().unwrap();
let apps_dir = apps_dir.clone(); let apps_dir = apps_dir.clone();
let app = app.clone(); let app = app.clone();
let app_name = app.file_name().unwrap().to_string_lossy().to_string(); b.iter(move || {
let mut rt = tokio::runtime::Builder::new_multi_thread();
rt.block_on(async move { rt.enable_all().on_thread_stop(|| {
// TurboMalloc::thread_stop();
turbopack_cli::build::build(&BuildArguments { });
common: CommonArguments { let rt = rt.build().unwrap();
entries: Some(vec![format!("{app_name}/index.tsx")]),
dir: Some(app.clone()), let apps_dir = apps_dir.clone();
root: Some(apps_dir), let app = app.clone();
log_level: None,
show_all: false, let app_name = app.file_name().unwrap().to_string_lossy().to_string();
log_detail: false,
full_stats: false, rt.block_on(async move {
target: None, //
}, turbopack_cli::build::build(&BuildArguments {
no_sourcemap: false, common: CommonArguments {
no_minify: false, entries: Some(vec![format!("{app_name}/index.tsx")]),
force_memory_cleanup: true, dir: Some(app.clone()),
root: Some(apps_dir),
log_level: None,
show_all: false,
log_detail: false,
full_stats: false,
target: None,
},
no_sourcemap: false,
no_minify: false,
force_memory_cleanup: true,
})
.await
}) })
.await .unwrap();
}) });
.unwrap(); },
}); );
});
} }
} }
......
...@@ -77,6 +77,7 @@ par-core = { workspace = true, features = ["rayon"] } ...@@ -77,6 +77,7 @@ par-core = { workspace = true, features = ["rayon"] }
[dev-dependencies] [dev-dependencies]
criterion = { workspace = true, features = ["async_tokio"] } criterion = { workspace = true, features = ["async_tokio"] }
turbo-tasks-backend = { workspace = true } turbo-tasks-backend = { workspace = true }
turbo-tasks-malloc = { workspace = true }
turbo-tasks-testing = { workspace = true } turbo-tasks-testing = { workspace = true }
[build-dependencies] [build-dependencies]
......
extern crate turbo_tasks_malloc;
use criterion::{criterion_group, criterion_main}; use criterion::{criterion_group, criterion_main};
mod analyzer; mod analyzer;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment