Chromium Code Reviews| Index: net/disk_cache/blockfile/histogram_macros.h |
| diff --git a/net/disk_cache/blockfile/histogram_macros.h b/net/disk_cache/blockfile/histogram_macros.h |
| index a5d6f56f5c10ca888b78c97e5c4cb8ac6793d24b..be8a98fc9efe32b68b94d554efcd9554cdad760f 100644 |
| --- a/net/disk_cache/blockfile/histogram_macros.h |
| +++ b/net/disk_cache/blockfile/histogram_macros.h |
| @@ -14,16 +14,16 @@ |
| // ----------------------------------------------------------------------------- |
| // 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. |
| +// the counter is not cached locally. |
| // 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). |
| +// |counter| could be static (since there will be no race for reinitialization), |
| +// but as they are used (with new names every time) in CACHE_UMA that |
| +// would not work and if CACHE_UMA is made to have one instance for every |
| +// cache, they will generate too much non-reusable machine code. |
| #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( \ |
|
rvargas (doing something else)
2014/03/14 21:48:41
Does this mean that we should change UMA_HISTOGRAM
Daniel Bratell
2014/03/17 09:46:57
I think removing static from all UVA macros could
gavinp
2014/03/17 10:15:28
I think this would be great. It's very difficult f
gavinp
2014/03/17 10:15:28
A few weeks ago, I started looking at this. It tur
rvargas (doing something else)
2014/03/17 18:03:08
I would be more interested in an open bug.
rvargas (doing something else)
2014/03/17 18:03:08
How does the switch amplifies the overhead? What i
Daniel Bratell
2014/03/17 19:35:54
The "static" just prevented the optimizer from reu
|
| name, min, max, bucket_count, \ |
| base::Histogram::kUmaTargetedHistogramFlag); \ |
| counter->Add(sample); \ |
| @@ -40,9 +40,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 +51,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 +94,16 @@ |
| const std::string my_name =\ |
| CACHE_UMA_BACKEND_IMPL_OBJ->HistogramName(name, experiment);\ |
| switch (CACHE_UMA_BACKEND_IMPL_OBJ->cache_type()) {\ |
|
gavinp
2014/03/17 10:15:28
Does it make sense to keep this as a switch statem
rvargas (doing something else)
2014/03/17 18:03:08
I would actually prefer to keep a switch (or equiv
|
| + 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;\ |
| }\ |
| } |