diff options
author | 2024-03-13 20:45:34 +0000 | |
---|---|---|
committer | 2024-03-13 20:45:34 +0000 | |
commit | a3d2ec8a4c9b51494425d751870620e682d31eb8 (patch) | |
tree | 6ae8d7b1e44d068d706bc12ab550e94ffa6e3323 | |
parent | 81deab754e4728f98e09196528e0c3777ca70ed8 (diff) |
Revert "Fix libtracing_perfetto performance impact"
This reverts commit 81deab754e4728f98e09196528e0c3777ca70ed8.
Reason for revert: Droid-monitored triggered revert due to likely culprit for breakages in b/329487228. Will be verifying through ABTD before submitting the revert.
Change-Id: I83f9eac29fb9f51e2d79053c6e98a047d7ab74d9
-rw-r--r-- | libs/tracing_perfetto/tracing_perfetto.cpp | 3 | ||||
-rw-r--r-- | libs/tracing_perfetto/tracing_perfetto_internal.cpp | 14 | ||||
-rw-r--r-- | libs/tracing_perfetto/tracing_perfetto_internal.h | 2 |
3 files changed, 9 insertions, 10 deletions
diff --git a/libs/tracing_perfetto/tracing_perfetto.cpp b/libs/tracing_perfetto/tracing_perfetto.cpp index 19d1eb639e..c7fb8bd9a8 100644 --- a/libs/tracing_perfetto/tracing_perfetto.cpp +++ b/libs/tracing_perfetto/tracing_perfetto.cpp @@ -131,8 +131,7 @@ Result traceCounter(uint64_t category, const char* name, int64_t value) { } uint64_t getEnabledCategories() { - if (internal::isPerfettoRegistered()) { - // TODO(b/303199244): Return only enabled categories and not all registered ones + if (internal::isPerfettoSdkTracingEnabled()) { return internal::getDefaultCategories(); } else { return atrace_get_enabled_tags(); diff --git a/libs/tracing_perfetto/tracing_perfetto_internal.cpp b/libs/tracing_perfetto/tracing_perfetto_internal.cpp index 976db7e430..58ba428610 100644 --- a/libs/tracing_perfetto/tracing_perfetto_internal.cpp +++ b/libs/tracing_perfetto/tracing_perfetto_internal.cpp @@ -70,8 +70,6 @@ PERFETTO_TE_CATEGORIES_DECLARE(FRAMEWORK_CATEGORIES); PERFETTO_TE_CATEGORIES_DEFINE(FRAMEWORK_CATEGORIES); -std::atomic_bool is_perfetto_registered = false; - struct PerfettoTeCategory* toCategory(uint64_t inCategory) { switch (inCategory) { case TRACE_CATEGORY_ALWAYS: @@ -137,11 +135,15 @@ struct PerfettoTeCategory* toCategory(uint64_t inCategory) { } // namespace -bool isPerfettoRegistered() { - return is_perfetto_registered; +bool isPerfettoSdkTracingEnabled() { + return android::os::perfetto_sdk_tracing(); } struct PerfettoTeCategory* toPerfettoCategory(uint64_t category) { + if (!isPerfettoSdkTracingEnabled()) { + return nullptr; + } + struct PerfettoTeCategory* perfettoCategory = toCategory(category); bool enabled = PERFETTO_UNLIKELY(PERFETTO_ATOMIC_LOAD_EXPLICIT( (*perfettoCategory).enabled, PERFETTO_MEMORY_ORDER_RELAXED)); @@ -149,10 +151,9 @@ struct PerfettoTeCategory* toPerfettoCategory(uint64_t category) { } void registerWithPerfetto(bool test) { - if (!android::os::perfetto_sdk_tracing()) { + if (!isPerfettoSdkTracingEnabled()) { return; } - static std::once_flag registration; std::call_once(registration, [test]() { struct PerfettoProducerInitArgs args = PERFETTO_PRODUCER_INIT_ARGS_INIT(); @@ -160,7 +161,6 @@ void registerWithPerfetto(bool test) { PerfettoProducerInit(args); PerfettoTeInit(); PERFETTO_TE_REGISTER_CATEGORIES(FRAMEWORK_CATEGORIES); - is_perfetto_registered = true; }); } diff --git a/libs/tracing_perfetto/tracing_perfetto_internal.h b/libs/tracing_perfetto/tracing_perfetto_internal.h index 79e4b8f1b4..9a579f162a 100644 --- a/libs/tracing_perfetto/tracing_perfetto_internal.h +++ b/libs/tracing_perfetto/tracing_perfetto_internal.h @@ -26,7 +26,7 @@ namespace tracing_perfetto { namespace internal { -bool isPerfettoRegistered(); +bool isPerfettoSdkTracingEnabled(); struct PerfettoTeCategory* toPerfettoCategory(uint64_t category); |