Repository navigation
NIXL: Optimize nixlDescList iteration - #1322
Conversation
|
👋 Hi iyastreb! Thank you for contributing to ai-dynamo/nixl. Your PR reviewers will review your contribution then trigger the CI to test your changes. 🚀 |
c314529 to
2fc5509
Compare
|
/build |
|
/build |
|
/build |
|
/build |
📝 WalkthroughWalkthroughChanges modernize descriptor list access patterns by converting operator[] from unsigned int to size_t parameters, moving implementations from .cpp to inline header definitions, and adding runtime sortedness assertions to descriptor list access. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. 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.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/api/cpp/nixl_descriptors.h`:
- Around line 331-339: Add Doxygen comment blocks above both operator[]
overloads and change their exception specification to conditional noexcept by
using noexcept(noexcept(descs[index])) so the wrapper propagates the underlying
std::vector behavior; update the const and non-const overloads
(operator[](size_t) const and operator[](size_t)) to use
noexcept(noexcept(descs[index])) and ensure the Doxygen explains the behavior
and that they return a reference to the element from the internal descs
container.
In `@src/infra/mem_section.h`:
- Around line 74-78: The assert inside operator[](size_t) calls verifySorted()
(an O(n) linear scan) each access, causing O(n²) debug iteration; move the
sorted invariant check into the mutation site addDesc(...) (which already
enforces ordering) and remove the verifySorted() call from operator[] so
operator[] simply returns descs[index]; additionally fix verifySorted() to treat
empty and single-element lists as sorted (i.e. return true for size==0 or
size==1) to avoid spurious asserts on empty containers; if you need runtime
protection after external mutations consider replacing the scan with a cheap
dirty-flag that addDesc clears and any external mutator must set, with
operator[] only asserting the flag or skipping the check entirely.
- Around line 74-78: The operator[] in nixlSectionDesc (non-const) currently
asserts verifySorted() each call causing O(n²) debug iteration and also trips on
empty lists; remove that assert from operator[] and make it a plain passthrough
returning descs[index] (matching the base class), then move the invariant check
to nixlSecDescList::addDesc (assert verifySorted() or assert the
single-element/ordering condition there so insertion maintains sortedness). Also
fix verifySorted() to treat empty and single-element lists as sorted (return
true for size < 2) and remove the now-unnecessary using declaration referenced
near line 66. Ensure you update nixl_descriptors.cpp (nixlSecDescList::addDesc)
and mem_section.h (operator[] and the using) accordingly.
|
/build |
What?
Optimize iteration over nixlDescList
Why?
This change alone improves TTFT by 5% on large dimensions
How?
inlining operator[] and removing virtual modifier
Perf testing:
Summary by CodeRabbit