Commit b04f6a41 authored by Michael Achenbach's avatar Michael Achenbach Committed by Commit Bot

Revert "[wasm] Add CPU time metrics"

This reverts commit dcdaf42f.

Reason for revert: This has problems on mac-arm64:
https://ci.chromium.org/p/v8/builders/ci/V8%20Mac%20-%20arm64%20-%20release/3591

Original change's description:
> [wasm] Add CPU time metrics
>
> This adds CPU time metrics to the WasmModuleDecoded (except for streaming),
> WasmModuleCompiled and WasmModuleTieredUp events. This can later be used
> to provide this information as UKMs or UMAs.
>
> Bug: v8:11611
> Change-Id: I36818f5efbdcae2d3ed6f27c16db21f9d8440d98
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2796952
> Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> Reviewed-by: Andreas Haas <ahaas@chromium.org>
> Commit-Queue: Emanuel Ziegler <ecmziegler@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#73882}

Bug: v8:11611
Change-Id: I1c82c3e4f19b3a486538fd62665669f6c5b98438
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2818380
Auto-Submit: Michael Achenbach <machenbach@chromium.org>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/master@{#73884}
parent 2acc3d96
...@@ -69,7 +69,6 @@ struct WasmModuleDecoded { ...@@ -69,7 +69,6 @@ struct WasmModuleDecoded {
size_t module_size_in_bytes = 0; size_t module_size_in_bytes = 0;
size_t function_count = 0; size_t function_count = 0;
int64_t wall_clock_duration_in_us = -1; int64_t wall_clock_duration_in_us = -1;
int64_t cpu_duration_in_us = -1;
}; };
struct WasmModuleCompiled { struct WasmModuleCompiled {
...@@ -82,7 +81,6 @@ struct WasmModuleCompiled { ...@@ -82,7 +81,6 @@ struct WasmModuleCompiled {
size_t code_size_in_bytes = 0; size_t code_size_in_bytes = 0;
size_t liftoff_bailout_count = 0; size_t liftoff_bailout_count = 0;
int64_t wall_clock_duration_in_us = -1; int64_t wall_clock_duration_in_us = -1;
int64_t cpu_duration_in_us = -1;
}; };
struct WasmModuleInstantiated { struct WasmModuleInstantiated {
...@@ -96,7 +94,6 @@ struct WasmModuleTieredUp { ...@@ -96,7 +94,6 @@ struct WasmModuleTieredUp {
bool lazy = false; bool lazy = false;
size_t code_size_in_bytes = 0; size_t code_size_in_bytes = 0;
int64_t wall_clock_duration_in_us = -1; int64_t wall_clock_duration_in_us = -1;
int64_t cpu_duration_in_us = -1;
}; };
struct WasmModulesPerIsolate { struct WasmModulesPerIsolate {
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
#include "src/wasm/function-compiler.h" #include "src/wasm/function-compiler.h"
#include "src/base/platform/time.h"
#include "src/codegen/compiler.h" #include "src/codegen/compiler.h"
#include "src/codegen/macro-assembler-inl.h" #include "src/codegen/macro-assembler-inl.h"
#include "src/codegen/optimized-compilation-info.h" #include "src/codegen/optimized-compilation-info.h"
...@@ -184,9 +183,6 @@ WasmCompilationResult WasmCompilationUnit::ExecuteFunctionCompilation( ...@@ -184,9 +183,6 @@ WasmCompilationResult WasmCompilationUnit::ExecuteFunctionCompilation(
} }
WasmCompilationResult result; WasmCompilationResult result;
base::ThreadTicks thread_ticks = base::ThreadTicks::IsSupported()
? base::ThreadTicks::Now()
: base::ThreadTicks();
switch (tier_) { switch (tier_) {
case ExecutionTier::kNone: case ExecutionTier::kNone:
...@@ -227,11 +223,6 @@ WasmCompilationResult WasmCompilationUnit::ExecuteFunctionCompilation( ...@@ -227,11 +223,6 @@ WasmCompilationResult WasmCompilationUnit::ExecuteFunctionCompilation(
break; break;
} }
if (!thread_ticks.IsNull()) {
result.cpu_duration =
(base::ThreadTicks::Now() - thread_ticks).InMicroseconds();
}
return result; return result;
} }
...@@ -278,7 +269,6 @@ void WasmCompilationUnit::CompileWasmFunction(Isolate* isolate, ...@@ -278,7 +269,6 @@ void WasmCompilationUnit::CompileWasmFunction(Isolate* isolate,
isolate->wasm_engine(), &env, isolate->wasm_engine(), &env,
native_module->compilation_state()->GetWireBytesStorage(), native_module->compilation_state()->GetWireBytesStorage(),
isolate->counters(), detected); isolate->counters(), detected);
native_module->UpdateCPUDuration(result);
if (result.succeeded()) { if (result.succeeded()) {
WasmCodeRefScope code_ref_scope; WasmCodeRefScope code_ref_scope;
native_module->PublishCode( native_module->PublishCode(
......
...@@ -75,7 +75,6 @@ struct WasmCompilationResult { ...@@ -75,7 +75,6 @@ struct WasmCompilationResult {
ExecutionTier result_tier; ExecutionTier result_tier;
Kind kind = kFunction; Kind kind = kFunction;
ForDebugging for_debugging = kNoDebugging; ForDebugging for_debugging = kNoDebugging;
size_t cpu_duration = 0;
}; };
class V8_EXPORT_PRIVATE WasmCompilationUnit final { class V8_EXPORT_PRIVATE WasmCompilationUnit final {
......
...@@ -1126,7 +1126,6 @@ bool CompileLazy(Isolate* isolate, Handle<WasmModuleObject> module_object, ...@@ -1126,7 +1126,6 @@ bool CompileLazy(Isolate* isolate, Handle<WasmModuleObject> module_object,
isolate->wasm_engine(), &env, compilation_state->GetWireBytesStorage(), isolate->wasm_engine(), &env, compilation_state->GetWireBytesStorage(),
counters, &detected_features); counters, &detected_features);
compilation_state->OnCompilationStopped(detected_features); compilation_state->OnCompilationStopped(detected_features);
native_module->UpdateCPUDuration(result);
// During lazy compilation, we can only get compilation errors when // During lazy compilation, we can only get compilation errors when
// {--wasm-lazy-validation} is enabled. Otherwise, the module was fully // {--wasm-lazy-validation} is enabled. Otherwise, the module was fully
...@@ -1310,8 +1309,6 @@ CompilationExecutionResult ExecuteCompilationUnits( ...@@ -1310,8 +1309,6 @@ CompilationExecutionResult ExecuteCompilationUnits(
// (synchronized): Publish the compilation result and get the next unit. // (synchronized): Publish the compilation result and get the next unit.
BackgroundCompileScope compile_scope(native_module); BackgroundCompileScope compile_scope(native_module);
if (compile_scope.cancelled()) return kYield; if (compile_scope.cancelled()) return kYield;
compile_scope.native_module()->UpdateCPUDuration(
results_to_publish.back());
if (!results_to_publish.back().succeeded()) { if (!results_to_publish.back().succeeded()) {
compile_scope.compilation_state()->SetError(); compile_scope.compilation_state()->SetError();
...@@ -1488,6 +1485,7 @@ class CompilationTimeCallback { ...@@ -1488,6 +1485,7 @@ class CompilationTimeCallback {
histogram->AddSample(static_cast<int>(duration.InMicroseconds())); histogram->AddSample(static_cast<int>(duration.InMicroseconds()));
} }
// TODO(sartang@microsoft.com): Remove wall_clock_time_in_us field
v8::metrics::WasmModuleCompiled event{ v8::metrics::WasmModuleCompiled event{
(compile_mode_ != kSynchronous), // async (compile_mode_ != kSynchronous), // async
(compile_mode_ == kStreaming), // streamed (compile_mode_ == kStreaming), // streamed
...@@ -1497,10 +1495,8 @@ class CompilationTimeCallback { ...@@ -1497,10 +1495,8 @@ class CompilationTimeCallback {
true, // success true, // success
native_module->liftoff_code_size(), // code_size_in_bytes native_module->liftoff_code_size(), // code_size_in_bytes
native_module->liftoff_bailout_count(), // liftoff_bailout_count native_module->liftoff_bailout_count(), // liftoff_bailout_count
duration.InMicroseconds(), // wall_clock_duration_in_us duration.InMicroseconds() // wall_clock_duration_in_us
FLAG_liftoff // cpu_time_duration_in_us };
? native_module->liftoff_cpu_duration()
: native_module->turbofan_cpu_duration()};
metrics_recorder_->DelayMainThreadEvent(event, context_id_); metrics_recorder_->DelayMainThreadEvent(event, context_id_);
} }
if (event == CompilationEvent::kFinishedTopTierCompilation) { if (event == CompilationEvent::kFinishedTopTierCompilation) {
...@@ -1508,10 +1504,9 @@ class CompilationTimeCallback { ...@@ -1508,10 +1504,9 @@ class CompilationTimeCallback {
histogram->AddSample(static_cast<int>(duration.InMicroseconds())); histogram->AddSample(static_cast<int>(duration.InMicroseconds()));
v8::metrics::WasmModuleTieredUp event{ v8::metrics::WasmModuleTieredUp event{
FLAG_wasm_lazy_compilation, // lazy FLAG_wasm_lazy_compilation, // lazy
native_module->turbofan_code_size(), // code_size_in_bytes native_module->turbofan_code_size(), // code_size_in_bytes
duration.InMicroseconds(), // wall_clock_duration_in_us duration.InMicroseconds() // wall_clock_duration_in_us
native_module->turbofan_cpu_duration() // cpu_time_duration_in_us
}; };
metrics_recorder_->DelayMainThreadEvent(event, context_id_); metrics_recorder_->DelayMainThreadEvent(event, context_id_);
} }
...@@ -1525,10 +1520,8 @@ class CompilationTimeCallback { ...@@ -1525,10 +1520,8 @@ class CompilationTimeCallback {
false, // success false, // success
native_module->liftoff_code_size(), // code_size_in_bytes native_module->liftoff_code_size(), // code_size_in_bytes
native_module->liftoff_bailout_count(), // liftoff_bailout_count native_module->liftoff_bailout_count(), // liftoff_bailout_count
duration.InMicroseconds(), // wall_clock_duration_in_us duration.InMicroseconds() // wall_clock_duration_in_us
FLAG_liftoff // cpu_time_duration_in_us };
? native_module->liftoff_cpu_duration()
: native_module->turbofan_cpu_duration()};
metrics_recorder_->DelayMainThreadEvent(event, context_id_); metrics_recorder_->DelayMainThreadEvent(event, context_id_);
} }
} }
...@@ -1926,12 +1919,10 @@ void AsyncCompileJob::FinishCompile(bool is_after_cache_hit) { ...@@ -1926,12 +1919,10 @@ void AsyncCompileJob::FinishCompile(bool is_after_cache_hit) {
is_after_deserialization, // deserialized is_after_deserialization, // deserialized
wasm_lazy_compilation_, // lazy wasm_lazy_compilation_, // lazy
!compilation_state->failed(), // success !compilation_state->failed(), // success
native_module_->turbofan_code_size(), // code_size_in_bytes native_module_->liftoff_code_size(), // code_size_in_bytes
native_module_->liftoff_bailout_count(), // liftoff_bailout_count native_module_->liftoff_bailout_count(), // liftoff_bailout_count
duration.InMicroseconds(), // wall_clock_duration_in_us duration.InMicroseconds() // wall_clock_duration_in_us
FLAG_liftoff // cpu_time_duration_in_us };
? native_module_->liftoff_cpu_duration()
: native_module_->turbofan_cpu_duration()};
isolate_->metrics_recorder()->DelayMainThreadEvent(event, context_id_); isolate_->metrics_recorder()->DelayMainThreadEvent(event, context_id_);
} }
} }
......
...@@ -2143,19 +2143,12 @@ ModuleResult DecodeWasmModule( ...@@ -2143,19 +2143,12 @@ ModuleResult DecodeWasmModule(
v8::metrics::WasmModuleDecoded metrics_event; v8::metrics::WasmModuleDecoded metrics_event;
base::ElapsedTimer timer; base::ElapsedTimer timer;
timer.Start(); timer.Start();
base::ThreadTicks thread_ticks = base::ThreadTicks::IsSupported()
? base::ThreadTicks::Now()
: base::ThreadTicks();
ModuleResult result = ModuleResult result =
decoder.DecodeModule(counters, allocator, verify_functions); decoder.DecodeModule(counters, allocator, verify_functions);
// Record event metrics. // Record event metrics.
metrics_event.wall_clock_duration_in_us = timer.Elapsed().InMicroseconds(); metrics_event.wall_clock_duration_in_us = timer.Elapsed().InMicroseconds();
timer.Stop(); timer.Stop();
if (!thread_ticks.IsNull()) {
metrics_event.cpu_duration_in_us =
(base::ThreadTicks::Now() - thread_ticks).InMicroseconds();
}
metrics_event.success = decoder.ok() && result.ok(); metrics_event.success = decoder.ok() && result.ok();
metrics_event.async = decoding_method == DecodingMethod::kAsync || metrics_event.async = decoding_method == DecodingMethod::kAsync ||
decoding_method == DecodingMethod::kAsyncStream; decoding_method == DecodingMethod::kAsyncStream;
......
...@@ -1498,21 +1498,6 @@ void NativeModule::SetWireBytes(OwnedVector<const uint8_t> wire_bytes) { ...@@ -1498,21 +1498,6 @@ void NativeModule::SetWireBytes(OwnedVector<const uint8_t> wire_bytes) {
} }
} }
void NativeModule::UpdateCPUDuration(WasmCompilationResult& result) {
if (result.for_debugging != ForDebugging::kNoDebugging) return;
DCHECK_NE(std::numeric_limits<size_t>::max(), result.cpu_duration);
if (result.requested_tier == ExecutionTier::kLiftoff) {
liftoff_cpu_duration_.fetch_add(result.cpu_duration,
std::memory_order::memory_order_relaxed);
} else if (result.requested_tier == ExecutionTier::kTurbofan) {
turbofan_cpu_duration_.fetch_add(result.cpu_duration,
std::memory_order::memory_order_relaxed);
}
#ifdef DEBUG
result.cpu_duration = std::numeric_limits<size_t>::max();
#endif
}
void NativeModule::TransferNewOwnedCodeLocked() const { void NativeModule::TransferNewOwnedCodeLocked() const {
// The caller holds the allocation mutex. // The caller holds the allocation mutex.
DCHECK(!allocation_mutex_.TryLock()); DCHECK(!allocation_mutex_.TryLock());
......
...@@ -631,8 +631,6 @@ class V8_EXPORT_PRIVATE NativeModule final { ...@@ -631,8 +631,6 @@ class V8_EXPORT_PRIVATE NativeModule final {
size_t liftoff_bailout_count() const { return liftoff_bailout_count_.load(); } size_t liftoff_bailout_count() const { return liftoff_bailout_count_.load(); }
size_t liftoff_code_size() const { return liftoff_code_size_.load(); } size_t liftoff_code_size() const { return liftoff_code_size_.load(); }
size_t turbofan_code_size() const { return turbofan_code_size_.load(); } size_t turbofan_code_size() const { return turbofan_code_size_.load(); }
size_t liftoff_cpu_duration() const { return liftoff_cpu_duration_.load(); }
size_t turbofan_cpu_duration() const { return turbofan_cpu_duration_.load(); }
WasmEngine* engine() const { return engine_; } WasmEngine* engine() const { return engine_; }
bool HasWireBytes() const { bool HasWireBytes() const {
...@@ -641,8 +639,6 @@ class V8_EXPORT_PRIVATE NativeModule final { ...@@ -641,8 +639,6 @@ class V8_EXPORT_PRIVATE NativeModule final {
} }
void SetWireBytes(OwnedVector<const uint8_t> wire_bytes); void SetWireBytes(OwnedVector<const uint8_t> wire_bytes);
void UpdateCPUDuration(WasmCompilationResult& result);
WasmCode* Lookup(Address) const; WasmCode* Lookup(Address) const;
WasmImportWrapperCache* import_wrapper_cache() const { WasmImportWrapperCache* import_wrapper_cache() const {
...@@ -857,8 +853,6 @@ class V8_EXPORT_PRIVATE NativeModule final { ...@@ -857,8 +853,6 @@ class V8_EXPORT_PRIVATE NativeModule final {
std::atomic<size_t> liftoff_bailout_count_{0}; std::atomic<size_t> liftoff_bailout_count_{0};
std::atomic<size_t> liftoff_code_size_{0}; std::atomic<size_t> liftoff_code_size_{0};
std::atomic<size_t> turbofan_code_size_{0}; std::atomic<size_t> turbofan_code_size_{0};
std::atomic<size_t> liftoff_cpu_duration_{0};
std::atomic<size_t> turbofan_cpu_duration_{0};
}; };
class V8_EXPORT_PRIVATE WasmCodeManager final { class V8_EXPORT_PRIVATE WasmCodeManager final {
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include "include/libplatform/libplatform.h" #include "include/libplatform/libplatform.h"
#include "include/v8-metrics.h" #include "include/v8-metrics.h"
#include "src/api/api-inl.h" #include "src/api/api-inl.h"
#include "src/base/platform/time.h"
#include "src/wasm/wasm-engine.h" #include "src/wasm/wasm-engine.h"
#include "src/wasm/wasm-module-builder.h" #include "src/wasm/wasm-module-builder.h"
#include "test/cctest/cctest.h" #include "test/cctest/cctest.h"
...@@ -272,9 +271,6 @@ COMPILE_TEST(TestEventMetrics) { ...@@ -272,9 +271,6 @@ COMPILE_TEST(TestEventMetrics) {
std::shared_ptr<MetricsRecorder> recorder = std::shared_ptr<MetricsRecorder> recorder =
std::make_shared<MetricsRecorder>(); std::make_shared<MetricsRecorder>();
reinterpret_cast<v8::Isolate*>(isolate)->SetMetricsRecorder(recorder); reinterpret_cast<v8::Isolate*>(isolate)->SetMetricsRecorder(recorder);
if (v8::base::ThreadTicks::IsSupported()) {
v8::base::ThreadTicks::WaitUntilInitialized();
}
TestSignatures sigs; TestSignatures sigs;
v8::internal::AccountingAllocator allocator; v8::internal::AccountingAllocator allocator;
...@@ -317,8 +313,6 @@ COMPILE_TEST(TestEventMetrics) { ...@@ -317,8 +313,6 @@ COMPILE_TEST(TestEventMetrics) {
recorder->module_decoded_.back().module_size_in_bytes); recorder->module_decoded_.back().module_size_in_bytes);
CHECK_EQ(1, recorder->module_decoded_.back().function_count); CHECK_EQ(1, recorder->module_decoded_.back().function_count);
CHECK_LE(0, recorder->module_decoded_.back().wall_clock_duration_in_us); CHECK_LE(0, recorder->module_decoded_.back().wall_clock_duration_in_us);
CHECK_IMPLIES(v8::base::ThreadTicks::IsSupported(),
recorder->module_decoded_.back().wall_clock_duration_in_us > 0);
CHECK_EQ(1, recorder->module_compiled_.size()); CHECK_EQ(1, recorder->module_compiled_.size());
CHECK(recorder->module_compiled_.back().success); CHECK(recorder->module_compiled_.back().success);
...@@ -339,12 +333,6 @@ COMPILE_TEST(TestEventMetrics) { ...@@ -339,12 +333,6 @@ COMPILE_TEST(TestEventMetrics) {
recorder->module_compiled_.back().code_size_in_bytes); recorder->module_compiled_.back().code_size_in_bytes);
CHECK_EQ(0, recorder->module_compiled_.back().liftoff_bailout_count); CHECK_EQ(0, recorder->module_compiled_.back().liftoff_bailout_count);
CHECK_LE(0, recorder->module_compiled_.back().wall_clock_duration_in_us); CHECK_LE(0, recorder->module_compiled_.back().wall_clock_duration_in_us);
CHECK_EQ(i::FLAG_liftoff ? native_module->liftoff_cpu_duration()
: native_module->turbofan_cpu_duration(),
recorder->module_compiled_.back().cpu_duration_in_us);
CHECK_IMPLIES(
v8::base::ThreadTicks::IsSupported() && !i::FLAG_wasm_test_streaming,
recorder->module_compiled_.back().cpu_duration_in_us > 0);
CHECK_EQ(1, recorder->module_instantiated_.size()); CHECK_EQ(1, recorder->module_instantiated_.size());
CHECK(recorder->module_instantiated_.back().success); CHECK(recorder->module_instantiated_.back().success);
...@@ -363,10 +351,6 @@ COMPILE_TEST(TestEventMetrics) { ...@@ -363,10 +351,6 @@ COMPILE_TEST(TestEventMetrics) {
CHECK_GE(native_module->committed_code_space(), CHECK_GE(native_module->committed_code_space(),
recorder->module_tiered_up_.back().code_size_in_bytes); recorder->module_tiered_up_.back().code_size_in_bytes);
CHECK_LE(0, recorder->module_tiered_up_.back().wall_clock_duration_in_us); CHECK_LE(0, recorder->module_tiered_up_.back().wall_clock_duration_in_us);
CHECK_EQ(native_module->turbofan_cpu_duration(),
recorder->module_tiered_up_.back().cpu_duration_in_us);
CHECK_IMPLIES(v8::base::ThreadTicks::IsSupported() && i::FLAG_wasm_tier_up,
recorder->module_tiered_up_.back().cpu_duration_in_us > 0);
} }
} // namespace wasm } // namespace wasm
......
...@@ -558,7 +558,6 @@ void WasmFunctionCompiler::Build(const byte* start, const byte* end) { ...@@ -558,7 +558,6 @@ void WasmFunctionCompiler::Build(const byte* start, const byte* end) {
isolate()->counters(), &unused_detected_features); isolate()->counters(), &unused_detected_features);
WasmCode* code = native_module->PublishCode( WasmCode* code = native_module->PublishCode(
native_module->AddCompiledCode(std::move(result))); native_module->AddCompiledCode(std::move(result)));
native_module->UpdateCPUDuration(result);
DCHECK_NOT_NULL(code); DCHECK_NOT_NULL(code);
DisallowGarbageCollection no_gc; DisallowGarbageCollection no_gc;
Script script = builder_->instance_object()->module_object().script(); Script script = builder_->instance_object()->module_object().script();
......
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