Add lightweight, zero-overhead tracing macros in tpu_sync/common/trace.h supporting both TraceMe and Perfetto backends. - #856
Merged
Conversation
copybara-service
Bot
force-pushed
the
test_976476264
branch
from
September 4, 2026 23:34
8861a93 to
a110bb7
Compare
tpu_sync/common/trace.h.tpu_sync/common/trace.h supporting both TraceMe and Perfetto backends.
copybara-service
Bot
force-pushed
the
test_976476264
branch
9 times, most recently
from
September 5, 2026 02:42
3a574e4 to
35b87f9
Compare
copybara-service
Bot
force-pushed
the
test_976476264
branch
2 times, most recently
from
September 5, 2026 03:54
a094513 to
0878572
Compare
…ce.h` supporting both TraceMe and Perfetto backends.
* Define `RAIDEN_TRACE(name, ...)`, `RAIDEN_TRACE_SCOPE(name, ...)`, and `RAIDEN_TRACE_FN(name, metadata_fn, ...)` wrapping `ScopedTrace` for fine-grained host timeline instrumentation.
* Support `tsl::profiler::TraceMe` and `Perfetto` track event backends, selectable at runtime via `TPU_RAIDEN_TRACE_BACKEND` or `RAIDEN_TRACE_BACKEND` ("traceme", "perfetto", "both", "none"), or via `TPU_RAIDEN_USE_PERFETTO` / `RAIDEN_USE_PERFETTO`.
* Add file-based trace export via `StartPerfettoTraceToFile()` / `StopPerfettoTraceToFile()` and automated file capture using `TPU_RAIDEN_PERFETTO_OUTPUT_FILE` with `std::atexit` flush.
* Annotate core Raiden components with sample `RAIDEN_TRACE` macros across `internal/raiden_component.cc`, `internal/weight_sync_component.cc`, `internal/raiden_server.cc`, and `weight_sync/weight_synchronizer_base.cc`.
* Support explicit backend tracing via `RAIDEN_PERFETTO_TRACE(...)` and `RAIDEN_TRACEME_TRACE(...)`.
* Implement thread-safe initialization and track event category registration for Perfetto in `tpu_sync/common/trace.cc`.
* Provide programmatic backend override via `SetTraceBackendForTesting(...)` for unit tests.
* Define `RAIDEN_TRACE_LOG(...)` and `IsTraceLoggingEnabled()` for debug trace logging to stderr controlled by `TPU_RAIDEN_TRACE` and `RAIDEN_TRACE` environment variables.
* Add comprehensive unit tests in `tpu_sync/common/trace_test.cc` covering backend selection, dynamic name lambdas, metadata callbacks, and in-process Perfetto trace sessions.
* Add bidirectional open-source Copybara transformations for `tsl` and `perfetto` dependencies and includes.
* Declare `perfetto` Bzlmod dependency and `git_override` in `MODULE.bazel` pointing to `https://github.com/google/perfetto`.
* Add `no_android_deps.patch` for Perfetto to remove Android SDK/NDK requirements and fix protoc_lib dependencies for open-source Protobuf 32.1 compatibility.
* Expose `@tsl` repository from OpenXLA via `tsl_extension` in `MODULE.bazel` and map TSL dependencies to `@tsl//tsl` in `copy.bara.sky` for profiler targets.
[skip-perf-gate]
PiperOrigin-RevId: 976630278
copybara-service
Bot
force-pushed
the
test_976476264
branch
from
September 5, 2026 04:14
0878572 to
622f9b5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add lightweight, zero-overhead tracing macros in
tpu_sync/common/trace.hsupporting both TraceMe and Perfetto backends.RAIDEN_TRACE(name, ...),RAIDEN_TRACE_SCOPE(name, ...), andRAIDEN_TRACE_FN(name, metadata_fn, ...)wrappingScopedTracefor fine-grained host timeline instrumentation.tsl::profiler::TraceMeandPerfettotrack event backends, selectable at runtime viaTPU_RAIDEN_TRACE_BACKENDorRAIDEN_TRACE_BACKEND("traceme", "perfetto", "both", "none"), or viaTPU_RAIDEN_USE_PERFETTO/RAIDEN_USE_PERFETTO.StartPerfettoTraceToFile()/StopPerfettoTraceToFile()and automated file capture usingTPU_RAIDEN_PERFETTO_OUTPUT_FILEwithstd::atexitflush.RAIDEN_TRACEmacros acrossinternal/raiden_component.cc,internal/weight_sync_component.cc,internal/raiden_server.cc, andweight_sync/weight_synchronizer_base.cc.RAIDEN_PERFETTO_TRACE(...)andRAIDEN_TRACEME_TRACE(...).tpu_sync/common/trace.cc.SetTraceBackendForTesting(...)for unit tests.RAIDEN_TRACE_LOG(...)andIsTraceLoggingEnabled()for debug trace logging to stderr controlled byTPU_RAIDEN_TRACEandRAIDEN_TRACEenvironment variables.tpu_sync/common/trace_test.cccovering backend selection, dynamic name lambdas, metadata callbacks, and in-process Perfetto trace sessions.tslandperfettodependencies and includes.perfettoBzlmod dependency andgit_overrideinMODULE.bazelpointing tohttps://github.com/google/perfetto.no_android_deps.patchfor Perfetto to remove Android SDK/NDK requirements and fix protoc_lib dependencies for open-source Protobuf 32.1 compatibility.@tslrepository from OpenXLA viatsl_extensioninMODULE.bazeland map TSL dependencies to@tsl//tslincopy.bara.skyfor profiler targets.[skip-perf-gate]