Rename RuntimeProfiler to TieringManager
.. to resolve the overloaded 'runtime' term and overall pick a more meaningful name for this class. It's neither very related to runtime (instead it's called periodically when the bytecode interrupt budget is exhausted); nor is profiling its main purpose. This class is responsible for controlling tiering decisions, hence the new name 'TieringManager'. Bug: v8:7700 Change-Id: Id6f1edf4ebe016d0d81903d0a13e0e1fe6e02142 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3463716 Reviewed-by: Leszek Swirski <leszeks@chromium.org> Reviewed-by: Dominik Inführ <dinfuehr@chromium.org> Reviewed-by: Igor Sheludko <ishell@chromium.org> Commit-Queue: Jakob Gruber <jgruber@chromium.org> Cr-Commit-Position: refs/heads/main@{#79101}
This commit is contained in:
parent
a380537d97
commit
adfe633a0f
@ -1243,8 +1243,6 @@ filegroup(
|
||||
"src/execution/protectors-inl.h",
|
||||
"src/execution/protectors.cc",
|
||||
"src/execution/protectors.h",
|
||||
"src/execution/runtime-profiler.cc",
|
||||
"src/execution/runtime-profiler.h",
|
||||
"src/execution/shared-mutex-guard-if-off-thread.h",
|
||||
"src/execution/simulator-base.cc",
|
||||
"src/execution/simulator-base.h",
|
||||
@ -1255,6 +1253,8 @@ filegroup(
|
||||
"src/execution/thread-id.h",
|
||||
"src/execution/thread-local-top.cc",
|
||||
"src/execution/thread-local-top.h",
|
||||
"src/execution/tiering-manager.cc",
|
||||
"src/execution/tiering-manager.h",
|
||||
"src/execution/v8threads.cc",
|
||||
"src/execution/v8threads.h",
|
||||
"src/execution/vm-state-inl.h",
|
||||
|
4
BUILD.gn
4
BUILD.gn
@ -2921,13 +2921,13 @@ v8_header_set("v8_internal_headers") {
|
||||
"src/execution/pointer-authentication.h",
|
||||
"src/execution/protectors-inl.h",
|
||||
"src/execution/protectors.h",
|
||||
"src/execution/runtime-profiler.h",
|
||||
"src/execution/shared-mutex-guard-if-off-thread.h",
|
||||
"src/execution/simulator-base.h",
|
||||
"src/execution/simulator.h",
|
||||
"src/execution/stack-guard.h",
|
||||
"src/execution/thread-id.h",
|
||||
"src/execution/thread-local-top.h",
|
||||
"src/execution/tiering-manager.h",
|
||||
"src/execution/v8threads.h",
|
||||
"src/execution/vm-state-inl.h",
|
||||
"src/execution/vm-state.h",
|
||||
@ -4142,11 +4142,11 @@ v8_source_set("v8_base_without_compiler") {
|
||||
"src/execution/messages.cc",
|
||||
"src/execution/microtask-queue.cc",
|
||||
"src/execution/protectors.cc",
|
||||
"src/execution/runtime-profiler.cc",
|
||||
"src/execution/simulator-base.cc",
|
||||
"src/execution/stack-guard.cc",
|
||||
"src/execution/thread-id.cc",
|
||||
"src/execution/thread-local-top.cc",
|
||||
"src/execution/tiering-manager.cc",
|
||||
"src/execution/v8threads.cc",
|
||||
"src/extensions/cputracemark-extension.cc",
|
||||
"src/extensions/externalize-string-extension.cc",
|
||||
|
@ -57,7 +57,6 @@
|
||||
#include "src/execution/isolate-inl.h"
|
||||
#include "src/execution/messages.h"
|
||||
#include "src/execution/microtask-queue.h"
|
||||
#include "src/execution/runtime-profiler.h"
|
||||
#include "src/execution/simulator.h"
|
||||
#include "src/execution/v8threads.h"
|
||||
#include "src/execution/vm-state-inl.h"
|
||||
|
@ -34,7 +34,6 @@
|
||||
#include "src/execution/isolate-inl.h"
|
||||
#include "src/execution/isolate.h"
|
||||
#include "src/execution/local-isolate.h"
|
||||
#include "src/execution/runtime-profiler.h"
|
||||
#include "src/execution/vm-state-inl.h"
|
||||
#include "src/handles/handles.h"
|
||||
#include "src/handles/maybe-handles.h"
|
||||
|
@ -53,8 +53,8 @@
|
||||
#include "src/execution/messages.h"
|
||||
#include "src/execution/microtask-queue.h"
|
||||
#include "src/execution/protectors-inl.h"
|
||||
#include "src/execution/runtime-profiler.h"
|
||||
#include "src/execution/simulator.h"
|
||||
#include "src/execution/tiering-manager.h"
|
||||
#include "src/execution/v8threads.h"
|
||||
#include "src/execution/vm-state-inl.h"
|
||||
#include "src/handles/global-handles-inl.h"
|
||||
@ -3387,9 +3387,9 @@ void Isolate::Deinit() {
|
||||
builtins_.TearDown();
|
||||
bootstrapper_->TearDown();
|
||||
|
||||
if (runtime_profiler_ != nullptr) {
|
||||
delete runtime_profiler_;
|
||||
runtime_profiler_ = nullptr;
|
||||
if (tiering_manager_ != nullptr) {
|
||||
delete tiering_manager_;
|
||||
tiering_manager_ = nullptr;
|
||||
}
|
||||
|
||||
delete heap_profiler_;
|
||||
@ -4035,9 +4035,9 @@ bool Isolate::Init(SnapshotData* startup_snapshot_data,
|
||||
optimizing_compile_dispatcher_ = new OptimizingCompileDispatcher(this);
|
||||
}
|
||||
|
||||
// Initialize runtime profiler before deserialization, because collections may
|
||||
// occur, clearing/updating ICs.
|
||||
runtime_profiler_ = new RuntimeProfiler(this);
|
||||
// Initialize before deserialization since collections may occur,
|
||||
// clearing/updating ICs (and thus affecting tiering decisions).
|
||||
tiering_manager_ = new TieringManager(this);
|
||||
|
||||
// If we are deserializing, read the state into the now-empty heap.
|
||||
{
|
||||
|
@ -121,7 +121,7 @@ class PersistentHandlesList;
|
||||
class ReadOnlyArtifacts;
|
||||
class RegExpStack;
|
||||
class RootVisitor;
|
||||
class RuntimeProfiler;
|
||||
class TieringManager;
|
||||
class SetupIsolateDelegate;
|
||||
class Simulator;
|
||||
class SnapshotData;
|
||||
@ -1095,7 +1095,7 @@ class V8_EXPORT_PRIVATE Isolate final : private HiddenFactory {
|
||||
const std::shared_ptr<metrics::Recorder>& metrics_recorder() {
|
||||
return metrics_recorder_;
|
||||
}
|
||||
RuntimeProfiler* runtime_profiler() { return runtime_profiler_; }
|
||||
TieringManager* tiering_manager() { return tiering_manager_; }
|
||||
CompilationCache* compilation_cache() { return compilation_cache_; }
|
||||
Logger* logger() {
|
||||
// Call InitializeLoggingAndCounters() if logging is needed before
|
||||
@ -2071,7 +2071,7 @@ class V8_EXPORT_PRIVATE Isolate final : private HiddenFactory {
|
||||
StringStream* incomplete_message_ = nullptr;
|
||||
Address isolate_addresses_[kIsolateAddressCount + 1] = {};
|
||||
Bootstrapper* bootstrapper_ = nullptr;
|
||||
RuntimeProfiler* runtime_profiler_ = nullptr;
|
||||
TieringManager* tiering_manager_ = nullptr;
|
||||
CompilationCache* compilation_cache_ = nullptr;
|
||||
std::shared_ptr<Counters> async_counters_;
|
||||
base::RecursiveMutex break_access_;
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include "src/compiler-dispatcher/optimizing-compile-dispatcher.h"
|
||||
#include "src/execution/interrupts-scope.h"
|
||||
#include "src/execution/isolate.h"
|
||||
#include "src/execution/runtime-profiler.h"
|
||||
#include "src/execution/simulator.h"
|
||||
#include "src/logging/counters.h"
|
||||
#include "src/objects/backing-store.h"
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "src/execution/runtime-profiler.h"
|
||||
#include "src/execution/tiering-manager.h"
|
||||
|
||||
#include "src/base/platform/platform.h"
|
||||
#include "src/codegen/assembler.h"
|
||||
@ -22,7 +22,6 @@ namespace internal {
|
||||
|
||||
// Maximum size in bytes of generate code for a function to allow OSR.
|
||||
static const int kOSRBytecodeSizeAllowanceBase = 119;
|
||||
|
||||
static const int kOSRBytecodeSizeAllowancePerTick = 44;
|
||||
|
||||
#define OPTIMIZATION_REASON_LIST(V) \
|
||||
@ -85,17 +84,14 @@ void TraceRecompile(JSFunction function, OptimizationReason reason,
|
||||
|
||||
} // namespace
|
||||
|
||||
RuntimeProfiler::RuntimeProfiler(Isolate* isolate)
|
||||
: isolate_(isolate), any_ic_changed_(false) {}
|
||||
|
||||
void RuntimeProfiler::Optimize(JSFunction function, OptimizationReason reason,
|
||||
void TieringManager::Optimize(JSFunction function, OptimizationReason reason,
|
||||
CodeKind code_kind) {
|
||||
DCHECK_NE(reason, OptimizationReason::kDoNotOptimize);
|
||||
TraceRecompile(function, reason, code_kind, isolate_);
|
||||
function.MarkForOptimization(ConcurrencyMode::kConcurrent);
|
||||
}
|
||||
|
||||
void RuntimeProfiler::AttemptOnStackReplacement(UnoptimizedFrame* frame,
|
||||
void TieringManager::AttemptOnStackReplacement(UnoptimizedFrame* frame,
|
||||
int loop_nesting_levels) {
|
||||
JSFunction function = frame->function();
|
||||
SharedFunctionInfo shared = function.shared();
|
||||
@ -122,7 +118,7 @@ void RuntimeProfiler::AttemptOnStackReplacement(UnoptimizedFrame* frame,
|
||||
{level + loop_nesting_levels, AbstractCode::kMaxLoopNestingMarker}));
|
||||
}
|
||||
|
||||
void RuntimeProfiler::MaybeOptimizeFrame(JSFunction function,
|
||||
void TieringManager::MaybeOptimizeFrame(JSFunction function,
|
||||
JavaScriptFrame* frame,
|
||||
CodeKind code_kind) {
|
||||
if (function.IsInOptimizationQueue()) {
|
||||
@ -158,7 +154,7 @@ void RuntimeProfiler::MaybeOptimizeFrame(JSFunction function,
|
||||
}
|
||||
}
|
||||
|
||||
bool RuntimeProfiler::MaybeOSR(JSFunction function, UnoptimizedFrame* frame) {
|
||||
bool TieringManager::MaybeOSR(JSFunction function, UnoptimizedFrame* frame) {
|
||||
int ticks = function.feedback_vector().profiler_ticks();
|
||||
if (function.IsMarkedForOptimization() ||
|
||||
function.IsMarkedForConcurrentOptimization() ||
|
||||
@ -182,7 +178,7 @@ bool ShouldOptimizeAsSmallFunction(int bytecode_size, bool any_ic_changed) {
|
||||
|
||||
} // namespace
|
||||
|
||||
OptimizationReason RuntimeProfiler::ShouldOptimize(JSFunction function,
|
||||
OptimizationReason TieringManager::ShouldOptimize(JSFunction function,
|
||||
BytecodeArray bytecode,
|
||||
JavaScriptFrame* frame) {
|
||||
if (function.ActiveTierIsTurbofan()) {
|
||||
@ -238,21 +234,22 @@ OptimizationReason RuntimeProfiler::ShouldOptimize(JSFunction function,
|
||||
return OptimizationReason::kDoNotOptimize;
|
||||
}
|
||||
|
||||
RuntimeProfiler::MarkCandidatesForOptimizationScope::
|
||||
MarkCandidatesForOptimizationScope(RuntimeProfiler* profiler)
|
||||
TieringManager::OnInterruptTickScope::OnInterruptTickScope(
|
||||
TieringManager* profiler)
|
||||
: handle_scope_(profiler->isolate_), profiler_(profiler) {
|
||||
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"),
|
||||
"V8.MarkCandidatesForOptimization");
|
||||
}
|
||||
|
||||
RuntimeProfiler::MarkCandidatesForOptimizationScope::
|
||||
~MarkCandidatesForOptimizationScope() {
|
||||
TieringManager::OnInterruptTickScope::~OnInterruptTickScope() {
|
||||
profiler_->any_ic_changed_ = false;
|
||||
}
|
||||
|
||||
void RuntimeProfiler::MarkCandidatesForOptimization(JavaScriptFrame* frame) {
|
||||
void TieringManager::OnInterruptTick(JavaScriptFrame* frame) {
|
||||
isolate_->counters()->runtime_profiler_ticks()->Increment();
|
||||
|
||||
if (!isolate_->use_optimizer()) return;
|
||||
MarkCandidatesForOptimizationScope scope(this);
|
||||
OnInterruptTickScope scope(this);
|
||||
|
||||
JSFunction function = frame->function();
|
||||
CodeKind code_kind = function.GetActiveTier().value();
|
||||
@ -268,16 +265,16 @@ void RuntimeProfiler::MarkCandidatesForOptimization(JavaScriptFrame* frame) {
|
||||
MaybeOptimizeFrame(function, frame, code_kind);
|
||||
}
|
||||
|
||||
void RuntimeProfiler::MarkCandidatesForOptimizationFromBytecode() {
|
||||
void TieringManager::OnInterruptTickFromBytecode() {
|
||||
JavaScriptFrameIterator it(isolate_);
|
||||
DCHECK(it.frame()->is_unoptimized());
|
||||
MarkCandidatesForOptimization(it.frame());
|
||||
OnInterruptTick(it.frame());
|
||||
}
|
||||
|
||||
void RuntimeProfiler::MarkCandidatesForOptimizationFromCode() {
|
||||
void TieringManager::OnInterruptTickFromCode() {
|
||||
JavaScriptFrameIterator it(isolate_);
|
||||
DCHECK(it.frame()->is_optimized());
|
||||
MarkCandidatesForOptimization(it.frame());
|
||||
OnInterruptTick(it.frame());
|
||||
}
|
||||
|
||||
} // namespace internal
|
@ -2,8 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef V8_EXECUTION_RUNTIME_PROFILER_H_
|
||||
#define V8_EXECUTION_RUNTIME_PROFILER_H_
|
||||
#ifndef V8_EXECUTION_TIERING_MANAGER_H_
|
||||
#define V8_EXECUTION_TIERING_MANAGER_H_
|
||||
|
||||
#include "src/common/assert-scope.h"
|
||||
#include "src/handles/handles.h"
|
||||
@ -20,14 +20,12 @@ class JSFunction;
|
||||
enum class CodeKind;
|
||||
enum class OptimizationReason : uint8_t;
|
||||
|
||||
class RuntimeProfiler {
|
||||
class TieringManager {
|
||||
public:
|
||||
explicit RuntimeProfiler(Isolate* isolate);
|
||||
explicit TieringManager(Isolate* isolate) : isolate_(isolate) {}
|
||||
|
||||
// Called from the interpreter when the bytecode interrupt has been exhausted.
|
||||
void MarkCandidatesForOptimizationFromBytecode();
|
||||
// Likewise, from generated code.
|
||||
void MarkCandidatesForOptimizationFromCode();
|
||||
void OnInterruptTickFromBytecode();
|
||||
void OnInterruptTickFromCode();
|
||||
|
||||
void NotifyICChanged() { any_ic_changed_ = true; }
|
||||
|
||||
@ -35,8 +33,8 @@ class RuntimeProfiler {
|
||||
int nesting_levels = 1);
|
||||
|
||||
private:
|
||||
// Helper function called from MarkCandidatesForOptimization*
|
||||
void MarkCandidatesForOptimization(JavaScriptFrame* frame);
|
||||
// Helper function called from OnInterruptTick*
|
||||
void OnInterruptTick(JavaScriptFrame* frame);
|
||||
|
||||
// Make the decision whether to optimize the given function, and mark it for
|
||||
// optimization if the decision was 'yes'.
|
||||
@ -53,22 +51,22 @@ class RuntimeProfiler {
|
||||
CodeKind code_kind);
|
||||
void Baseline(JSFunction function, OptimizationReason reason);
|
||||
|
||||
class V8_NODISCARD MarkCandidatesForOptimizationScope final {
|
||||
class V8_NODISCARD OnInterruptTickScope final {
|
||||
public:
|
||||
explicit MarkCandidatesForOptimizationScope(RuntimeProfiler* profiler);
|
||||
~MarkCandidatesForOptimizationScope();
|
||||
explicit OnInterruptTickScope(TieringManager* profiler);
|
||||
~OnInterruptTickScope();
|
||||
|
||||
private:
|
||||
HandleScope handle_scope_;
|
||||
RuntimeProfiler* const profiler_;
|
||||
TieringManager* const profiler_;
|
||||
DisallowGarbageCollection no_gc;
|
||||
};
|
||||
|
||||
Isolate* isolate_;
|
||||
bool any_ic_changed_;
|
||||
Isolate* const isolate_;
|
||||
bool any_ic_changed_ = false;
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
||||
#endif // V8_EXECUTION_RUNTIME_PROFILER_H_
|
||||
#endif // V8_EXECUTION_TIERING_MANAGER_H_
|
@ -30,7 +30,6 @@
|
||||
#include "src/execution/embedder-state.h"
|
||||
#include "src/execution/isolate-utils-inl.h"
|
||||
#include "src/execution/microtask-queue.h"
|
||||
#include "src/execution/runtime-profiler.h"
|
||||
#include "src/execution/v8threads.h"
|
||||
#include "src/execution/vm-state-inl.h"
|
||||
#include "src/handles/global-handles-inl.h"
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include "src/execution/frames-inl.h"
|
||||
#include "src/execution/isolate-inl.h"
|
||||
#include "src/execution/protectors-inl.h"
|
||||
#include "src/execution/runtime-profiler.h"
|
||||
#include "src/execution/tiering-manager.h"
|
||||
#include "src/handles/handles-inl.h"
|
||||
#include "src/ic/call-optimization.h"
|
||||
#include "src/ic/handler-configuration-inl.h"
|
||||
@ -345,7 +345,7 @@ void IC::OnFeedbackChanged(Isolate* isolate, FeedbackVector vector,
|
||||
}
|
||||
#endif
|
||||
|
||||
isolate->runtime_profiler()->NotifyICChanged();
|
||||
isolate->tiering_manager()->NotifyICChanged();
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include "src/deoptimizer/deoptimizer.h"
|
||||
#include "src/execution/frames.h"
|
||||
#include "src/execution/isolate.h"
|
||||
#include "src/execution/runtime-profiler.h"
|
||||
#include "src/execution/simulator.h"
|
||||
#include "src/init/bootstrapper.h"
|
||||
#include "src/libsampler/sampler.h"
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include "src/deoptimizer/deoptimizer.h"
|
||||
#include "src/diagnostics/perf-jit.h"
|
||||
#include "src/execution/isolate.h"
|
||||
#include "src/execution/runtime-profiler.h"
|
||||
#include "src/execution/v8threads.h"
|
||||
#include "src/execution/vm-state-inl.h"
|
||||
#include "src/handles/global-handles.h"
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include "src/execution/frames-inl.h"
|
||||
#include "src/execution/isolate-inl.h"
|
||||
#include "src/execution/messages.h"
|
||||
#include "src/execution/runtime-profiler.h"
|
||||
#include "src/execution/tiering-manager.h"
|
||||
#include "src/handles/maybe-handles.h"
|
||||
#include "src/init/bootstrapper.h"
|
||||
#include "src/logging/counters.h"
|
||||
@ -372,8 +372,7 @@ void BytecodeBudgetInterruptFromBytecode(Isolate* isolate,
|
||||
}
|
||||
if (should_mark_for_optimization) {
|
||||
SealHandleScope shs(isolate);
|
||||
isolate->counters()->runtime_profiler_ticks()->Increment();
|
||||
isolate->runtime_profiler()->MarkCandidatesForOptimizationFromBytecode();
|
||||
isolate->tiering_manager()->OnInterruptTickFromBytecode();
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
@ -427,8 +426,7 @@ RUNTIME_FUNCTION(Runtime_BytecodeBudgetInterruptFromCode) {
|
||||
FeedbackVector::SetInterruptBudget(*feedback_cell);
|
||||
|
||||
SealHandleScope shs(isolate);
|
||||
isolate->counters()->runtime_profiler_ticks()->Increment();
|
||||
isolate->runtime_profiler()->MarkCandidatesForOptimizationFromCode();
|
||||
isolate->tiering_manager()->OnInterruptTickFromCode();
|
||||
return ReadOnlyRoots(isolate).undefined_value();
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include "src/execution/frames-inl.h"
|
||||
#include "src/execution/isolate-inl.h"
|
||||
#include "src/execution/protectors-inl.h"
|
||||
#include "src/execution/runtime-profiler.h"
|
||||
#include "src/execution/tiering-manager.h"
|
||||
#include "src/heap/heap-inl.h" // For ToBoolean. TODO(jkummerow): Drop.
|
||||
#include "src/heap/heap-write-barrier-inl.h"
|
||||
#include "src/ic/stub-cache.h"
|
||||
@ -514,7 +514,7 @@ RUNTIME_FUNCTION(Runtime_OptimizeOsr) {
|
||||
|
||||
// Make the profiler arm all back edges in unoptimized code.
|
||||
if (it.frame()->is_unoptimized()) {
|
||||
isolate->runtime_profiler()->AttemptOnStackReplacement(
|
||||
isolate->tiering_manager()->AttemptOnStackReplacement(
|
||||
UnoptimizedFrame::cast(it.frame()),
|
||||
AbstractCode::kMaxLoopNestingMarker);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user