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

[cpu-profiler] Make StartProfilingAfterOsr more predictable

Always spend 1ms per iteration.

Previously if the profilerthread took a long time to start up then we
would skip through iterations and potentially not gather enough samples.

This forces each iteration to take 1ms.

Bug: v8:10996
Change-Id: I0dd7bb7e31636c9ebf5dd99110c8a976cbc8f045
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2461727
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
Reviewed-by: 's avatarSimon Zünd <szuend@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70466}
parent 8deb0fd3
......@@ -2210,20 +2210,21 @@ TEST(FunctionDetailsInlining) {
}
static const char* pre_profiling_osr_script = R"(
const kMinIterationDurationMs = 1;
function whenPass(pass, optDuration) {
if (pass == 5) startProfiling();
}
function hot(optDuration, deoptDuration) {
const startTime = Date.now();
%PrepareFunctionForOptimization(hot);
for (let pass = 0; pass <= optDuration + deoptDuration; pass++) {
const startTime = Date.now();
// Let a few passes go by to ensure we have enough feeback info
if (pass == 3) %OptimizeOsr();
// Force deoptimization. %DeoptimizeNow and %DeoptimizeFunction don't
// doptimize OSRs.
if (pass == optDuration) whenPass = () => {};
whenPass(pass, optDuration);
while (Date.now() - startTime < pass) {
while (Date.now() - startTime < kMinIterationDurationMs) {
for (let j = 0; j < 1000; j++) {
x = Math.random() * j;
}
......
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