diff options
author | glider@chromium.org <glider@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-04 10:33:54 +0000 |
---|---|---|
committer | glider@chromium.org <glider@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-04 10:33:54 +0000 |
commit | 665aaca303c92a10a63047ed7ce893d7dab05386 (patch) | |
tree | ad196ed8981fdfd27fc8ac9c35d3ed06fde223e7 /base/metrics | |
parent | f6d7f2dcd287df23e4a7dd4529fb7a60c9ac0ab6 (diff) | |
download | chromium_src-665aaca303c92a10a63047ed7ce893d7dab05386.zip chromium_src-665aaca303c92a10a63047ed7ce893d7dab05386.tar.gz chromium_src-665aaca303c92a10a63047ed7ce893d7dab05386.tar.bz2 |
Use nobarrier atomics for platform-size lossy counters in base::HistogramSamples and base::SampleVector
This should not affect the performance, but will make it explicit that the counter values are expected to be read and written atomically.
This will also suppress the ThreadSanitizer v2 reports on these counters.
BUG=46840
R=jar@chromium.org
Review URL: https://codereview.chromium.org/23602005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221168 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/metrics')
-rw-r--r-- | base/metrics/histogram_base.h | 4 | ||||
-rw-r--r-- | base/metrics/histogram_samples.cc | 3 | ||||
-rw-r--r-- | base/metrics/sample_vector.cc | 3 |
3 files changed, 6 insertions, 4 deletions
diff --git a/base/metrics/histogram_base.h b/base/metrics/histogram_base.h index f5448e7..dba4395 100644 --- a/base/metrics/histogram_base.h +++ b/base/metrics/histogram_base.h @@ -50,8 +50,8 @@ BASE_EXPORT void DeserializeHistogramAndAddSamples(PickleIterator* iter); class BASE_EXPORT HistogramBase { public: - typedef int Sample; // Used for samples. - typedef int Count; // Used to count samples. + typedef int Sample; // Used for samples. + typedef subtle::Atomic32 Count; // Used to count samples. static const Sample kSampleType_MAX; // INT_MAX diff --git a/base/metrics/histogram_samples.cc b/base/metrics/histogram_samples.cc index 0e0eeb4..9f3dd6a 100644 --- a/base/metrics/histogram_samples.cc +++ b/base/metrics/histogram_samples.cc @@ -113,7 +113,8 @@ void HistogramSamples::IncreaseSum(int64 diff) { } void HistogramSamples::IncreaseRedundantCount(HistogramBase::Count diff) { - redundant_count_ += diff; + base::subtle::NoBarrier_Store(&redundant_count_, + base::subtle::NoBarrier_Load(&redundant_count_) + diff); } SampleCountIterator::~SampleCountIterator() {} diff --git a/base/metrics/sample_vector.cc b/base/metrics/sample_vector.cc index fe602ee..89233c7 100644 --- a/base/metrics/sample_vector.cc +++ b/base/metrics/sample_vector.cc @@ -24,7 +24,8 @@ SampleVector::~SampleVector() {} void SampleVector::Accumulate(Sample value, Count count) { size_t bucket_index = GetBucketIndex(value); - counts_[bucket_index] += count; + subtle::NoBarrier_Store(&counts_[bucket_index], + subtle::NoBarrier_Load(&counts_[bucket_index]) + count); IncreaseSum(count * value); IncreaseRedundantCount(count); } |