Commit 547e857b authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[wasm] Remove samples for obsolete histograms

The histograms were removed from chrome. This CL cleans up the V8 code
to stop reporting samples.

R=ahaas@chromium.org

Bug: chromium:1053285
Change-Id: I7c6ff36ac9bb5d86e81e5f36849903a95a8ed618
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2083478Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66553}
parent 9245e3b4
......@@ -132,13 +132,11 @@ void Report(Handle<Script> script, int position, Vector<const char> text,
// Hook to report successful execution of {AsmJs::CompileAsmViaWasm} phase.
void ReportCompilationSuccess(Handle<Script> script, int position,
double translate_time, double compile_time,
size_t module_size) {
double compile_time, size_t module_size) {
if (FLAG_suppress_asm_messages || !FLAG_trace_asm_time) return;
EmbeddedVector<char, 100> text;
int length = SNPrintF(
text, "success, asm->wasm: %0.3f ms, compile: %0.3f ms, %zu bytes",
translate_time, compile_time, module_size);
int length = SNPrintF(text, "success, compile time %0.3f ms, %zu bytes",
compile_time, module_size);
CHECK_NE(-1, length);
text.Truncate(length);
Report(script, position, text, MessageTemplate::kAsmJsCompiled,
......@@ -195,11 +193,8 @@ class AsmJsCompilationJob final : public UnoptimizedCompilationJob {
compilation_info_(&zone_, parse_info, literal),
module_(nullptr),
asm_offsets_(nullptr),
translate_time_(0),
compile_time_(0),
module_source_size_(0),
translate_time_micro_(0),
translate_zone_size_(0) {}
module_source_size_(0) {}
protected:
Status ExecuteJobImpl() final;
......@@ -216,21 +211,14 @@ class AsmJsCompilationJob final : public UnoptimizedCompilationJob {
wasm::ZoneBuffer* asm_offsets_;
wasm::AsmJsParser::StdlibSet stdlib_uses_;
double translate_time_; // Time (milliseconds) taken to execute step [1].
double compile_time_; // Time (milliseconds) taken to execute step [2].
int module_source_size_; // Module source size in bytes.
int64_t translate_time_micro_; // Time (microseconds) taken to translate.
size_t translate_zone_size_;
DISALLOW_COPY_AND_ASSIGN(AsmJsCompilationJob);
};
UnoptimizedCompilationJob::Status AsmJsCompilationJob::ExecuteJobImpl() {
// Step 1: Translate asm.js module to WebAssembly module.
size_t compile_zone_start = compilation_info()->zone()->allocation_size();
base::ElapsedTimer translate_timer;
translate_timer.Start();
Zone* compile_zone = compilation_info()->zone();
Zone translate_zone(allocator_, ZONE_NAME);
......@@ -254,19 +242,8 @@ UnoptimizedCompilationJob::Status AsmJsCompilationJob::ExecuteJobImpl() {
parser.module_builder()->WriteAsmJsOffsetTable(asm_offsets_);
stdlib_uses_ = *parser.stdlib_uses();
size_t compile_zone_size =
compilation_info()->zone()->allocation_size() - compile_zone_start;
translate_zone_size_ = translate_zone.allocation_size();
translate_time_ = translate_timer.Elapsed().InMillisecondsF();
translate_time_micro_ = translate_timer.Elapsed().InMicroseconds();
module_source_size_ = compilation_info()->literal()->end_position() -
compilation_info()->literal()->start_position();
if (FLAG_trace_asm_parser) {
PrintF(
"[asm.js translation successful: time=%0.3fms, "
"translate_zone=%zuKB, compile_zone+=%zuKB]\n",
translate_time_, translate_zone_size_ / KB, compile_zone_size / KB);
}
return SUCCEEDED;
}
......@@ -297,26 +274,12 @@ UnoptimizedCompilationJob::Status AsmJsCompilationJob::FinalizeJobImpl(
RecordHistograms(isolate);
ReportCompilationSuccess(handle(Script::cast(shared_info->script()), isolate),
compilation_info()->literal()->position(),
translate_time_, compile_time_, module_->size());
compile_time_, module_->size());
return SUCCEEDED;
}
void AsmJsCompilationJob::RecordHistograms(Isolate* isolate) {
Counters* counters = isolate->counters();
counters->asm_wasm_translation_time()->AddSample(
static_cast<int>(translate_time_micro_));
counters->asm_wasm_translation_peak_memory_bytes()->AddSample(
static_cast<int>(translate_zone_size_));
counters->asm_module_size_bytes()->AddSample(module_source_size_);
// translation_throughput is not exact (assumes MB == 1000000). But that is ok
// since the metric is stored in buckets that lose some precision anyways.
int translation_throughput =
translate_time_micro_ != 0
? static_cast<int>(static_cast<int64_t>(module_source_size_) /
translate_time_micro_)
: 0;
counters->asm_wasm_translation_throughput()->AddSample(
translation_throughput);
isolate->counters()->asm_module_size_bytes()->AddSample(module_source_size_);
}
std::unique_ptr<UnoptimizedCompilationJob> AsmJs::NewCompilationJob(
......
......@@ -55,19 +55,9 @@ namespace internal {
51) \
HR(wasm_wasm_max_mem_pages_count, V8.WasmMaxMemPagesCount.wasm, 1, 2 << 16, \
51) \
HR(wasm_decode_asm_module_peak_memory_bytes, \
V8.WasmDecodeModulePeakMemoryBytes.asm, 1, GB, 51) \
HR(wasm_decode_wasm_module_peak_memory_bytes, \
V8.WasmDecodeModulePeakMemoryBytes.wasm, 1, GB, 51) \
HR(asm_wasm_translation_peak_memory_bytes, \
V8.AsmWasmTranslationPeakMemoryBytes, 1, GB, 51) \
HR(wasm_compile_function_peak_memory_bytes, \
V8.WasmCompileFunctionPeakMemoryBytes, 1, GB, 51) \
HR(asm_module_size_bytes, V8.AsmModuleSizeBytes, 1, GB, 51) \
HR(asm_wasm_translation_throughput, V8.AsmWasmTranslationThroughput, 1, 100, \
20) \
HR(wasm_lazy_compilation_throughput, V8.WasmLazyCompilationThroughput, 1, \
10000, 50) \
HR(compile_script_cache_behaviour, V8.CompileScript.CacheBehaviour, 0, 20, \
21) \
HR(wasm_memory_allocation_result, V8.WasmMemoryAllocationResult, 0, 3, 4) \
......@@ -81,8 +71,6 @@ namespace internal {
/* code size per module after top-tier compilation */ \
HR(wasm_module_code_size_mb_after_top_tier, V8.WasmModuleCodeSizeTopTierMiB, \
0, 1024, 64) \
/* freed code size per module, collected on GC */ \
HR(wasm_module_freed_code_size_mb, V8.WasmModuleCodeSizeFreed, 0, 1024, 64) \
/* percent of freed code size per module, collected on GC */ \
HR(wasm_module_freed_code_size_percent, V8.WasmModuleCodeSizePercentFreed, \
0, 100, 32) \
......@@ -124,12 +112,7 @@ namespace internal {
/* Total compilation time incl. caching/parsing */ \
HT(compile_script, V8.CompileScriptMicroSeconds, 1000000, MICROSECOND) \
/* Total JavaScript execution time (including callbacks and runtime calls */ \
HT(execute, V8.Execute, 1000000, MICROSECOND) \
/* Asm/Wasm */ \
HT(asm_wasm_translation_time, V8.AsmWasmTranslationMicroSeconds, 1000000, \
MICROSECOND) \
HT(wasm_lazy_compilation_time, V8.WasmLazyCompilationMicroSeconds, 1000000, \
MICROSECOND)
HT(execute, V8.Execute, 1000000, MICROSECOND)
#define TIMED_HISTOGRAM_LIST(HT) \
/* Timer histograms, thread safe: HT(name, caption, max, unit) */ \
......@@ -175,14 +158,6 @@ namespace internal {
HT(turbofan_osr_total_time, \
V8.TurboFanOptimizeForOnStackReplacementTotalTime, 10000000, MICROSECOND) \
/* Wasm timers. */ \
HT(wasm_decode_asm_module_time, V8.WasmDecodeModuleMicroSeconds.asm, \
1000000, MICROSECOND) \
HT(wasm_decode_wasm_module_time, V8.WasmDecodeModuleMicroSeconds.wasm, \
1000000, MICROSECOND) \
HT(wasm_decode_asm_function_time, V8.WasmDecodeFunctionMicroSeconds.asm, \
1000000, MICROSECOND) \
HT(wasm_decode_wasm_function_time, V8.WasmDecodeFunctionMicroSeconds.wasm, \
1000000, MICROSECOND) \
HT(wasm_compile_asm_module_time, V8.WasmCompileModuleMicroSeconds.asm, \
10000000, MICROSECOND) \
HT(wasm_compile_wasm_module_time, V8.WasmCompileModuleMicroSeconds.wasm, \
......@@ -205,7 +180,6 @@ namespace internal {
V8.WasmInstantiateModuleMicroSeconds.wasm, 10000000, MICROSECOND) \
HT(wasm_instantiate_asm_module_time, \
V8.WasmInstantiateModuleMicroSeconds.asm, 10000000, MICROSECOND) \
HT(wasm_code_gc_time, V8.WasmCodeGCTime, 1000000, MICROSECOND) \
/* Total compilation time incl. caching/parsing for various cache states. */ \
HT(compile_script_with_produce_cache, \
V8.CompileScriptMicroSeconds.ProduceCache, 1000000, MICROSECOND) \
......
......@@ -832,13 +832,8 @@ DecodeResult ValidateSingleFunction(const WasmModule* module, int func_index,
FunctionBody body{func->sig, func->code.offset(), code.begin(), code.end()};
DecodeResult result;
auto time_counter =
SELECT_WASM_COUNTER(counters, module->origin, wasm_decode, function_time);
TimedHistogramScope wasm_decode_function_time_scope(time_counter);
WasmFeatures detected;
result = VerifyWasmCode(allocator, enabled_features, module, &detected, body);
return result;
return VerifyWasmCode(allocator, enabled_features, module, &detected, body);
}
enum OnlyLazyFunctions : bool {
......@@ -890,12 +885,8 @@ bool CompileLazy(Isolate* isolate, NativeModule* native_module,
Counters* counters = isolate->counters();
DCHECK(!native_module->lazy_compile_frozen());
HistogramTimerScope lazy_time_scope(counters->wasm_lazy_compilation_time());
NativeModuleModificationScope native_module_modification_scope(native_module);
base::ElapsedTimer compilation_timer;
compilation_timer.Start();
TRACE_LAZY("Compiling wasm-function#%d.\n", func_index);
CompilationStateImpl* compilation_state =
......@@ -935,14 +926,8 @@ bool CompileLazy(Isolate* isolate, NativeModule* native_module,
if (WasmCode::ShouldBeLogged(isolate)) code->LogCode(isolate);
double func_kb = 1e-3 * func->code.length();
double compilation_seconds = compilation_timer.Elapsed().InSecondsF();
counters->wasm_lazily_compiled_functions()->Increment();
int throughput_sample = static_cast<int>(func_kb / compilation_seconds);
counters->wasm_lazy_compilation_throughput()->AddSample(throughput_sample);
const bool lazy_module = IsLazyModule(module);
if (GetCompileStrategy(module, enabled_features, func_index, lazy_module) ==
CompileStrategy::kLazy &&
......
......@@ -1409,16 +1409,9 @@ class ModuleDecoderImpl : public Decoder {
start_ + GetBufferRelativeOffset(function->code.offset()),
start_ + GetBufferRelativeOffset(function->code.end_offset())};
DecodeResult result;
{
auto time_counter = SELECT_WASM_COUNTER(GetCounters(), origin_,
wasm_decode, function_time);
TimedHistogramScope wasm_decode_function_time_scope(time_counter);
WasmFeatures unused_detected_features = WasmFeatures::None();
result = VerifyWasmCode(allocator, enabled_features_, module,
&unused_detected_features, body);
}
WasmFeatures unused_detected_features = WasmFeatures::None();
DecodeResult result = VerifyWasmCode(allocator, enabled_features_, module,
&unused_detected_features, body);
// If the decode failed and this is the first error, set error code and
// location.
......@@ -1987,9 +1980,6 @@ ModuleResult DecodeWasmModule(const WasmFeatures& enabled,
bool verify_functions, ModuleOrigin origin,
Counters* counters,
AccountingAllocator* allocator) {
auto counter =
SELECT_WASM_COUNTER(counters, origin, wasm_decode, module_time);
TimedHistogramScope wasm_decode_module_time_scope(counter);
size_t size = module_end - module_start;
CHECK_LE(module_start, module_end);
if (size >= kV8MaxWasmModuleSize) {
......@@ -2003,19 +1993,7 @@ ModuleResult DecodeWasmModule(const WasmFeatures& enabled,
// Signatures are stored in zone memory, which have the same lifetime
// as the {module}.
ModuleDecoderImpl decoder(enabled, module_start, module_end, origin);
ModuleResult result =
decoder.DecodeModule(counters, allocator, verify_functions);
// TODO(bradnelson): Improve histogram handling of size_t.
// TODO(titzer): this isn't accurate, since it doesn't count the data
// allocated on the C++ heap.
// https://bugs.chromium.org/p/chromium/issues/detail?id=657320
if (result.ok()) {
auto peak_counter = SELECT_WASM_COUNTER(counters, origin, wasm_decode,
module_peak_memory_bytes);
peak_counter->AddSample(
static_cast<int>(result.value()->signature_zone->allocation_size()));
}
return result;
return decoder.DecodeModule(counters, allocator, verify_functions);
}
ModuleDecoder::ModuleDecoder(const WasmFeatures& enabled)
......
......@@ -1743,8 +1743,6 @@ void NativeModule::SampleCodeSize(
if (generated_size >= 2 * MB && module()->origin == kWasmOrigin) {
size_t freed_size = code_allocator_.freed_code_size();
DCHECK_LE(freed_size, generated_size);
int total_freed_mb = static_cast<int>(freed_size / MB);
counters->wasm_module_freed_code_size_mb()->AddSample(total_freed_mb);
int freed_percent = static_cast<int>(100 * freed_size / generated_size);
counters->wasm_module_freed_code_size_percent()->AddSample(
freed_percent);
......
......@@ -733,15 +733,6 @@ void WasmEngine::DeleteCompileJobsOnIsolate(Isolate* isolate) {
}
}
namespace {
int GetGCTimeMicros(base::TimeTicks start) {
DCHECK(!start.IsNull());
int64_t duration_us = (base::TimeTicks::Now() - start).InMicroseconds();
return static_cast<int>(
std::min(std::max(int64_t{0}, duration_us), int64_t{kMaxInt}));
}
} // namespace
void WasmEngine::AddIsolate(Isolate* isolate) {
base::MutexGuard guard(&mutex_);
DCHECK_EQ(0, isolates_.count(isolate));
......@@ -761,13 +752,6 @@ void WasmEngine::AddIsolate(Isolate* isolate) {
for (auto* native_module : engine->isolates_[isolate]->native_modules) {
native_module->SampleCodeSize(counters, NativeModule::kSampling);
}
// If there is an ongoing code GC, sample its time here. This will record
// samples for very long-running or never ending GCs.
if (engine->current_gc_info_ &&
!engine->current_gc_info_->start_time.IsNull()) {
isolate->counters()->wasm_code_gc_time()->AddSample(
GetGCTimeMicros(engine->current_gc_info_->start_time));
}
};
isolate->heap()->AddGCEpilogueCallback(callback, v8::kGCTypeMarkSweepCompact,
nullptr);
......@@ -1096,9 +1080,6 @@ void WasmEngine::TriggerGC(int8_t gc_sequence_index) {
DCHECK(FLAG_wasm_code_gc);
new_potentially_dead_code_size_ = 0;
current_gc_info_.reset(new CurrentGCInfo(gc_sequence_index));
if (base::TimeTicks::IsHighResolution()) {
current_gc_info_->start_time = base::TimeTicks::Now();
}
// Add all potentially dead code to this GC, and trigger a GC task in each
// isolate.
for (auto& entry : native_modules_) {
......@@ -1160,16 +1141,8 @@ void WasmEngine::PotentiallyFinishCurrentGC() {
FreeDeadCodeLocked(dead_code);
int duration_us = 0;
if (!current_gc_info_->start_time.IsNull()) {
duration_us = GetGCTimeMicros(current_gc_info_->start_time);
for (auto& entry : isolates_) {
entry.second->async_counters->wasm_code_gc_time()->AddSample(duration_us);
}
}
TRACE_CODE_GC("Took %d us; found %zu dead code objects, freed %zu.\n",
duration_us, current_gc_info_->dead_code.size(), num_freed);
TRACE_CODE_GC("Found %zu dead code objects, freed %zu.\n",
current_gc_info_->dead_code.size(), num_freed);
USE(num_freed);
int8_t next_gc_sequence_index = current_gc_info_->next_gc_sequence_index;
......
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