Commit 710b88ff authored by Andreas Haas's avatar Andreas Haas Committed by V8 LUCI CQ

[wasm] Add histogram for deserialization time

At the moment deserialization happens synchronously on the main thread.
This is fine at the moment because deserialization is fast. However,
future refactorings may affect deserialization time, and may force us
to deserialize in the background. This CL adds a timer to monitor
deserialization time, so that we get a signal if deserialization time
regresses.

R=clemensb@chromium.org

Bug: v8:11862
Change-Id: I18b52c19106b92158cd986492926a24d0d57e6ba
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2966389Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#75218}
parent 863a2d6c
......@@ -186,6 +186,8 @@ namespace internal {
V8.WasmCompileModuleStreamingMicroSeconds, 100000000, MICROSECOND) \
HT(wasm_streaming_finish_wasm_module_time, \
V8.WasmFinishModuleStreamingMicroSeconds, 100000000, MICROSECOND) \
HT(wasm_deserialization_time, V8.WasmDeserializationTimeMicroSeconds, \
100000000, MICROSECOND) \
HT(wasm_tier_up_module_time, V8.WasmTierUpModuleMicroSeconds, 100000000, \
MICROSECOND) \
HT(wasm_compile_asm_function_time, V8.WasmCompileFunctionMicroSeconds.asm, \
......
......@@ -2768,9 +2768,31 @@ void AsyncStreamingProcessor::OnAbort() {
job_->Abort();
}
namespace {
class DeserializationTimeScope {
public:
explicit DeserializationTimeScope(TimedHistogram* counter)
: counter_(counter), start_(base::TimeTicks::Now()) {}
~DeserializationTimeScope() {
if (base::TimeTicks::IsHighResolution()) {
base::TimeDelta duration = base::TimeTicks::Now() - start_;
int duration_usecs = static_cast<int>(duration.InMicroseconds());
counter_->AddSample(duration_usecs);
}
}
private:
TimedHistogram* counter_;
base::TimeTicks start_;
};
} // namespace
bool AsyncStreamingProcessor::Deserialize(Vector<const uint8_t> module_bytes,
Vector<const uint8_t> wire_bytes) {
TRACE_EVENT0("v8.wasm", "wasm.Deserialize");
DeserializationTimeScope time_scope(
job_->isolate()->counters()->wasm_deserialization_time());
// DeserializeNativeModule and FinishCompile assume that they are executed in
// a HandleScope, and that a context is set on the isolate.
HandleScope scope(job_->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