Commit a5afd47a authored by Peter Marshall's avatar Peter Marshall Committed by Commit Bot

DevTools: Block SIGPROF during CPU throttling

The V8 CPU profiler schedules SIGPROF signals. It is very likely that
the signal handler for these will run while the throttling signal
handler is already running. V8 can't properly read the stack when
there is already a signal handler present.

Fix this by using sa_mask to block V8's SIGPROFs while the
throttling handler is running. This makes more sense overall as well.
Our CPU samples would be skewed by whichever stacks we encounter
during throttling pauses.

Bug: 1027242
Change-Id: I80e856ce1e7b4744a9af7e36c2022b6d8610cf60
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2012280Reviewed-by: default avatarSigurd Schneider <sigurds@chromium.org>
Reviewed-by: default avatarSami Kyöstilä <skyostil@chromium.org>
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#733592}
parent f10118e3
...@@ -106,6 +106,9 @@ void ThreadCPUThrottler::ThrottlingThread::InstallSignalHandler() { ...@@ -106,6 +106,9 @@ void ThreadCPUThrottler::ThrottlingThread::InstallSignalHandler() {
struct sigaction sa; struct sigaction sa;
sa.sa_handler = &HandleSignal; sa.sa_handler = &HandleSignal;
sigemptyset(&sa.sa_mask); sigemptyset(&sa.sa_mask);
// Block SIGPROF while our handler is running so that the V8 CPU profiler
// doesn't try to sample the stack while our signal handler is active.
sigaddset(&sa.sa_mask, SIGPROF);
sa.sa_flags = SA_RESTART; sa.sa_flags = SA_RESTART;
signal_handler_installed_ = signal_handler_installed_ =
(sigaction(SIGUSR2, &sa, &old_signal_handler_) == 0); (sigaction(SIGUSR2, &sa, &old_signal_handler_) == 0);
......
(async function(testRunner) {
const {page, session, dp} = await testRunner.startBlank(
'Test that the profiler can record a profile with cpu throttling enabled.');
await dp.Emulation.setCPUThrottlingRate({rate: 4});
await dp.Profiler.enable();
await dp.Profiler.start();
await session.evaluate(`
let count = 0;
for (let i = 0; i < 1e7; i++) {
count += i;
}
window.count = count;
`);
await dp.Profiler.stop();
testRunner.completeTest();
})
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