feat(tracy): integrate Tracy performance profiling support#498
feat(tracy): integrate Tracy performance profiling support#498chenghuaWang merged 3 commits intoUbiquitousLearning:v2from
Conversation
- Add Tracy profiling support with new CMake option `MLLM_TRACY_ENABLE` - Integrate Tracy memory tracking in CPU allocator (`TracyAlloc`/`TracyFree`) - Add Tracy zones to key engine components (Dispatcher, Context, MemoryManager) - Update Tracy CMakeLists to link against `Tracy::TracyClient` - Include Tracy headers and zone macros in relevant source files - Disable Tracy by default in macOS build configuration - Install `MllmTracy` target when Tracy is enabled - Link `MllmRT` with `MllmTracy` when Tracy support is active - Refactor Tracy header guards and include paths for better compatibility
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughTracy performance profiling instrumentation is integrated throughout the codebase. Changes include adding Tracy header includes and zone-scoping macros to core components, updating CMake configurations to conditionally link and install the MllmTracy library, modifying Tracy header files with pragma once directives, and disabling Tracy in the macOS Accelerate build configuration. Changes
Sequence DiagramsequenceDiagram
participant Caller
participant ProfiledFunc as Profiled Function
participant Tracy as Tracy Profiler
Caller->>ProfiledFunc: invoke function
Note over ProfiledFunc: MLLM_TRACY_ZONE_SCOPED<br/>(zone starts)
activate ProfiledFunc
rect rgb(200, 220, 255)
Note over Tracy: Zone timing active
ProfiledFunc->>ProfiledFunc: original logic
end
deactivate ProfiledFunc
Note over ProfiledFunc: zone ends
ProfiledFunc->>Caller: return
ProfiledFunc->>Tracy: emit timing data
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (11)
CMakeLists.txt(1 hunks)mllm/CMakeLists.txt(1 hunks)mllm/backends/cpu/CPUAllocator.cpp(2 hunks)mllm/backends/cpu/CPUDispatcher.cpp(2 hunks)mllm/engine/Context.cpp(2 hunks)mllm/engine/DispatcherManager.cpp(2 hunks)mllm/engine/MemoryManager.cpp(3 hunks)mllm/tracy_perf/CMakeLists.txt(1 hunks)mllm/tracy_perf/Tracy.cpp(1 hunks)mllm/tracy_perf/Tracy.hpp(1 hunks)tasks/build_osx_apple_silicon_accelerate.yaml(1 hunks)
🧰 Additional context used
🪛 Clang (14.0.6)
mllm/backends/cpu/CPUAllocator.cpp
[error] 26-26: do not use pointer arithmetic
(cppcoreguidelines-pro-bounds-pointer-arithmetic,-warnings-as-errors)
[error] 31-31: do not use pointer arithmetic
(cppcoreguidelines-pro-bounds-pointer-arithmetic,-warnings-as-errors)
[error] 31-31: do not use C-style cast to convert between unrelated types
(cppcoreguidelines-pro-type-cstyle-cast,-warnings-as-errors)
🔇 Additional comments (15)
tasks/build_osx_apple_silicon_accelerate.yaml (1)
13-13: LGTM! Appropriate to disable Tracy on macOS Accelerate builds.Disabling Tracy for this specific build configuration is a sensible choice, likely to avoid platform-specific issues or maintain build performance.
mllm/backends/cpu/CPUDispatcher.cpp (2)
8-8: LGTM! Tracy header correctly included.
43-43: LGTM! Zone scoping correctly placed.The
MLLM_TRACY_ZONE_SCOPEDmacro is appropriately positioned at the function entry to profile the entire task processing logic.mllm/engine/DispatcherManager.cpp (2)
8-8: LGTM! Tracy header correctly included.
18-21: LGTM! Zone scoping correctly profiles the dispatch path.The Tracy zone correctly wraps the dispatcher receive call, enabling profiling of task submission overhead.
mllm/tracy_perf/Tracy.hpp (2)
1-4: LGTM! Modern header structure with appropriate copyright.The use of
#pragma onceis a cleaner alternative to traditional include guards and is widely supported by modern compilers.
6-15: LGTM! Tracy integration correctly implemented.The angle brackets
<tracy/Tracy.hpp>appropriately treat Tracy as an external library, and the conditional macro definitions ensure clean compilation when Tracy is disabled.mllm/engine/Context.cpp (2)
10-10: LGTM! Tracy header correctly included.
46-46: LGTM! Zone scoping correctly profiles the operation submission path.The Tracy zone appropriately covers the entire flow including device selection, op creation, and task submission.
mllm/tracy_perf/CMakeLists.txt (1)
3-4: LGTM! Modern CMake practices applied.Using the
Tracy::TracyClientimported target and exposing public include directories follows modern CMake best practices and ensures proper dependency management.mllm/CMakeLists.txt (1)
81-84: LGTM! Tracy integration correctly wired into the build.The conditional compilation block properly adds the Tracy subdirectory and links the MllmTracy library to MllmRT when Tracy support is enabled.
mllm/engine/MemoryManager.cpp (2)
6-6: LGTM! Tracy profiling properly integrated.The Tracy header include and zone instrumentation are correctly placed for profiling memory allocation operations.
Also applies to: 29-29
63-63: LGTM! Consistent profiling instrumentation.The Tracy zone for the free method matches the pattern used in alloc.
mllm/backends/cpu/CPUAllocator.cpp (1)
6-6: LGTM! TracyAlloc correctly tracks allocation.The TracyAlloc call properly tracks the malloc'd pointer with the correct size (including alignment offset).
Also applies to: 22-24
CMakeLists.txt (1)
303-310: LGTM! Installation rule properly configured.The MllmTracy installation follows the same pattern as other targets and is correctly gated by the MLLM_TRACY_ENABLE flag.
The TracyFree call was placed after the free() call, which could lead to undefined behavior. This change ensures that TracyFree is called before the memory is actually freed, allowing proper tracking and profiling of memory deallocation when Tracy is enabled. Additionally, remove redundant tracy include in Tracy.cpp to avoid potential conflicts with the local tracy implementation.
MLLM_TRACY_ENABLETracyAlloc/TracyFree)Tracy::TracyClientMllmTracytarget when Tracy is enabledMllmRTwithMllmTracywhen Tracy support is activeSummary by CodeRabbit
Release Notes
New Features
Chores