Commit ec71d2b9 authored by Mythri A's avatar Mythri A Committed by Commit Bot

[runtime-profiler] Update profiler ticks before tiering up decisions

We used to update profiler ticks after tiering up decisions when tiering
up from Ignition and update the ticks before when tiering up from
mid-tier optimized code. This meant we added special cases to account for
this difference. This cl makes updating the ticks uniform by always
updating the ticks before tiering up decisions. Also adjusts the
heuristics to take this into account.

Bug: v8:9684
Change-Id: I2c63ba3499c542bb4a69e55d6cc4bebe4612793f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2563659Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Commit-Queue: Mythri Alle <mythria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71457}
parent 9a0faab2
......@@ -22,7 +22,7 @@ namespace internal {
// Number of times a function has to be seen on the stack before it is
// optimized.
static const int kProfilerTicksBeforeOptimization = 2;
static const int kProfilerTicksBeforeOptimization = 3;
// The number of ticks required for optimizing a function increases with
// the size of the bytecode. This is in addition to the
......@@ -30,7 +30,7 @@ static const int kProfilerTicksBeforeOptimization = 2;
static const int kBytecodeSizeAllowancePerTick = 1200;
// Maximum size in bytes of generate code for a function to allow OSR.
static const int kOSRBytecodeSizeAllowanceBase = 180;
static const int kOSRBytecodeSizeAllowanceBase = 132;
static const int kOSRBytecodeSizeAllowancePerTick = 48;
......@@ -265,17 +265,9 @@ OptimizationReason RuntimeProfiler::ShouldOptimize(JSFunction function,
bool active_tier_is_turboprop = function.ActiveTierIsMidtierTurboprop();
int scale_factor =
active_tier_is_turboprop ? FLAG_ticks_scale_factor_for_top_tier : 1;
// TODO(turboprop, mythria): There is a difference in when we increment the
// profiler ticks on the feedback vector. For interrupts from interpreted code
// we increment after the tier up decision and from optimized code we
// increment before the decision. So we need to adjust the ticks here if we
// are tiering up from Turboprop to Turbofan. The right fix is to make the
// increments consistent in both places and avoid adding one additional tick
// here.
int ticks_for_optimization =
kProfilerTicksBeforeOptimization +
(bytecode.length() / kBytecodeSizeAllowancePerTick) +
(active_tier_is_turboprop ? 1 : 0);
(bytecode.length() / kBytecodeSizeAllowancePerTick);
ticks_for_optimization *= scale_factor;
if (ticks >= ticks_for_optimization) {
return OptimizationReason::kHotAndStable;
......@@ -326,11 +318,9 @@ void RuntimeProfiler::MarkCandidatesForOptimizationFromBytecode() {
if (!function.has_feedback_vector()) continue;
MaybeOptimizeFrame(function, frame, CodeKind::INTERPRETED_FUNCTION);
// TODO(leszeks): Move this increment to before the maybe optimize checks,
// and update the tests to assume the increment has already happened.
function.feedback_vector().SaturatingIncrementProfilerTicks();
MaybeOptimizeFrame(function, frame, CodeKind::INTERPRETED_FUNCTION);
}
}
......
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