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,
stats.total_allocated_bytes_);
os << buffer;
} else {
base::OS::SNPrintF(buffer, kBufferSize, "%28s %10.3f (%5.1f%%) %10" PRIuS
" (%5.1f%%) %10" PRIuS " %10" PRIuS,
name, ms, percent, stats.total_allocated_bytes_,
size_percent, stats.max_allocated_bytes_,
stats.absolute_max_allocated_bytes_);
base::OS::SNPrintF(
buffer, kBufferSize,
"%34s %10.3f (%5.1f%%) %10" PRIuS " (%5.1f%%) %10" PRIuS " %10" PRIuS,
name, ms, percent, stats.total_allocated_bytes_, size_percent,
stats.max_allocated_bytes_, stats.absolute_max_allocated_bytes_);
os << buffer;
if (stats.function_name_.size() > 0) {
......@@ -93,24 +93,24 @@ static void WriteLine(std::ostream& os, bool machine_format, const char* name,
static void WriteFullLine(std::ostream& os) {
os << "--------------------------------------------------------"
"--------------------------------------------------------\n";
os << "-----------------------------------------------------------"
"-----------------------------------------------------------\n";
}
static void WriteHeader(std::ostream& os) {
WriteFullLine(os);
os << " Turbofan phase Time (ms) "
<< " Space (bytes) Function\n"
<< " "
<< " Total Max. Abs. max.\n";
os << " Turbofan phase Time (ms) "
<< " Space (bytes) Function\n"
<< " "
<< " Total Max. Abs. max.\n";
WriteFullLine(os);
}
static void WritePhaseKindBreak(std::ostream& os) {
os << " ---------------------------"
"--------------------------------------------------------\n";
os << " ------------------------"
"-----------------------------------------------------------\n";
}
std::ostream& operator<<(std::ostream& os, const AsPrintableStatistics& ps) {
......
......@@ -9,11 +9,22 @@
#include "src/objects/shared-function-info.h"
#include "src/objects/string.h"
#include "src/optimized-compilation-info.h"
#include "src/tracing/trace-event.h"
namespace v8 {
namespace internal {
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(
PipelineStatistics* pipeline_stats) {
DCHECK(!scope_);
......@@ -74,31 +85,32 @@ PipelineStatistics::~PipelineStatistics() {
void PipelineStatistics::BeginPhaseKind(const char* phase_kind_name) {
DCHECK(!InPhase());
if (InPhaseKind()) EndPhaseKind();
TRACE_EVENT_BEGIN0(kTraceCategory, phase_kind_name);
phase_kind_name_ = phase_kind_name;
phase_kind_stats_.Begin(this);
}
void PipelineStatistics::EndPhaseKind() {
DCHECK(!InPhase());
CompilationStatistics::BasicStats diff;
phase_kind_stats_.End(this, &diff);
compilation_stats_->RecordPhaseKindStats(phase_kind_name_, diff);
TRACE_EVENT_END0(kTraceCategory, phase_kind_name_);
}
void PipelineStatistics::BeginPhase(const char* name) {
void PipelineStatistics::BeginPhase(const char* phase_name) {
TRACE_EVENT_BEGIN0(kTraceCategory, phase_name);
DCHECK(InPhaseKind());
phase_name_ = name;
phase_name_ = phase_name;
phase_stats_.Begin(this);
}
void PipelineStatistics::EndPhase() {
DCHECK(InPhaseKind());
CompilationStatistics::BasicStats diff;
phase_stats_.End(this, &diff);
compilation_stats_->RecordPhaseStats(phase_kind_name_, phase_name_, diff);
TRACE_EVENT_END0(kTraceCategory, phase_name_);
}
} // 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