Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(322)

Unified Diff: src/objects.cc

Issue 2792623002: Track large array buffer allocations. (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/counters.h ('K') | « src/counters.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index fe386ae12723afe650cdeae7ecefed1753a18ea8..1df792d4435caf5623e08e1b01e91f04f63e2d01 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -19463,6 +19463,20 @@ void JSArrayBuffer::Setup(Handle<JSArrayBuffer> array_buffer, Isolate* isolate,
}
}
+namespace {
+
+template <class T>
+int log2Value(T value) {
bbudge 2017/03/31 19:01:18 Rather than roll your own, you could use the funct
kschimpf 2017/03/31 19:31:52 Thanks for the pointer. I agree that I shouldn't r
+ int count = 0;
+ T base = 0;
+ while (value > base) {
+ ++count;
+ value >>= 1;
+ }
+ return count;
+}
+
+} // namespace
bool JSArrayBuffer::SetupAllocatingData(Handle<JSArrayBuffer> array_buffer,
Isolate* isolate,
@@ -19473,6 +19487,10 @@ bool JSArrayBuffer::SetupAllocatingData(Handle<JSArrayBuffer> array_buffer,
// Prevent creating array buffers when serializing.
DCHECK(!isolate->serializer_enabled());
if (allocated_length != 0) {
+ constexpr size_t MinBigAllocation = 1 << 20;
bbudge 2017/03/31 19:01:18 nit: convention is to prefix 'k' to constants
kschimpf 2017/03/31 19:31:52 Good point. I suffer from spending too many years
+ if (allocated_length >= MinBigAllocation)
+ isolate->counters()->big_array_buffer_allocations()->AddSample(
+ log2Value(allocated_length));
if (initialize) {
data = isolate->array_buffer_allocator()->Allocate(allocated_length);
} else {
« src/counters.h ('K') | « src/counters.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698