[tools] Fix linux-perf-chrome.py renderer command path

Drive-by-fix:
- Wait for linux-perf to flush large profile files

No-try: True
Change-Id: I729aa897e3f55fc92a9412208322ee099029453f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3605282
Reviewed-by: Victor Gomes <victorgomes@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80154}
This commit is contained in:
Camillo Bruni 2022-04-25 16:52:01 +02:00 committed by V8 LUCI CQ
parent 983046cf67
commit 19a991d578
3 changed files with 17 additions and 9 deletions

View File

@ -40,6 +40,5 @@ for i in "$@"; do
esac esac
done done
PERF_OUTPUT="$PERF_DATA_DIR/${PERF_DATA_PREFIX}_${PPID}_${RENDERER_ID}.perf.data" PERF_OUTPUT="$PERF_DATA_DIR/${PERF_DATA_PREFIX}_${PPID}_${RENDERER_ID}.perf.data"
perf record --call-graph=fp --clockid=mono --freq=max --output="${PERF_OUTPUT}" -- $@ perf record --call-graph=fp --clockid=mono --freq=max --output="${PERF_OUTPUT}" -- $@

View File

@ -14,7 +14,7 @@ import time
import psutil import psutil
import multiprocessing import multiprocessing
renderer_cmd_file = Path(__file__).parent / 'linux-perf-renderer-cmd.sh' renderer_cmd_file = Path(__file__).parent / 'linux-perf-chrome-renderer-cmd.sh'
assert renderer_cmd_file.is_file() assert renderer_cmd_file.is_file()
renderer_cmd_prefix = f"{renderer_cmd_file} --perf-data-prefix=chrome_renderer" renderer_cmd_prefix = f"{renderer_cmd_file} --perf-data-prefix=chrome_renderer"
@ -109,7 +109,7 @@ old_cwd = Path.cwd()
os.chdir(options.perf_data_dir) os.chdir(options.perf_data_dir)
# ============================================================================== # ==============================================================================
JS_FLAGS_PERF = ("--perf-prof --no-write-protect-code-memory " JS_FLAGS_PERF = ("--perf-prof", "--no-write-protect-code-memory",
"--interpreted-frames-native-stack") "--interpreted-frames-native-stack")
@ -134,10 +134,15 @@ with tempfile.TemporaryDirectory(prefix="chrome-") as tmp_dir_path:
"--no-sandbox", "--incognito", "--enable-benchmarking", "--no-first-run", "--no-sandbox", "--incognito", "--enable-benchmarking", "--no-first-run",
"--no-default-browser-check", "--no-default-browser-check",
f"--renderer-cmd-prefix={options.renderer_cmd_prefix}", f"--renderer-cmd-prefix={options.renderer_cmd_prefix}",
f"--js-flags={JS_FLAGS_PERF}"
] ]
# Do the magic js-flag concatenation to properly forward them to the
# renderer command
js_flags = set(JS_FLAGS_PERF)
if options.js_flags: if options.js_flags:
cmd += [f"--js-flags={options.js_flags}"] js_flags.update(shlex.split(options.js_flags))
cmd += [f"--js-flags={','.join(list(js_flags))}"]
if options.enable_features: if options.enable_features:
cmd += [f"--enable-features={options.enable_features}"] cmd += [f"--enable-features={options.enable_features}"]
if options.disable_features: if options.disable_features:
@ -156,7 +161,9 @@ with tempfile.TemporaryDirectory(prefix="chrome-") as tmp_dir_path:
if options.timeout is None: if options.timeout is None:
try: try:
subprocess.check_call(cmd) subprocess.check_call(cmd, start_new_session=True)
log("Waiting for linux-perf to flush all perf data")
time.sleep(3)
except: except:
log("ERROR running perf record") log("ERROR running perf record")
else: else:
@ -169,8 +176,8 @@ with tempfile.TemporaryDirectory(prefix="chrome-") as tmp_dir_path:
if "chrome" in child.name() or "content_shell" in child.name(): if "chrome" in child.name() or "content_shell" in child.name():
print(f" quitting PID={child.pid}") print(f" quitting PID={child.pid}")
child.send_signal(signal.SIGQUIT) child.send_signal(signal.SIGQUIT)
# Wait for linux-perf to write out files log("Waiting for linux-perf to flush all perf data")
time.sleep(1) time.sleep(3)
return_status = process.poll() return_status = process.poll()
if return_status is None: if return_status is None:
log("Force quitting linux-perf") log("Force quitting linux-perf")

View File

@ -178,6 +178,8 @@ def wait_for_process_timeout(process):
if options.timeout is None: if options.timeout is None:
try: try:
subprocess.check_call(cmd) subprocess.check_call(cmd)
log("Waiting for linux-perf to flush all perf data")
time.sleep(1)
except: except:
log("ERROR running perf record") log("ERROR running perf record")
else: else:
@ -190,7 +192,7 @@ else:
if "d8" in child.name(): if "d8" in child.name():
print(f" quitting PID={child.pid}") print(f" quitting PID={child.pid}")
child.send_signal(signal.SIGQUIT) child.send_signal(signal.SIGQUIT)
# Wait for linux-perf to write out files log("Waiting for linux-perf to flush all perf data")
time.sleep(1) time.sleep(1)
return_status = process.poll() return_status = process.poll()
if return_status is None: if return_status is None: