refactor(dfx): unify L2 phase buffer switching#1391
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughDeviceProfilerEngine now centralizes free-buffer claiming and adds non-blocking startup acquisition. The L2 swimlane collector uses typed contexts and engine-based phase-buffer operations, with new unit tests covering queue transitions and empty-queue behavior. ChangesDevice profiler buffer flow
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Collector as L2SwimlaneCollector
participant Engine as DeviceProfilerEngine
participant FreeQueue
participant ReadyQueue
Collector->>Engine: prime or recover phase buffer
Engine->>FreeQueue: claim free slot
Collector->>Engine: switch full buffer
Engine->>ReadyQueue: enqueue completed buffer
Engine->>FreeQueue: pop replacement buffer
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 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 |
There was a problem hiding this comment.
Code Review
This pull request refactors the DeviceProfilerEngine to extract buffer claiming logic and introduces a non-blocking try_pop_free method. It also templatizes and refactors the L2 swimlane collector to use this unified engine for buffer management, switching, and recovery, replacing manual queue operations. Additionally, unit tests are added for the profiler device engine. A bug was identified in acquire_phase_slot where recovering a phase buffer after a switch failure causes a sequence number gap because state->head.current_buf_seq + 1 is passed instead of state->head.current_buf_seq.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/common/platform/shared/aicpu/l2_swimlane_collector_aicpu.cpp`:
- Around line 887-890: The recovery path in L2SwimlaneDeviceModule should reuse
the current buffer sequence instead of advancing it: update pop_free() in
src/common/platform/shared/aicpu/l2_swimlane_collector_aicpu.cpp:887-890 to pass
state->head.current_buf_seq. Update the corresponding test in
tests/ut/cpp/common/test_profiler_device_engine.cpp:138-154 to pass the existing
sequence and assert that it remains 8.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 10ec047d-7f7f-4bc9-b367-921432992124
📒 Files selected for processing (4)
src/common/platform/include/aicpu/profiler_device_engine.hsrc/common/platform/shared/aicpu/l2_swimlane_collector_aicpu.cpptests/ut/cpp/CMakeLists.txttests/ut/cpp/common/test_profiler_device_engine.cpp
936b457 to
73e8ccd
Compare
Route sched and orch phase buffer rotation through DeviceProfilerEngine so free-queue ownership, head updates, and sequence bookkeeping have a single implementation. Keep startup acquisition non-blocking and add engine-level tests for switching and recovery. Refs hw-native-sys#1385
73e8ccd to
8a58186
Compare
Summary
DeviceProfilerEnginefor sched/orch phase buffer switching and recovery.try_pop_free().Fixes #1385
Validation
test_profiler_device_engine: passed