Skip to content

NIXL: Optimize nixlDescList iteration - #1322

Merged
brminich merged 11 commits into
ai-dynamo:mainfrom
iyastreb:desc-list-iter-opt
Feb 22, 2026
Merged

brminich merged 11 commits into
ai-dynamo:mainfrom
iyastreb:desc-list-iter-opt

Conversation

@iyastreb

@iyastreb iyastreb commented Feb 13, 2026 •

Copy link
Copy Markdown
Contributor

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:

      BEFORE    AFTER
prep: 3183194   1457517   // write access is much faster (inline non-virtual)
post:  816547    738207    // read access is faster (inline)

Summary by CodeRabbit

  • Refactor
    • Improved type safety and consistency in descriptor access mechanisms with updated method signatures.
    • Enhanced validation of descriptor list integrity at access time through runtime assertions.

@github-actions

Copy link
Copy Markdown

👋 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.

🚀

Comment thread src/api/cpp/nixl_descriptors.h Outdated
Comment thread src/infra/nixl_descriptors.cpp
Comment thread src/api/cpp/nixl_descriptors.h Outdated
Comment thread src/api/cpp/nixl_descriptors.h Outdated
@iyastreb

Copy link
Copy Markdown
Contributor Author

/build

@brminich

Copy link
Copy Markdown
Contributor

/build

@iyastreb

Copy link
Copy Markdown
Contributor Author

/build

@iyastreb

Copy link
Copy Markdown
Contributor Author

/build

@coderabbitai

coderabbitai Bot commented Feb 20, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Changes 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

Cohort / File(s) Summary
Header API Modernization
src/api/cpp/nixl_descriptors.h
Updated isEmpty() to use noexcept and std::vector::empty() instead of size comparison; refactored operator[] from unsigned int overload declarations to inline size_t-based implementations with direct references.
Infrastructure Access Control
src/infra/mem_section.h
Added <cassert> include; converted operator[] from pure override declaration accepting unsigned int to inline definition accepting size_t with runtime verifySorted() assertion before element access.
Implementation Removal
src/infra/nixl_descriptors.cpp
Deleted all operator[] implementations: const and non-const overloads from nixlDescList<T> template and overload from nixlSecDescList, consolidating access logic to header definitions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 From .cpp to headers we hoppy-migrated,
Size_t replaces what once was outdated,
With assertions now guarding each sorted descent,
The descriptors access in cleaner intent! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main change: optimizing iteration over nixlDescList through inlining operator[].
Description check ✅ Passed The description includes all required template sections (What, Why, How) with clear explanations and supporting performance data demonstrating the optimization's impact.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/api/cpp/nixl_descriptors.h
Comment thread src/infra/mem_section.h
@iyastreb

Copy link
Copy Markdown
Contributor Author

/build

This branch was previously deployed

2 inactive deployments
SWX_AWS — 721cb603 Deployed Feb 21, 2026 by copy-pr-bot[bot] via Run AWS Tests - C++ Tests #5754
GITLAB — 721cb603 Deployed Feb 20, 2026 by copy-pr-bot[bot] via Trigger CI Pipeline #7069
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants