From a79000c4b17a6678aa74e0b115bb44e1df57fbaa Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Fri, 8 Mar 2024 20:26:01 +0530 Subject: [PATCH 1/4] V8 builtins PGO --- .gitmodules | 3 +++ depot_tools | 1 + 2 files changed, 4 insertions(+) create mode 160000 depot_tools diff --git a/.gitmodules b/.gitmodules index 5ff41bf655..28c7f0230a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -28,3 +28,6 @@ [submodule "third_party/abseil-cpp"] path = third_party/abseil-cpp url = https://chromium.googlesource.com/chromium/src/third_party/abseil-cpp.git +[submodule "depot_tools"] + path = depot_tools + url = https://github.com/denoland/depot_tools diff --git a/depot_tools b/depot_tools new file mode 160000 index 0000000000..726042b2c2 --- /dev/null +++ b/depot_tools @@ -0,0 +1 @@ +Subproject commit 726042b2c223ff037daef0678710044d19e4a947 From edf3b089bbb20115c0bc8526c536dd5e7f4a5b08 Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Fri, 8 Mar 2024 20:26:08 +0530 Subject: [PATCH 2/4] V8 builtins PGO --- .gn | 2 ++ build.rs | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/.gn b/.gn index f1ce46c2cf..68858e0f8a 100644 --- a/.gn +++ b/.gn @@ -72,6 +72,8 @@ default_args = { # Enable V8 object print for debugging. # v8_enable_object_print = true + + v8_enable_builtins_optimization = true # Enable Deno-specific extra bindings deno_enable_extras = true diff --git a/build.rs b/build.rs index f890957918..2d57553229 100644 --- a/build.rs +++ b/build.rs @@ -114,6 +114,9 @@ fn build_v8() { if need_gn_ninja_download() { download_ninja_gn_binaries(); } + if need_pgo_data_download() { + download_v8_pgo_data(); + } // On windows, rustc cannot link with a V8 debug build. let mut gn_args = if is_debug() && !cfg!(target_os = "windows") { @@ -310,6 +313,33 @@ fn download_ninja_gn_binaries() { env::set_var("NINJA", ninja); } +fn download_v8_pgo_data() { + // Update $PATH to include depot_tools + // + // required for vpython3 to work. + env::set_var( + "PATH", + format!( + "{}:{}", + env::var("PATH").unwrap(), + std::env::current_dir() + .unwrap() + .join("depot_tools") + .to_str() + .unwrap() + ), + ); + println!("Downloading PGO data"); + assert!(Command::new(python()) + .arg("./v8/tools/builtins-pgo/download_profiles.py") + .arg("download") + .arg("--depot-tools") + .arg("./depot_tools") + .status() + .unwrap() + .success()); +} + fn static_lib_url() -> String { if let Ok(custom_archive) = env::var("RUSTY_V8_ARCHIVE") { return custom_archive; @@ -533,6 +563,11 @@ fn need_gn_ninja_download() -> bool { !has_ninja || !has_gn } +fn need_pgo_data_download() -> bool { + let pgo_data = Path::new("v8/tools/builtins-pgo/profiles/x64.profile"); + !pgo_data.exists() +} + // Chromiums gn arg clang_base_path is currently compatible with: // * Apples clang and clang from homebrew's llvm@x packages // * the official binaries from releases.llvm.org From 27f595e961cfbe2a0c88795f3183a7e2e17d3308 Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Fri, 8 Mar 2024 21:29:44 +0530 Subject: [PATCH 3/4] x --- build.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/build.rs b/build.rs index 2d57553229..e9503ad7fd 100644 --- a/build.rs +++ b/build.rs @@ -330,6 +330,7 @@ fn download_v8_pgo_data() { ), ); println!("Downloading PGO data"); + #[cfg(not(target_os = "windows"))] assert!(Command::new(python()) .arg("./v8/tools/builtins-pgo/download_profiles.py") .arg("download") From fad28986bcda6b0289a1edf5eb7d699f63865e74 Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Sat, 9 Mar 2024 14:52:01 +0530 Subject: [PATCH 4/4] x --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index 7dcadaec1d..6aac85d875 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -73,6 +73,7 @@ exclude = [ "!v8/tools/run.py", "!v8/tools/snapshot/asm_to_inline_asm.py", "!v8/tools/testrunner/utils/dump_build_config.py", + "!v8/tools/builtins-pgo", ] [features]