aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPrimiano Tucci <primiano@google.com>2018-05-08 14:13:00 +0100
committerPrimiano Tucci <primiano@google.com>2018-05-08 14:15:37 +0100
commit361f1e2e39054b2002ce0b22b7c74387559610a8 (patch)
treebf4ed55c810e67e9a47eaa1400c0664045cf8e52
parent28894baecffa4c85a2802b558fe24430fee11e9a (diff)
downloadperfetto-361f1e2e39054b2002ce0b22b7c74387559610a8.tar.gz
Limit concurrent traces to 5 to prevent stalls in traced_probes
This re-sets a heuristic limit that has been dropped during a previous refactoring. This is still not the right clean fix (that would require revisiting the logic in traced_probes), but is good enough to avoid hitting the problem in practice. (cherry picked from commit a690a7d79fe15b1e084825a3d3e8b108750e34db) Bug: 73052144 Change-Id: Iefec4ba044e32906092b1ceeb8e645e1f3c4c41f Merged-In: Iefec4ba044e32906092b1ceeb8e645e1f3c4c41f
-rw-r--r--src/tracing/core/service_impl.cc22
1 files changed, 8 insertions, 14 deletions
diff --git a/src/tracing/core/service_impl.cc b/src/tracing/core/service_impl.cc
index 7697e863a..028c0d4fd 100644
--- a/src/tracing/core/service_impl.cc
+++ b/src/tracing/core/service_impl.cc
@@ -57,6 +57,7 @@ constexpr base::TimeMillis kStatsSnapshotInterval(10 * 1000);
constexpr int kMinWriteIntoFilePeriodMs = 100;
constexpr int kDefaultWriteIntoFilePeriodMs = 5000;
constexpr int kFlushTimeoutMs = 1000;
+constexpr int kMaxConcurrentTracingSessions = 5;
constexpr uint64_t kMillisPerHour = 3600000;
@@ -222,22 +223,15 @@ bool ServiceImpl::EnableTracing(ConsumerEndpointImpl* consumer,
return false;
}
- // TODO(taylori): These assumptions are no longer true. Figure out a new
- // heuristic.
// TODO(primiano): This is a workaround to prevent that a producer gets stuck
// in a state where it stalls by design by having more TraceWriterImpl
- // instances than free pages in the buffer. This is a very fragile heuristic
- // though, because this assumes that each tracing session creates at most one
- // data source instance in each Producer, and each data source has only one
- // TraceWriter.
- // auto first_producer_config = cfg.producers()[0];
- // if (tracing_sessions_.size() >=
- // (kDefaultShmSize / first_producer_config.page_size_kb() / 2)) {
- // PERFETTO_ELOG("Too many concurrent tracing sesions (%zu)",
- // tracing_sessions_.size());
- // // TODO(primiano): make this a bool and return failure to the IPC layer.
- // return;
- //}
+ // instances than free pages in the buffer. This is really a bug in
+ // trace_probes and the way it handles stalls in the shmem buffer.
+ if (tracing_sessions_.size() >= kMaxConcurrentTracingSessions) {
+ PERFETTO_ELOG("Too many concurrent tracing sesions (%zu)",
+ tracing_sessions_.size());
+ return false;
+ }
const TracingSessionID tsid = ++last_tracing_session_id_;
tracing_session =