Commit 7d468b70 authored by Ross McIlroy's avatar Ross McIlroy Committed by V8 LUCI CQ

[TurboProp] Make TurboProp optimize later.

Moves TurboProp to optimize around the time of TurboFan right now, and
removes some of the special-case logic we had to avoid aggressive
early optimization of TurboProp.

BUG=v8:9684

Change-Id: I0299408891ff6fd57e6523ff309b5f16624466a9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2964814
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: 's avatarMythri Alle <mythria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#75163}
parent 2347c81a
......@@ -38,29 +38,6 @@ static const int kOSRBytecodeSizeAllowancePerTick = 44;
// the very first time it is seen on the stack.
static const int kMaxBytecodeSizeForEarlyOpt = 81;
// Number of times a function has to be seen on the stack before it is
// OSRed in TurboProp
// This value is chosen so TurboProp OSRs at similar time as TurboFan. The
// current interrupt budger of TurboFan is approximately 10 times that of
// TurboProp and we wait for 4 ticks (3 for marking for optimization and an
// additional tick to mark it for OSR) and hence this is set to 4 * 10.
// TODO(mythria): This value should be based on
// FLAG_ticks_scale_factor_for_top_tier.
static const int kProfilerTicksForTurboPropOSR = 4 * 10;
// These are used to decide when we tiering up to Turboprop.
// The number of ticks required for tiering up to Turboprop is based on how
// "soon" the function becomes hot. We use kMidTierGlobalTicksScaleFactor to
// scale the difference in global ticks since the last time a function saw a
// tick. The scaled difference is used to to increase the number of ticks
// required for tiering up to Turboprop.
static const int kMidTierGlobalTicksScaleFactor = 100;
// This is used to limit the number of additional ticks that the
// kMidTierGlobalTicksScaleFactor can increase threshold for mid-tier tier
// tierup.
static const int kMaxAdditionalMidTierGlobalTicks = 10;
#define OPTIMIZATION_REASON_LIST(V) \
V(DoNotOptimize, "do not optimize") \
V(HotAndStable, "hot and stable") \
......@@ -122,7 +99,7 @@ void TraceRecompile(JSFunction function, OptimizationReason reason,
} // namespace
RuntimeProfiler::RuntimeProfiler(Isolate* isolate)
: isolate_(isolate), any_ic_changed_(false), current_global_ticks_(0) {}
: isolate_(isolate), any_ic_changed_(false) {}
void RuntimeProfiler::Optimize(JSFunction function, OptimizationReason reason,
CodeKind code_kind) {
......@@ -192,9 +169,6 @@ void RuntimeProfiler::MaybeOptimizeFrame(JSFunction function,
if (reason != OptimizationReason::kDoNotOptimize) {
Optimize(function, reason, code_kind);
}
function.feedback_vector()
.set_global_ticks_at_last_runtime_profiler_interrupt(
current_global_ticks_);
}
bool RuntimeProfiler::MaybeOSR(JSFunction function, UnoptimizedFrame* frame) {
......@@ -202,17 +176,6 @@ bool RuntimeProfiler::MaybeOSR(JSFunction function, UnoptimizedFrame* frame) {
// TODO(rmcilroy): Also ensure we only OSR top-level code if it is smaller
// than kMaxToplevelSourceSize.
// Turboprop optimizes quite early. So don't attempt to OSR if the loop isn't
// hot enough.
// TODO(mythria): We should decide when to OSR based on number of ticks
// instead of checking if it has been marked for optimization. That will allow
// us to unify OSR decisions from different tiers and we can remove this
// special case here for Turboprop. If we do that also remove the code to
// reset the marker in Runtime_CompileForOnStackReplacement.
if (FLAG_turboprop && ticks < kProfilerTicksForTurboPropOSR) {
return false;
}
if (function.IsMarkedForOptimization() ||
function.IsMarkedForConcurrentOptimization() ||
function.HasAvailableOptimizedCode()) {
......@@ -238,7 +201,6 @@ namespace {
bool ShouldOptimizeAsSmallFunction(int bytecode_size, int ticks,
bool any_ic_changed,
bool active_tier_is_turboprop) {
if (FLAG_turboprop) return false;
if (any_ic_changed || bytecode_size >= kMaxBytecodeSizeForEarlyOpt)
return false;
return true;
......@@ -259,17 +221,6 @@ OptimizationReason RuntimeProfiler::ShouldOptimize(JSFunction function,
int ticks_for_optimization =
kProfilerTicksBeforeOptimization +
(bytecode.length() / kBytecodeSizeAllowancePerTick);
if (FLAG_turboprop && !active_tier_is_turboprop) {
DCHECK_EQ(function.NextTier(), CodeKind::TURBOPROP);
int global_ticks_diff =
(current_global_ticks_ -
function.feedback_vector()
.global_ticks_at_last_runtime_profiler_interrupt());
ticks_for_optimization =
ticks_for_optimization +
std::min(global_ticks_diff / kMidTierGlobalTicksScaleFactor,
kMaxAdditionalMidTierGlobalTicks);
}
if (ticks >= ticks_for_optimization) {
return OptimizationReason::kHotAndStable;
} else if (ShouldOptimizeAsSmallFunction(bytecode.length(), ticks,
......@@ -297,10 +248,6 @@ RuntimeProfiler::MarkCandidatesForOptimizationScope::
: handle_scope_(profiler->isolate_), profiler_(profiler) {
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"),
"V8.MarkCandidatesForOptimization");
if (profiler_->current_global_ticks_ <
FeedbackVector::GlobalTicksAtLastRuntimeProfilerInterruptBits::kMax - 1) {
profiler_->current_global_ticks_ += 1;
}
}
RuntimeProfiler::MarkCandidatesForOptimizationScope::
......
......@@ -65,7 +65,6 @@ class RuntimeProfiler {
Isolate* isolate_;
bool any_ic_changed_;
unsigned int current_global_ticks_;
};
} // namespace internal
......
......@@ -641,14 +641,11 @@ DEFINE_BOOL(
turboprop_as_toptier, false,
"enable experimental turboprop compiler without further tierup to turbofan")
DEFINE_IMPLICATION(turboprop_as_toptier, turboprop)
DEFINE_VALUE_IMPLICATION(turboprop, interrupt_budget, 20 * KB)
DEFINE_VALUE_IMPLICATION(turboprop, reuse_opt_code_count, 2)
DEFINE_UINT_READONLY(max_minimorphic_map_checks, 4,
"max number of map checks to perform in minimorphic state")
// The scale factor determines the interrupt budget when tiering up from
// Turboprop to TurboFan. The default of 10 is approximately the ratio of
// Turboprop to the TurboFan interrupt budget.
DEFINE_INT(interrupt_budget_scale_factor_for_top_tier, 10,
// Turboprop to TurboFan.
DEFINE_INT(interrupt_budget_scale_factor_for_top_tier, 5,
"scale factor for profiler ticks when tiering up from midtier")
// Flags for Sparkplug
......
......@@ -132,16 +132,6 @@ OptimizationMarker FeedbackVector::optimization_marker() const {
return OptimizationMarkerBits::decode(flags());
}
int FeedbackVector::global_ticks_at_last_runtime_profiler_interrupt() const {
return GlobalTicksAtLastRuntimeProfilerInterruptBits::decode(flags());
}
void FeedbackVector::set_global_ticks_at_last_runtime_profiler_interrupt(
int ticks) {
set_flags(
GlobalTicksAtLastRuntimeProfilerInterruptBits::update(flags(), ticks));
}
OptimizationTier FeedbackVector::optimization_tier() const {
OptimizationTier tier = OptimizationTierBits::decode(flags());
// It is possible that the optimization tier bits aren't updated when the code
......
......@@ -226,8 +226,6 @@ class FeedbackVector
inline bool has_optimization_marker() const;
inline OptimizationMarker optimization_marker() const;
inline OptimizationTier optimization_tier() const;
inline int global_ticks_at_last_runtime_profiler_interrupt() const;
inline void set_global_ticks_at_last_runtime_profiler_interrupt(int ticks);
void ClearOptimizedCode(FeedbackCell feedback_cell);
void EvictOptimizedCodeMarkedForDeoptimization(FeedbackCell feedback_cell,
SharedFunctionInfo shared,
......
......@@ -1027,7 +1027,7 @@
'compiler/serializer-transition-propagation': [SKIP],
'opt-elements-kind': [SKIP],
'regress/regress-trap-allocation-memento': [SKIP],
'regress/regress-v8-9267-*': [SKIP],
'regress/regrtoess-v8-9267-*': [SKIP],
'shared-function-tier-up-turbo': [SKIP],
}], # 'gc_fuzzer'
......
......@@ -63,8 +63,6 @@ INCOMPATIBLE_FLAGS_PER_VARIANT = {
"--max-inlined-bytecode-size-cumulative=*", "--stress-inline"],
"sparkplug": ["--jitless"],
"always_sparkplug": ["--jitless"],
"turboprop": ["--interrupt-budget=*"],
"turboprop_as_toptier": ["--interrupt-budget=*"],
"code_serializer": ["--cache=after-execute", "--cache=full-code-cache",
"--cache=none"],
"experimental_regexp": ["--no-enable-experimental-regexp-engine"],
......
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