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

Unified Diff: base/metrics/bucket_ranges.h

Issue 2794073002: De-duplicate ranges information in persistent memory. (Closed)
Patch Set: addressed final review comments Created 3 years, 8 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 | base/metrics/persistent_histogram_allocator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/bucket_ranges.h
diff --git a/base/metrics/bucket_ranges.h b/base/metrics/bucket_ranges.h
index c356195ba78ca2716897463b576f73a26bbe9b70..db82e552b3ac5c193ffbed00e7c195008dd15681 100644
--- a/base/metrics/bucket_ranges.h
+++ b/base/metrics/bucket_ranges.h
@@ -24,6 +24,7 @@
#include <limits.h>
+#include "base/atomicops.h"
#include "base/base_export.h"
#include "base/macros.h"
#include "base/metrics/histogram_base.h"
@@ -58,6 +59,17 @@ class BASE_EXPORT BucketRanges {
// Return true iff |other| object has same ranges_ as |this| object's ranges_.
bool Equals(const BucketRanges* other) const;
+ // Set and get a reference into persistent memory where this bucket data
+ // can be found (and re-used). These calls are internally atomic with no
+ // safety against overwriting an existing value since though it is wasteful
+ // to have multiple identical persistent records, it is still safe.
+ void set_persistent_reference(uint32_t ref) const {
+ subtle::NoBarrier_Store(&persistent_reference_, ref);
+ }
+ uint32_t persistent_reference() const {
+ return subtle::NoBarrier_Load(&persistent_reference_);
+ }
+
private:
// A monotonically increasing list of values which determine which bucket to
// put a sample into. For each index, show the smallest sample that can be
@@ -71,6 +83,12 @@ class BASE_EXPORT BucketRanges {
// noise on UMA dashboard.
uint32_t checksum_;
+ // A reference into a global PersistentMemoryAllocator where the ranges
+ // information is stored. This allows for the record to be created once and
+ // re-used simply by having all histograms with the same ranges use the
+ // same reference.
+ mutable subtle::Atomic32 persistent_reference_ = 0;
+
DISALLOW_COPY_AND_ASSIGN(BucketRanges);
};
« no previous file with comments | « no previous file | base/metrics/persistent_histogram_allocator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698