summaryrefslogtreecommitdiffstats
path: root/net/disk_cache/blockfile/histogram_macros.h
diff options
context:
space:
mode:
authorbratell@opera.com <bratell@opera.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-18 15:27:37 +0000
committerbratell@opera.com <bratell@opera.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-18 15:27:37 +0000
commit64a1962967e206643d998fbad39fd0e218acb235 (patch)
tree2e0d7f8df807e296be91964d7b15f5cf2495520b /net/disk_cache/blockfile/histogram_macros.h
parentf393b9d67e9526dd00fd07bf49ba35944f4f15b1 (diff)
downloadchromium_src-64a1962967e206643d998fbad39fd0e218acb235.zip
chromium_src-64a1962967e206643d998fbad39fd0e218acb235.tar.gz
chromium_src-64a1962967e206643d998fbad39fd0e218acb235.tar.bz2
Put histogram code in disk_cache on a diet.
The CACHE_UMA macro expanded wildly and with all the static variables in all blocks it was impossible for the compiler to shrink it. This removes the static variables (for a minor performance hit) to save 75% of the size of BackendImpl::ReportStats() and other changes elsewhere. Examples (sorry, don't have data for symbols smaller than 6 KB so not exact): disk_cache::BackendImpl::ReportStats() 55423 bytes -> 9788 bytes disk_cache::BackendImpl::FirstEviction() 21361 bytes -> < 6 KB disk_cache::BackendImpl::OpenEntryImpl: 16381 bytes -> < 6 KB disk_cache::EntryImpl::ReportIOTime: 14626 bytes -> < 6 KB disk_cache::Eviction::ReportListStats: 10099 bytes -> < 6 KB disk_cache::Eviction::TrimCacheV2: 7820 bytes -> < 6 KB disk_cache::Eviction::TrimCache: 7095 bytes -> < 6 KB In total my stripped Linux x64 Release content_shell binary shrinks by 132 KB with this change (0.25%). BUG=352555 R=gavinp@chromium.org Review URL: https://codereview.chromium.org/196383016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@257637 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache/blockfile/histogram_macros.h')
-rw-r--r--net/disk_cache/blockfile/histogram_macros.h31
1 files changed, 7 insertions, 24 deletions
diff --git a/net/disk_cache/blockfile/histogram_macros.h b/net/disk_cache/blockfile/histogram_macros.h
index a5d6f56..ecffc8f 100644
--- a/net/disk_cache/blockfile/histogram_macros.h
+++ b/net/disk_cache/blockfile/histogram_macros.h
@@ -14,16 +14,11 @@
// -----------------------------------------------------------------------------
// These histograms follow the definition of UMA_HISTOGRAMN_XXX except that
-// whenever the name changes (the experiment group changes), the histrogram
-// object is re-created.
-// Note: These macros are only run on one thread, so the declarations of
-// |counter| was made static (i.e., there will be no race for reinitialization).
+// the counter is not cached locally.
#define CACHE_HISTOGRAM_CUSTOM_COUNTS(name, sample, min, max, bucket_count) \
do { \
- static base::HistogramBase* counter(NULL); \
- if (!counter || name != counter->histogram_name()) \
- counter = base::Histogram::FactoryGet( \
+ base::HistogramBase* counter = base::Histogram::FactoryGet( \
name, min, max, bucket_count, \
base::Histogram::kUmaTargetedHistogramFlag); \
counter->Add(sample); \
@@ -40,9 +35,7 @@
#define CACHE_HISTOGRAM_CUSTOM_TIMES(name, sample, min, max, bucket_count) \
do { \
- static base::HistogramBase* counter(NULL); \
- if (!counter || name != counter->histogram_name()) \
- counter = base::Histogram::FactoryTimeGet( \
+ base::HistogramBase* counter = base::Histogram::FactoryTimeGet( \
name, min, max, bucket_count, \
base::Histogram::kUmaTargetedHistogramFlag); \
counter->AddTime(sample); \
@@ -53,9 +46,7 @@
base::TimeDelta::FromSeconds(10), 50)
#define CACHE_HISTOGRAM_ENUMERATION(name, sample, boundary_value) do { \
- static base::HistogramBase* counter(NULL); \
- if (!counter || name != counter->histogram_name()) \
- counter = base::LinearHistogram::FactoryGet( \
+ base::HistogramBase* counter = base::LinearHistogram::FactoryGet( \
name, 1, boundary_value, boundary_value + 1, \
base::Histogram::kUmaTargetedHistogramFlag); \
counter->Add(sample); \
@@ -98,24 +89,16 @@
const std::string my_name =\
CACHE_UMA_BACKEND_IMPL_OBJ->HistogramName(name, experiment);\
switch (CACHE_UMA_BACKEND_IMPL_OBJ->cache_type()) {\
+ default:\
+ NOTREACHED();\
+ /* Fall-through. */\
case net::DISK_CACHE:\
- CACHE_HISTOGRAM_##type(my_name.data(), sample);\
- break;\
case net::MEDIA_CACHE:\
- CACHE_HISTOGRAM_##type(my_name.data(), sample);\
- break;\
case net::APP_CACHE:\
- CACHE_HISTOGRAM_##type(my_name.data(), sample);\
- break;\
case net::SHADER_CACHE:\
- CACHE_HISTOGRAM_##type(my_name.data(), sample);\
- break;\
case net::PNACL_CACHE:\
CACHE_HISTOGRAM_##type(my_name.data(), sample);\
break;\
- default:\
- NOTREACHED();\
- break;\
}\
}