Commit 5a7977a3 authored by Leszek Swirski's avatar Leszek Swirski Committed by V8 LUCI CQ

[maglev] Add trace events for maglev compilation

Similar to existing v8.compile trace events for Turbofan. Also, augment
both with flow events.

Bug: v8:7700
Change-Id: I1de96120ce1da98fe3ea1670b5f52cc7d65929cd
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3918090
Commit-Queue: Jakob Linke <jgruber@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarJakob Linke <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/main@{#83425}
parent 858602d8
...@@ -1075,8 +1075,9 @@ bool CompileTurbofan_Concurrent(Isolate* isolate, ...@@ -1075,8 +1075,9 @@ bool CompileTurbofan_Concurrent(Isolate* isolate,
TimerEventScope<TimerEventRecompileSynchronous> timer(isolate); TimerEventScope<TimerEventRecompileSynchronous> timer(isolate);
RCS_SCOPE(isolate, RuntimeCallCounterId::kOptimizeConcurrentPrepare); RCS_SCOPE(isolate, RuntimeCallCounterId::kOptimizeConcurrentPrepare);
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), TRACE_EVENT_WITH_FLOW0(TRACE_DISABLED_BY_DEFAULT("v8.compile"),
"V8.OptimizeConcurrentPrepare"); "V8.OptimizeConcurrentPrepare", job.get(),
TRACE_EVENT_FLAG_FLOW_OUT);
if (!PrepareJobWithHandleScope(job.get(), isolate, compilation_info, if (!PrepareJobWithHandleScope(job.get(), isolate, compilation_info,
ConcurrencyMode::kConcurrent)) { ConcurrencyMode::kConcurrent)) {
...@@ -1210,6 +1211,10 @@ MaybeHandle<CodeT> CompileMaglev(Isolate* isolate, Handle<JSFunction> function, ...@@ -1210,6 +1211,10 @@ MaybeHandle<CodeT> CompileMaglev(Isolate* isolate, Handle<JSFunction> function,
auto job = maglev::MaglevCompilationJob::New(isolate, function); auto job = maglev::MaglevCompilationJob::New(isolate, function);
{ {
TRACE_EVENT_WITH_FLOW0(
TRACE_DISABLED_BY_DEFAULT("v8.compile"),
IsSynchronous(mode) ? "V8.MaglevPrepare" : "V8.MaglevConcurrentPrepare",
job.get(), TRACE_EVENT_FLAG_FLOW_OUT);
CompilerTracer::TraceStartMaglevCompile(isolate, function, mode); CompilerTracer::TraceStartMaglevCompile(isolate, function, mode);
CompilationJob::Status status = job->PrepareJob(isolate); CompilationJob::Status status = job->PrepareJob(isolate);
CHECK_EQ(status, CompilationJob::SUCCEEDED); // TODO(v8:7700): Use status. CHECK_EQ(status, CompilationJob::SUCCEEDED); // TODO(v8:7700): Use status.
...@@ -3915,8 +3920,9 @@ void Compiler::FinalizeTurbofanCompilationJob(TurbofanCompilationJob* job, ...@@ -3915,8 +3920,9 @@ void Compiler::FinalizeTurbofanCompilationJob(TurbofanCompilationJob* job,
TimerEventScope<TimerEventRecompileSynchronous> timer(isolate); TimerEventScope<TimerEventRecompileSynchronous> timer(isolate);
RCS_SCOPE(isolate, RuntimeCallCounterId::kOptimizeConcurrentFinalize); RCS_SCOPE(isolate, RuntimeCallCounterId::kOptimizeConcurrentFinalize);
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), TRACE_EVENT_WITH_FLOW0(TRACE_DISABLED_BY_DEFAULT("v8.compile"),
"V8.OptimizeConcurrentFinalize"); "V8.OptimizeConcurrentFinalize", job,
TRACE_EVENT_FLAG_FLOW_IN);
Handle<JSFunction> function = compilation_info->closure(); Handle<JSFunction> function = compilation_info->closure();
Handle<SharedFunctionInfo> shared = compilation_info->shared_info(); Handle<SharedFunctionInfo> shared = compilation_info->shared_info();
......
...@@ -50,8 +50,10 @@ class OptimizingCompileDispatcher::CompileTask : public CancelableTask { ...@@ -50,8 +50,10 @@ class OptimizingCompileDispatcher::CompileTask : public CancelableTask {
RuntimeCallCounterId::kOptimizeBackgroundDispatcherJob); RuntimeCallCounterId::kOptimizeBackgroundDispatcherJob);
TimerEventScope<TimerEventRecompileConcurrent> timer(isolate_); TimerEventScope<TimerEventRecompileConcurrent> timer(isolate_);
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), TurbofanCompilationJob* job = dispatcher_->NextInput(&local_isolate);
"V8.OptimizeBackground"); TRACE_EVENT_WITH_FLOW0(
TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.OptimizeBackground", job,
TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT);
if (dispatcher_->recompilation_delay_ != 0) { if (dispatcher_->recompilation_delay_ != 0) {
base::OS::Sleep(base::TimeDelta::FromMilliseconds( base::OS::Sleep(base::TimeDelta::FromMilliseconds(
...@@ -62,8 +64,7 @@ class OptimizingCompileDispatcher::CompileTask : public CancelableTask { ...@@ -62,8 +64,7 @@ class OptimizingCompileDispatcher::CompileTask : public CancelableTask {
// code space in order to be able to get a bytecode array from a baseline // code space in order to be able to get a bytecode array from a baseline
// code. See SharedFunctionInfo::GetActiveBytecodeArray() for details. // code. See SharedFunctionInfo::GetActiveBytecodeArray() for details.
RwxMemoryWriteScope::SetDefaultPermissionsForNewThread(); RwxMemoryWriteScope::SetDefaultPermissionsForNewThread();
dispatcher_->CompileNext(dispatcher_->NextInput(&local_isolate), dispatcher_->CompileNext(job, &local_isolate);
&local_isolate);
} }
{ {
base::MutexGuard lock_guard(&dispatcher_->ref_count_mutex_); base::MutexGuard lock_guard(&dispatcher_->ref_count_mutex_);
......
...@@ -138,6 +138,9 @@ class MaglevConcurrentDispatcher::JobTask final : public v8::JobTask { ...@@ -138,6 +138,9 @@ class MaglevConcurrentDispatcher::JobTask final : public v8::JobTask {
std::unique_ptr<MaglevCompilationJob> job; std::unique_ptr<MaglevCompilationJob> job;
if (!incoming_queue()->Dequeue(&job)) break; if (!incoming_queue()->Dequeue(&job)) break;
DCHECK_NOT_NULL(job); DCHECK_NOT_NULL(job);
TRACE_EVENT_WITH_FLOW0(
TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.MaglevBackground",
job.get(), TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT);
RuntimeCallStats* rcs = nullptr; // TODO(v8:7700): Implement. RuntimeCallStats* rcs = nullptr; // TODO(v8:7700): Implement.
CompilationJob::Status status = job->ExecuteJob(rcs, &local_isolate); CompilationJob::Status status = job->ExecuteJob(rcs, &local_isolate);
CHECK_EQ(status, CompilationJob::SUCCEEDED); CHECK_EQ(status, CompilationJob::SUCCEEDED);
...@@ -192,6 +195,9 @@ void MaglevConcurrentDispatcher::FinalizeFinishedJobs() { ...@@ -192,6 +195,9 @@ void MaglevConcurrentDispatcher::FinalizeFinishedJobs() {
while (!outgoing_queue_.IsEmpty()) { while (!outgoing_queue_.IsEmpty()) {
std::unique_ptr<MaglevCompilationJob> job; std::unique_ptr<MaglevCompilationJob> job;
outgoing_queue_.Dequeue(&job); outgoing_queue_.Dequeue(&job);
TRACE_EVENT_WITH_FLOW0(TRACE_DISABLED_BY_DEFAULT("v8.compile"),
"V8.MaglevConcurrentFinalize", job.get(),
TRACE_EVENT_FLAG_FLOW_IN);
Compiler::FinalizeMaglevCompilationJob(job.get(), isolate_); Compiler::FinalizeMaglevCompilationJob(job.get(), isolate_);
} }
} }
......
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