Skip to content

UCT/IB: Add configurable TTL knob for the AH cache - #11847

Open
tvegas1 wants to merge 2 commits into
openucx:masterfrom
tvegas1:ah_cache_tll
Open

UCT/IB: Add configurable TTL knob for the AH cache#11847
tvegas1 wants to merge 2 commits into
openucx:masterfrom
tvegas1:ah_cache_tll

Conversation

@tvegas1

@tvegas1 tvegas1 commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

What?

Add UCX_IB_AH_CACHE_TTL: 0 creates AHs uncached, inf keeps them cached (no eviction).

Why?

The AH cache speeds up connection setup, but its underlying L2 resolution can become invalid (RoCE), leaving a stale cached entry.

How?

Users of the TTL configuration (cached or uncached):

  • UD verbs (moved away from raw AH pointer comparison), UD mlx5, DC (connect and grant), RC mlx5

Users of the always-cached path:

  • SRD (still compares raw AH pointers)

Added the configuration knob and tests.

Add UCX_IB_AH_CACHE_TTL (0 or inf) to bypass or keep the address handle
cache. All non-SRD AH creation call sites (UD, RC DEVX QP connect, DC
pure grant, compact AV probe) honor the setting, SRD always uses the
cache directly since it needs a stable AH pointer for is_connected().
@svc-nvidia-pr-review

Copy link
Copy Markdown

🤖 Starting review — findings will be posted here when done.

Comment thread src/uct/ib/mlx5/dc/dc_mlx5_ep.c
@svc-nvidia-pr-review

Copy link
Copy Markdown

src/uct/ib/base/ib_md.c

minor: The AH_CACHE_TTL option is typed as TIME_UNITS and named TTL, but only 0/inf are legal and any real duration is rejected at MD open. That is a surprising UX (a "TTL" that accepts no time value). Config naming/UX is never a blocker, so this is just a note — consider clarifying in the doc string that no intermediate values are supported yet (the doc already says "No other values are allowed", which is adequate).

Coverage note: No test covers the UCX_IB_AH_CACHE_TTL=0 path through SRD / dc-mlx5 FC-grant / rc-devx connect AH release (i.e., that the uncached AHs are actually destroyed and not leaked). This relies on existing transport tests running under a non-default config; if CI does not run a job with IB_AH_CACHE_TTL=0, leak/lifetime regressions in those release sites would go uncaught. Worth confirming a CI job or valgrind run exercises the disabled-cache path across RC/DC/UD/SRD, or adding one.

@svc-nvidia-pr-review

Copy link
Copy Markdown

🤖 Starting review — findings will be posted here when done.

@svc-nvidia-pr-review

Copy link
Copy Markdown

🤖 Review complete — no issues found.

typedef struct {
uct_ud_ep_t super;
uct_ud_verbs_ep_peer_address_t peer_address;
struct ibv_ah *ah;

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.

it increases ep size, maybe we can fix just mlx5 transports in this Pr?

@tomerg-nvidia tomerg-nvidia 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.

Minor comments

int uct_ib_iface_prepare_rx_wrs(uct_ib_iface_t *iface, ucs_mpool_t *mp,
uct_ib_recv_wr_t *wrs, unsigned n);

/* Honors UCX_IB_AH_CACHE_TTL=0 to bypass the AH cache */

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.

This comment seems out of place

Comment thread src/uct/ib/base/ib_md.c
ucs_offsetof(uct_ib_md_config_t, ext.direct_nic), UCS_CONFIG_TYPE_BOOL},

{"AH_CACHE_TTL", "inf",
"Address handle (AH) cache: 0 disables it, inf keeps it enabled. No\n"

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.

Maybe disables it when possible? SRD still has the cache

return uct_ib_device_create_ah_cached(uct_ib_iface_device(iface), ah_attr,
uct_ib_device_t *dev = uct_ib_iface_device(iface);

/* ah_cache_ttl=0 (UCX_IB_AH_CACHE_TTL) bypasses the cache */

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.

This comment is not useful

Comment thread src/uct/ib/base/ib_md.c
{"DIRECT_NIC", "y", "Use Direct NIC functionality for GPU memory access",
ucs_offsetof(uct_ib_md_config_t, ext.direct_nic), UCS_CONFIG_TYPE_BOOL},

{"AH_CACHE_TTL", "inf",

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.

Why TTL? Maybe just AH_CACHE_ENABLED?

return UCS_OK;
}

static void uct_ud_verbs_ep_destroy_ah(uct_ud_verbs_ep_t *ep)

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.

Consider naming uct_ud_verbs_ep_release_ah

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants