[builtins] add builtins PGO profiling data for x64
Bug: v8:10470 Change-Id: I67e1962c17caecdf7cd9e8ac64ce7e4c0d694a21 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3776693 Reviewed-by: Igor Sheludko <ishell@chromium.org> Commit-Queue: Tobias Tebbi <tebbi@chromium.org> Cr-Commit-Position: refs/heads/main@{#81938}
This commit is contained in:
parent
e8f9ff8507
commit
3e6ad9f2b6
18
BUILD.gn
18
BUILD.gn
@ -183,14 +183,14 @@ declare_args() {
|
||||
# chrome --no-sandbox --disable-extensions
|
||||
# --js-flags="--turbo-profiling-log-builtins --logfile=path/to/v8.log"
|
||||
# "http://localhost/test-suite"
|
||||
# 3. Run tools/get_hints.py to produce the branch hints, selecting min_count
|
||||
# and threshold_ratio as you wish.
|
||||
# 3. Run tools/builtins-pgo/get_hints.py to produce the branch hints,
|
||||
# selecting min_count and threshold_ratio as you wish.
|
||||
# 4. Optionally repeat steps 2-3 for additional workloads, and use
|
||||
# tools/combine_hints.py to combine the hints produced in step 3 into a
|
||||
# single file.
|
||||
# tools/builtins-pgo/combine_hints.py to combine the hints produced in
|
||||
# step 3 into a single file.
|
||||
# 5. Build again with v8_builtins_profiling_log_file set to the file created
|
||||
# in step 3 or 4.
|
||||
v8_builtins_profiling_log_file = ""
|
||||
v8_builtins_profiling_log_file = "default"
|
||||
|
||||
# Enables various testing features.
|
||||
v8_enable_test_features = ""
|
||||
@ -447,6 +447,14 @@ if (v8_enable_external_code_space == "") {
|
||||
if (v8_enable_maglev == "") {
|
||||
v8_enable_maglev = v8_current_cpu == "x64" && v8_enable_pointer_compression
|
||||
}
|
||||
if (v8_builtins_profiling_log_file == "default") {
|
||||
v8_builtins_profiling_log_file = ""
|
||||
if (is_debug == false && v8_optimized_debug == false) {
|
||||
if (v8_current_cpu == "x64") {
|
||||
v8_builtins_profiling_log_file = "tools/builtins-pgo/x64.profile"
|
||||
}
|
||||
}
|
||||
}
|
||||
if (v8_enable_single_generation == "") {
|
||||
v8_enable_single_generation = v8_disable_write_barriers
|
||||
}
|
||||
|
@ -3115,6 +3115,7 @@ MaybeHandle<Code> Pipeline::GenerateCodeForCodeStub(
|
||||
if (profile_data != nullptr &&
|
||||
profile_data->hash() != graph_hash_before_scheduling) {
|
||||
PrintF("Rejected profile data for %s due to function change\n", debug_name);
|
||||
PrintF("Please use tools/builtins-pgo/generate.py to refresh it.\n");
|
||||
profile_data = nullptr;
|
||||
data.set_profile_data(profile_data);
|
||||
}
|
||||
|
77
tools/builtins-pgo/generate.py
Executable file
77
tools/builtins-pgo/generate.py
Executable file
@ -0,0 +1,77 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# Copyright 2022 the V8 project authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can
|
||||
# be found in the LICENSE file.
|
||||
|
||||
import subprocess
|
||||
import argparse
|
||||
import os
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
description='Generate builtin PGO profiles. ' +
|
||||
'The script has to be run from the root of a V8 checkout and updates the profiles in `tools/builtins-pgo`.'
|
||||
)
|
||||
parser.add_argument(
|
||||
'benchmark_path',
|
||||
help='path to benchmark runner .js file, usually JetStream2\'s `cli.js`')
|
||||
parser.add_argument(
|
||||
'--out-path',
|
||||
default="out",
|
||||
help='directory to be used for building V8, by default `./out`')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
def try_start_goma():
|
||||
res = subprocess.run(["goma_ctl", "ensure_start"])
|
||||
print(res.returncode)
|
||||
has_goma = res.returncode == 0
|
||||
print("Detected Goma:", has_goma)
|
||||
return has_goma
|
||||
|
||||
|
||||
def _Write(path, content):
|
||||
with open(path, "w") as f:
|
||||
f.write(content)
|
||||
|
||||
|
||||
def build_d8(path, gn_args):
|
||||
if not os.path.exists(path):
|
||||
os.makedirs(path)
|
||||
_Write(os.path.join(path, "args.gn"), gn_args)
|
||||
subprocess.run(["gn", "gen", path])
|
||||
subprocess.run(["autoninja", "-C", path, "d8"])
|
||||
return os.path.abspath(os.path.join(path, "d8"))
|
||||
|
||||
|
||||
if not os.path.exists(os.path.join("tools", "builtins-pgo", "generate.py")):
|
||||
print("Please run this script from the root of a V8 checkout.")
|
||||
exit(1)
|
||||
|
||||
if not os.path.splitext(args.benchmark_path)[1] != ".js":
|
||||
print("\"")
|
||||
|
||||
v8_path = os.getcwd()
|
||||
|
||||
has_goma = try_start_goma()
|
||||
|
||||
X64_ARGS_TEMPLATE = """\
|
||||
is_debug = false
|
||||
target_cpu = "x64"
|
||||
use_goma = {has_goma}
|
||||
v8_enable_builtins_profiling = true
|
||||
""".format(has_goma="true" if has_goma else "false")
|
||||
|
||||
for arch, gn_args in [("x64", X64_ARGS_TEMPLATE)]:
|
||||
build_dir = os.path.join(args.out_path,
|
||||
arch + ".release.generate_builtin_pgo_profile")
|
||||
d8_path = build_d8(build_dir, gn_args)
|
||||
benchmark_dir = os.path.dirname(args.benchmark_path)
|
||||
benchmark_file = os.path.basename(args.benchmark_path)
|
||||
subprocess.run([d8_path, "--turbo-profiling-log-builtins", benchmark_file],
|
||||
cwd=benchmark_dir)
|
||||
get_hints_path = os.path.join("tools", "builtins-pgo", "get_hints.py")
|
||||
log_path = os.path.join(benchmark_dir, "v8.log")
|
||||
profile_path = os.path.join("tools", "builtins-pgo", arch + ".profile")
|
||||
subprocess.run([get_hints_path, log_path, profile_path])
|
6344
tools/builtins-pgo/x64.profile
Normal file
6344
tools/builtins-pgo/x64.profile
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user