Commit bdbaed7e authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] Avoid double accounting for wasm memory reservations

Currently the total allocated address space is collected twice per Wasm
memory: Once on allocation, once on release. Recording it once provides
the same data.

R=titzer@chromium.org

Bug: v8:8975
Change-Id: I99719ecb44b14ce5da1be4a74291377f91f4038a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1514738Reviewed-by: 's avatarBen Titzer <titzer@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60164}
parent 67770d61
......@@ -214,7 +214,10 @@ void WasmMemoryTracker::RegisterAllocation(Isolate* isolate,
base::MutexGuard scope_lock(&mutex_);
allocated_address_space_ += allocation_length;
AddAddressSpaceSample(isolate);
// Report address space usage in MiB so the full range fits in an int on all
// platforms.
isolate->counters()->wasm_address_space_usage_mb()->AddSample(
static_cast<int>(allocated_address_space_ / MB));
allocations_.emplace(buffer_start,
AllocationData{allocation_base, allocation_length,
......@@ -231,10 +234,6 @@ WasmMemoryTracker::AllocationData WasmMemoryTracker::ReleaseAllocation_Locked(
DCHECK_LE(num_bytes, allocated_address_space_);
reserved_address_space_ -= num_bytes;
allocated_address_space_ -= num_bytes;
// ReleaseAllocation might be called with a nullptr as isolate if the
// embedder is releasing the allocation and not a specific isolate. This
// happens if the allocation was shared between multiple isolates (threads).
if (isolate) AddAddressSpaceSample(isolate);
AllocationData allocation_data = find_result->second;
allocations_.erase(find_result);
......@@ -565,13 +564,6 @@ void WasmMemoryTracker::DeleteSharedMemoryObjectsOnIsolate(Isolate* isolate) {
}
}
void WasmMemoryTracker::AddAddressSpaceSample(Isolate* isolate) {
// Report address space usage in MiB so the full range fits in an int on all
// platforms.
isolate->counters()->wasm_address_space_usage_mb()->AddSample(
static_cast<int>(allocated_address_space_ >> 20));
}
Handle<JSArrayBuffer> SetupArrayBuffer(Isolate* isolate, void* backing_store,
size_t size, bool is_external,
SharedFlag shared) {
......
......@@ -214,7 +214,6 @@ class WasmMemoryTracker {
AllocationData ReleaseAllocation_Locked(Isolate* isolate,
const void* buffer_start);
void AddAddressSpaceSample(Isolate* isolate);
// Clients use a two-part process. First they "reserve" the address space,
// which signifies an intent to actually allocate it. This determines whether
// doing the allocation would put us over our limit. Once there is a
......
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