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

Unified Diff: base/metrics/histogram.cc

Issue 2898953007: Disallow non-sparse histograms with too many buckets. (Closed)
Patch Set: 10002 Created 3 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/histogram.cc
diff --git a/base/metrics/histogram.cc b/base/metrics/histogram.cc
index 09f0bbb67131e84417f8493971f52aa6603b06af..1f6a955f86637ae0942e248dbb791179d305e7e7 100644
--- a/base/metrics/histogram.cc
+++ b/base/metrics/histogram.cc
@@ -400,6 +400,13 @@ bool Histogram::InspectConstructionArguments(const std::string& name,
check_okay = false;
*bucket_count = 3;
}
+ // Very high bucket counts are wasteful. Use a sparse histogram instead.
+ // Value of 10002 equals a user-supplied value of 10k + 2 overflow buckets.
+ constexpr uint32_t kMaxBucketCount = 10002;
bcwhite 2017/05/25 19:21:41 Even 10k sounds really, really large.
Alexei Svitkine (slow) 2017/05/25 19:24:04 Yeah agreed. There was a unit test that was using
+ if (*bucket_count > kMaxBucketCount) {
+ check_okay = false;
+ *bucket_count = kMaxBucketCount;
+ }
if (*bucket_count > static_cast<uint32_t>(*maximum - *minimum + 2)) {
check_okay = false;
*bucket_count = static_cast<uint32_t>(*maximum - *minimum + 2);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698