Perf: align A5 TMR hot function entries - #2076
Conversation
Apply 64-byte entry alignment to the task submission, scheduler dispatch, and completion hot paths on Linux AArch64. Keep other targets unchanged through an internal platform-gated attribute.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe change adds a platform-conditional 64-byte alignment macro and applies it to task submission, completion, and dispatch entry points. ChangesHot-entry alignment
Estimated code review effort: 1 (Trivial) | ~5 minutes Merge Risk: ⚪ Minimal · up to This change stabilizes alignment for three internal AArch64/Linux hot-function entries without altering other targets or claiming a performance benefit; no actionable merge-blocking risk remains after normal checks and review. Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
ChaoZheng109
left a comment
There was a problem hiding this comment.
Thanks for the careful scoping and for verifying the result in the binary — the three symbol addresses check out (all divisible by 64).
Three questions before I can tell whether this change is necessary and effective.
1. Why does 64-byte alignment fix the variance?
#2071 establishes that unrelated changes move hot function entry addresses, but not why a moved address produces a 5–8% delta — there is no I-cache / branch-predictor / PMU evidence, and the issue itself labels the layout sensitivity a hypothesis. Without a mechanism it is hard to judge whether 64 is the right constraint (#2071's own follow-up notes 16 and 32 were never compared) or whether these three entries are the right ones (also an unchecked follow-up: "Align each of the three functions independently to identify which entries matter").
2. Why is the same alignment not applied to a2a3?
All three functions exist under src/a2a3/runtime/tensormap_and_ringbuffer/ under the same names (orchestrator.cpp:884, scheduler_dispatch.cpp:892, scheduler_completion.cpp:86), the two arches' target_compile_options(aicpu_kernel ...) are identical, and the TMR runtime sources differ by about 1.6% in size. Has the paired commit/parent comparison been run on a2a3?
If it has not, the a5-only scope rests on "no data elsewhere" rather than "a2a3 is unaffected" — but the name SIMPLER_A5_TMR_HOT_ENTRY_ALIGN reads as the latter to anyone picking this up later.
3. What is the measured result?
The PR verifies the binary layout and functional regression, but carries no performance data. Two numbers would settle it:
- cross-commit variance with this change landed, in the form it lands (#2071's data is
aligned Commitvsaligned Parent, i.e. applied to both sides, which is not what merging this does); - full a5 benchmark suite,
mainvsmain+ this PR. #2071 records that aligning these same three entries on main cost 7.63% on BGEMM's full AICore window. Since that is exactly what this PR does, it would be good to address that number directly rather than leave it at "no performance benchmarks were run".
CI will not catch a regression here: _st-npu-a5.yml runs the correctness pytest with no --rounds, and the repo has no performance gate — so a 7.63% slowdown passes green.
This is also #2071's own acceptance criterion: "Use reduced cross-commit variance with no new regressions as the acceptance criterion."
Summary
This applies the mitigation discussed in #2071. Without an explicit compile-time alignment requirement, unrelated code changes can move hot function entries and make performance-debugging results unpredictable. This change stabilizes the selected entry boundaries; it does not claim that alignment always improves performance.
Binary verification
The locally built A5 onboard AICPU shared object is AArch64 and places all three selected entries on 64-byte boundaries:
Artifact SHA-256: 9a80175755e086400bc96ab480209965ad41ba77b4db3be7e706d3d978151d8a
Testing
No performance benchmarks were run, and this PR makes no performance-benefit claim.