Commit 0c5f5a3a authored by kschimpf's avatar kschimpf Committed by Commit bot

Track large array buffer allocations.

Adds a counter for large array buffers. Used to give an indication of
how common large array buffers are allocated in V8.

For the moment, we assume a 1Mb cutoff for the notion of large array
buffers.  We also use log2(length) to cleanly bucket sizes into a
histogram.

BUG=chromium:704922
R=bbudge@chromium.org,bradnelson@chromium.org,mtrofin@chromium.org

Review-Url: https://codereview.chromium.org/2792623002
Cr-Commit-Position: refs/heads/master@{#44317}
parent 2de2840f
......@@ -928,7 +928,8 @@ class RuntimeCallTimerScope {
HR(wasm_functions_per_asm_module, V8.WasmFunctionsPerModule.asm, 1, 100000, \
51) \
HR(wasm_functions_per_wasm_module, V8.WasmFunctionsPerModule.wasm, 1, \
100000, 51)
100000, 51) \
HR(array_buffer_big_allocations, V8.ArrayBufferBigAllocations, 1, 32, 32)
#define HISTOGRAM_TIMER_LIST(HT) \
/* Garbage collection timers. */ \
......
......@@ -19473,6 +19473,12 @@ bool JSArrayBuffer::SetupAllocatingData(Handle<JSArrayBuffer> array_buffer,
// Prevent creating array buffers when serializing.
DCHECK(!isolate->serializer_enabled());
if (allocated_length != 0) {
constexpr size_t kMinBigAllocation = 1 << 20;
if (allocated_length >= kMinBigAllocation) {
isolate->counters()->array_buffer_big_allocations()->AddSample(
sizeof(uint64_t) * kBitsPerByte -
base::bits::CountLeadingZeros64(allocated_length));
}
if (initialize) {
data = isolate->array_buffer_allocator()->Allocate(allocated_length);
} else {
......
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