From c3c39bda0cbb0a96e2033436dc48d6d7a01b14e1 Mon Sep 17 00:00:00 2001 From: imxyy_soope_ Date: Wed, 18 Feb 2026 13:03:40 +0800 Subject: [PATCH] feat: v8 profiling --- .gitignore | 1 + Justfile | 8 ++++++++ nix-js/Cargo.toml | 1 + nix-js/src/runtime.rs | 7 ++++++- 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 673b44c..fc5394b 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ profile.json.gz prof.json *.cpuprofile *.cpuprofile.gz +*v8.log diff --git a/Justfile b/Justfile index 3b74586..afc96a7 100644 --- a/Justfile +++ b/Justfile @@ -21,3 +21,11 @@ [no-exit-message] @evali expr: cargo run --release --features inspector -- --inspect-brk 127.0.0.1:9229 eval --expr '{{expr}}' + +[no-exit-message] +@replp: + cargo run --release --features prof -- repl + +[no-exit-message] +@evalp expr: + cargo run --release --features prof -- eval --expr '{{expr}}' diff --git a/nix-js/Cargo.toml b/nix-js/Cargo.toml index d0b9baf..2456952 100644 --- a/nix-js/Cargo.toml +++ b/nix-js/Cargo.toml @@ -76,6 +76,7 @@ uuid = { version = "1", features = ["v4"], optional = true } [features] inspector = ["dep:fastwebsockets", "dep:hyper", "dep:hyper-util", "dep:http-body-util", "dep:http", "dep:uuid"] +prof = [] [dev-dependencies] criterion = { version = "0.8", features = ["html_reports"] } diff --git a/nix-js/src/runtime.rs b/nix-js/src/runtime.rs index 1e4b1df..0124fed 100644 --- a/nix-js/src/runtime.rs +++ b/nix-js/src/runtime.rs @@ -142,7 +142,12 @@ impl Runtime { static INIT: Once = Once::new(); INIT.call_once(|| { assert_eq!( - deno_core::v8_set_flags(vec!["".into(), format!("--stack-size={}", 8 * 1024)]), + deno_core::v8_set_flags(vec![ + "".into(), + format!("--stack-size={}", 8 * 1024), + #[cfg(feature = "prof")] + ("--prof".into()) + ]), [""] ); JsRuntime::init_platform(Some(v8::new_default_platform(0, false).make_shared()));