Skip to content

UCT/UD: Remove stale private UD connections - #11822

Merged
iyastreb merged 5 commits into
openucx:masterfrom
iyastreb:iyastreb/ud_match_stale_conn
Sep 4, 2026
Merged

iyastreb merged 5 commits into
openucx:masterfrom
iyastreb:iyastreb/ud_match_stale_conn

Conversation

@iyastreb

Copy link
Copy Markdown
Contributor

What?

Release a UD private endpoint once its peer is gone, instead of keeping it forever.

Why?

On first UCP wireup request:
A private endpoint is created internally on CREQ, has no UCP endpoint above it => so keepalive never checks it => and UD never signals a closed remote endpoint.
When remote peer connection dies => private UD connection stays forever pointing at a dead ep_id

On UCP wireup reconnect request => uct_ep_create() matches that stale endpoint by addr+conn_sn => reuses it as is => wireup reply goes to the dead ep_id => connection never completes

How?

Probe an idle private endpoint from the UD timer with the existing uct_ud_ep_check(), skipping it while the peer keeps sending. The threshold is the upper layer's keepalive interval. An alive peer acks; otherwise peer_timeout fires and the endpoint leaves connection matching immediately.

@iyastreb
iyastreb force-pushed the iyastreb/ud_match_stale_conn branch from d7a9d80 to c47656a Compare August 25, 2026 13:51
@svc-nvidia-pr-review

Copy link
Copy Markdown

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

Comment thread src/uct/ib/ud/base/ud_iface.h Outdated
Comment thread src/uct/ib/ud/base/ud_iface.c
@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

src/uct/ib/ud/base/ud_ep.c

self->config.keepalive_interval can be peer_timeout/3 (~10s at defaults), while the timer wheel resolution is tick/4 (~2.5ms) with 1024 slots (~2.5s max range). ucs_wtimer_add clamps deltas beyond the wheel range to the last slot, so uct_ud_ep_check_peer fires early and simply re-arms until idle_time reaches keepalive_interval. Functionally correct but the intent reads as 'fire once per keepalive_interval' — consider adding a code comment noting the clamp.

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

@evgeny-leksikov evgeny-leksikov 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.

LGTM, please check the room for optimization of eps GC in the comment. Can be separate PR.

Comment on lines +384 to +385
} else if (ep->flags & UCT_UD_EP_FLAG_PRIVATE) {
uct_ud_ep_check_peer(iface, 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.

what if we add the same logic to uct_ud_ep_free_by_timeout? I think we can reduce linger time if peer already gone => reduce and number of stale EP

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, I think this optimization makes sense, but can be done in a separate PR.

@iyastreb
iyastreb merged commit af7d05a into openucx:master Sep 4, 2026
162 checks passed
@iyastreb
iyastreb deleted the iyastreb/ud_match_stale_conn branch September 4, 2026 12:31
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.

3 participants