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

Unified Diff: base/trace_event/trace_event_impl.cc

Issue 1258903003: Revert of [tracing] Fix, simplify and speed up accounting of TraceEvent memory overhead (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 4 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 | « base/trace_event/trace_event_impl.h ('k') | base/trace_event/trace_event_memory_overhead.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/trace_event/trace_event_impl.cc
diff --git a/base/trace_event/trace_event_impl.cc b/base/trace_event/trace_event_impl.cc
index e78ee61b1219b18662682ec9c4e40a02b6f1c2bc..696ba66e3f31656e5fb251f1ea6ac5c92db68364 100644
--- a/base/trace_event/trace_event_impl.cc
+++ b/base/trace_event/trace_event_impl.cc
@@ -171,6 +171,7 @@ void TraceEvent::Reset() {
parameter_copy_storage_ = NULL;
for (int i = 0; i < kTraceMaxNumArgs; ++i)
convertable_values_[i] = NULL;
+ cached_memory_overhead_estimate_.reset();
}
void TraceEvent::UpdateDuration(const TraceTicks& now,
@@ -182,18 +183,25 @@ void TraceEvent::UpdateDuration(const TraceTicks& now,
void TraceEvent::EstimateTraceMemoryOverhead(
TraceEventMemoryOverhead* overhead) {
- overhead->Add("TraceEvent", sizeof(*this));
-
- // TODO(primiano): parameter_copy_storage_ is refcounted and, in theory,
- // could be shared by several events and we might overcount. In practice
- // this is unlikely but it's worth checking.
- if (parameter_copy_storage_)
- overhead->AddRefCountedString(*parameter_copy_storage_.get());
-
- for (size_t i = 0; i < kTraceMaxNumArgs; ++i) {
- if (arg_types_[i] == TRACE_VALUE_TYPE_CONVERTABLE)
- convertable_values_[i]->EstimateTraceMemoryOverhead(overhead);
+ if (!cached_memory_overhead_estimate_) {
+ cached_memory_overhead_estimate_.reset(new TraceEventMemoryOverhead);
+ cached_memory_overhead_estimate_->Add("TraceEvent", sizeof(*this));
+ // TODO(primiano): parameter_copy_storage_ is refcounted and, in theory,
+ // could be shared by several events and we might overcount. In practice
+ // this is unlikely but it's worth checking.
+ if (parameter_copy_storage_) {
+ cached_memory_overhead_estimate_->AddRefCountedString(
+ *parameter_copy_storage_.get());
+ }
+ for (size_t i = 0; i < kTraceMaxNumArgs; ++i) {
+ if (arg_types_[i] == TRACE_VALUE_TYPE_CONVERTABLE) {
+ convertable_values_[i]->EstimateTraceMemoryOverhead(
+ cached_memory_overhead_estimate_.get());
+ }
+ }
+ cached_memory_overhead_estimate_->AddSelf();
}
+ overhead->Update(*cached_memory_overhead_estimate_);
}
// static
« no previous file with comments | « base/trace_event/trace_event_impl.h ('k') | base/trace_event/trace_event_memory_overhead.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698