[maglev] Reset profiler ticks on ML finalization

.. since ticks collected in lower tiers use a different budget than
ticks collected in ML code. Keeping ticks from a lower tier would lead
to earlier-than-expected TF compilation requests.

Also, remove the runtime call between loops in osr-from-ml-to-tf.js
to not give TF too much time to tier up. It should no longer happen
now that ticks are cleared, but there's also no reason for the runtime
function to between the loops.

Bug: v8:7700
Fixed: v8:13242
Change-Id: I901c636079de05cb62d2aae1c92f0285a0f8c1ad
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3867310
Auto-Submit: Jakob Linke <jgruber@chromium.org>
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82859}
This commit is contained in:
Jakob Linke 2022-08-31 11:21:44 +02:00 committed by V8 LUCI CQ
parent 8293459504
commit 6565685935
2 changed files with 14 additions and 9 deletions

View File

@ -4000,24 +4000,29 @@ void Compiler::FinalizeMaglevCompilationJob(maglev::MaglevCompilationJob* job,
// when all the bytecodes are implemented.
USE(status);
Handle<JSFunction> function = job->function();
static constexpr BytecodeOffset osr_offset = BytecodeOffset::None();
ResetTieringState(*job->function(), osr_offset);
ResetTieringState(*function, osr_offset);
if (status == CompilationJob::SUCCEEDED) {
const bool kIsContextSpecializing = false;
OptimizedCodeCache::Insert(isolate, *job->function(),
BytecodeOffset::None(), job->function()->code(),
kIsContextSpecializing);
OptimizedCodeCache::Insert(isolate, *function, BytecodeOffset::None(),
function->code(), kIsContextSpecializing);
// Note the finalized Code object has already been installed on the
// function by MaglevCompilationJob::FinalizeJobImpl.
RecordMaglevFunctionCompilation(isolate, job->function());
// Reset ticks just after installation since ticks accumulated in lower
// tiers use a different (lower) budget than ticks collected in Maglev
// code.
ResetProfilerTicks(*function, osr_offset);
RecordMaglevFunctionCompilation(isolate, function);
double ms_prepare = job->time_taken_to_prepare().InMillisecondsF();
double ms_optimize = job->time_taken_to_execute().InMillisecondsF();
double ms_codegen = job->time_taken_to_finalize().InMillisecondsF();
CompilerTracer::TraceFinishMaglevCompile(
isolate, job->function(), ms_prepare, ms_optimize, ms_codegen);
CompilerTracer::TraceFinishMaglevCompile(isolate, function, ms_prepare,
ms_optimize, ms_codegen);
}
#endif
}

View File

@ -19,13 +19,13 @@ function f() {
function g() {
assertTrue(%IsMaglevEnabled());
assertTrue(%IsTurbofanEnabled());
while (!%ActiveTierIsMaglev(f) && --keep_going) {
i = 5.2;
f();
}
console.log('osr to tf', keep_going);
assertTrue(%IsTurbofanEnabled());
i = 66666666666;
f();
assertTrue(keep_going > 0);