Commit 27258eb8 authored by Benedikt Meurer's avatar Benedikt Meurer Committed by Commit Bot

[tracing] Log precise TurboFan/Wasm phase information via Tracing.

This extends the existing PipelineStatistics in the TurboFan pipeline
(also used for Wasm) to emit trace events for the various phases of the
(optimized) compilation. This works for "disabled-by-default-v8.compile"
and "disabled-by-default-v8.wasm" categories.

We also rename the existing phase names to match the naming convention
for the V8 trace events (starting with either "V8.TF" or "V8.Wasm") to
make it easy to spot and categorize them in the trace viewer.

This can be seen in action here

  https://i.paste.pics/a33c0e3942ff707af44f67ed4bac46b0.png

taken from a run of Octane/TypeScript.

Bug: v8:8598
Change-Id: Id40092ee8afc8d998532f8641780052769cad320
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1538121Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Reviewed-by: 's avatarPeter Marshall <petermarshall@chromium.org>
Reviewed-by: 's avatarBen Titzer <titzer@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60433}
parent 6604f182
...@@ -77,11 +77,11 @@ static void WriteLine(std::ostream& os, bool machine_format, const char* name, ...@@ -77,11 +77,11 @@ static void WriteLine(std::ostream& os, bool machine_format, const char* name,
stats.total_allocated_bytes_); stats.total_allocated_bytes_);
os << buffer; os << buffer;
} else { } else {
base::OS::SNPrintF(buffer, kBufferSize, "%28s %10.3f (%5.1f%%) %10" PRIuS base::OS::SNPrintF(
" (%5.1f%%) %10" PRIuS " %10" PRIuS, buffer, kBufferSize,
name, ms, percent, stats.total_allocated_bytes_, "%34s %10.3f (%5.1f%%) %10" PRIuS " (%5.1f%%) %10" PRIuS " %10" PRIuS,
size_percent, stats.max_allocated_bytes_, name, ms, percent, stats.total_allocated_bytes_, size_percent,
stats.absolute_max_allocated_bytes_); stats.max_allocated_bytes_, stats.absolute_max_allocated_bytes_);
os << buffer; os << buffer;
if (stats.function_name_.size() > 0) { if (stats.function_name_.size() > 0) {
...@@ -93,8 +93,8 @@ static void WriteLine(std::ostream& os, bool machine_format, const char* name, ...@@ -93,8 +93,8 @@ static void WriteLine(std::ostream& os, bool machine_format, const char* name,
static void WriteFullLine(std::ostream& os) { static void WriteFullLine(std::ostream& os) {
os << "--------------------------------------------------------" os << "-----------------------------------------------------------"
"--------------------------------------------------------\n"; "-----------------------------------------------------------\n";
} }
...@@ -109,8 +109,8 @@ static void WriteHeader(std::ostream& os) { ...@@ -109,8 +109,8 @@ static void WriteHeader(std::ostream& os) {
static void WritePhaseKindBreak(std::ostream& os) { static void WritePhaseKindBreak(std::ostream& os) {
os << " ---------------------------" os << " ------------------------"
"--------------------------------------------------------\n"; "-----------------------------------------------------------\n";
} }
std::ostream& operator<<(std::ostream& os, const AsPrintableStatistics& ps) { std::ostream& operator<<(std::ostream& os, const AsPrintableStatistics& ps) {
......
...@@ -9,11 +9,22 @@ ...@@ -9,11 +9,22 @@
#include "src/objects/shared-function-info.h" #include "src/objects/shared-function-info.h"
#include "src/objects/string.h" #include "src/objects/string.h"
#include "src/optimized-compilation-info.h" #include "src/optimized-compilation-info.h"
#include "src/tracing/trace-event.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
namespace compiler { namespace compiler {
namespace {
// We log detailed phase information about the pipeline
// in both the v8.compile and the v8.wasm categories.
const char kTraceCategory[] = // --
TRACE_DISABLED_BY_DEFAULT("v8.compile") "," // --
TRACE_DISABLED_BY_DEFAULT("v8.wasm");
} // namespace
void PipelineStatistics::CommonStats::Begin( void PipelineStatistics::CommonStats::Begin(
PipelineStatistics* pipeline_stats) { PipelineStatistics* pipeline_stats) {
DCHECK(!scope_); DCHECK(!scope_);
...@@ -74,31 +85,32 @@ PipelineStatistics::~PipelineStatistics() { ...@@ -74,31 +85,32 @@ PipelineStatistics::~PipelineStatistics() {
void PipelineStatistics::BeginPhaseKind(const char* phase_kind_name) { void PipelineStatistics::BeginPhaseKind(const char* phase_kind_name) {
DCHECK(!InPhase()); DCHECK(!InPhase());
if (InPhaseKind()) EndPhaseKind(); if (InPhaseKind()) EndPhaseKind();
TRACE_EVENT_BEGIN0(kTraceCategory, phase_kind_name);
phase_kind_name_ = phase_kind_name; phase_kind_name_ = phase_kind_name;
phase_kind_stats_.Begin(this); phase_kind_stats_.Begin(this);
} }
void PipelineStatistics::EndPhaseKind() { void PipelineStatistics::EndPhaseKind() {
DCHECK(!InPhase()); DCHECK(!InPhase());
CompilationStatistics::BasicStats diff; CompilationStatistics::BasicStats diff;
phase_kind_stats_.End(this, &diff); phase_kind_stats_.End(this, &diff);
compilation_stats_->RecordPhaseKindStats(phase_kind_name_, diff); compilation_stats_->RecordPhaseKindStats(phase_kind_name_, diff);
TRACE_EVENT_END0(kTraceCategory, phase_kind_name_);
} }
void PipelineStatistics::BeginPhase(const char* phase_name) {
void PipelineStatistics::BeginPhase(const char* name) { TRACE_EVENT_BEGIN0(kTraceCategory, phase_name);
DCHECK(InPhaseKind()); DCHECK(InPhaseKind());
phase_name_ = name; phase_name_ = phase_name;
phase_stats_.Begin(this); phase_stats_.Begin(this);
} }
void PipelineStatistics::EndPhase() { void PipelineStatistics::EndPhase() {
DCHECK(InPhaseKind()); DCHECK(InPhaseKind());
CompilationStatistics::BasicStats diff; CompilationStatistics::BasicStats diff;
phase_stats_.End(this, &diff); phase_stats_.End(this, &diff);
compilation_stats_->RecordPhaseStats(phase_kind_name_, phase_name_, diff); compilation_stats_->RecordPhaseStats(phase_kind_name_, phase_name_, diff);
TRACE_EVENT_END0(kTraceCategory, phase_name_);
} }
} // namespace compiler } // namespace compiler
......
This diff is collapsed.
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