-
kschimpf authored
After discussion with Chrome reviewers for UMA, it was decided that we would report array buffer allocation sizes in megabytes (not the log). They also wanted to wait until there is proof that small array buffer allocations would flood the histogram. Hence, all allocation sizes are sampled. There were several ways we could have added the notion of megabyte samples to V8 code. None of them are a great fit. This code simply provides a local function within the code that needs it. Other possible solutions but rejected were: a) Use a subclass of histogram to collect data at the megabyte level. It has it's own Add() method that converts the size from bytes to megabytes, and then call the generic add method AddSample(). This solution appears to follow the conventions of subclasses of class Histogram. b) Use Chrome macros - Rejected because it involves changing the counter representation of V8. c) Add a method AddMegabyteSample() to base class Histogram. Rejected because it may get confusing if a lot of different measures are added the the base class of histograms. d) Make method AddSample() virtual and override in the derived class. Rejected in that sampling is supposed to be fast, and adding a virtual call may be breaking that contract. d) Do not add a derived class. Rather just do the conversions at the call sites. Rejected because this duplicates code, and also makes it hard to change assumptions on how to calculate. For Chromes UMA changes see: CL: https://codereview.chromium.org/2795463002 BUG=chromium:704922 R=bbudge@chromium.org,bradnelson@chromium.org,mtrofin@chromium.org Review-Url: https://codereview.chromium.org/2795763002 Cr-Commit-Position: refs/heads/master@{#44388}
510abe73