Skip to content

TOOLS/PERF: Rotate message buffers in bandwidth tests - #12419

Open
tvegas1 wants to merge 1 commit into
openucx:masterfrom
tvegas1:perftest-rotate-buffers
Open

tvegas1 wants to merge 1 commit into
openucx:masterfrom
tvegas1:perftest-rotate-buffers

Conversation

@tvegas1

@tvegas1 tvegas1 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

What?

Add ucx_perftest -u <count>|auto to rotate the message buffers of the ucp_put_bw, ucp_get, tag_bw and ucp_am_bw tests. The default stays one buffer, as before.

Why?

These tests keep up to -O operations in flight, and all of them use the same send and receive buffers. With multi-rail zero-copy transfers from GPU memory, the source data then stays in the GPU L2, and the NICs could read it at lower bandwidth than from device memory (HBM).

Applications usually transfer distinct buffers, so allow the tests to do the same, to be able to test this case.

Example:

ucx_perftest <server> -t ucp_put_bw -m cuda -s 4194304 -u auto

How?

  • New ucp.buffer_count test parameter; UCP_PERF_BUFFER_COUNT_AUTO (0) derives the count from the message size. ucx_perftest and the gtest perf harness set it to 1.
  • -u auto: one buffer below 1 MB, where the per-message overhead dominates; otherwise enough buffers to span 256 MB, which is more than the L2. Messages of 256 MB or more get one buffer.
  • ucx_perf_get_thread_buffer_size() multiplies the message size by the count, so each thread allocates the buffers consecutively on both sides. The server gets the count with the rest of the test parameters.
  • run_stream_uni() moves the local buffers and the remote address to the next buffer on each iteration (next_buffer_offset()). The last-iteration signal and the final ack still use the first buffer, so the receiver polls the same location as before.
  • In ucp_am_bw the send buffer rotates, while the AM handler still receives into the first receive buffer.
  • A count above 1 is rejected for other tests, non-contiguous datatypes, and device and daemon modes; -u auto uses one buffer there.

ucp_put_bw, ucp_get, tag_bw and ucp_am_bw keep up to -O operations in
flight, and all of them use the same buffers. With multi-rail zero-copy
transfers from GPU memory, the source data then stays in the GPU L2, and
the NICs could read it at lower bandwidth than from device memory.
Applications usually transfer distinct buffers, so allow the tests to do
the same to be able to test this case.

Add "-u <count>" to allocate several message buffers on both sides and
make consecutive operations rotate through them. The default count of one
keeps the previous behavior, and "-u auto" derives the count from the
message size: a single buffer below 1 MB, otherwise enough buffers to span
256 MB. The last-iteration signal and the final ack still use the first
buffer.
@tvegas1
tvegas1 requested a review from a team as a code owner November 23, 2026 09:57
@svc-nvidia-pr-review

Copy link
Copy Markdown

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

perf->send_allocator, &perf->send_buffer,
&perf->ucp.send_memh);
if (status != UCS_OK) {
ucs_error("failed to allocate send memory, \"-u <count>\" reduces "

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This hint is printed also when the test uses a single buffer and -u was never passed, where it is confusing. Please print it only when the buffer count is > 1, and add the requested size to the message. (Same applies to the copy at line 214.)


#define UCP_PERF_FC_WINDOW_DEFAULT 4

#define UCP_PERF_BUFFER_COUNT_AUTO 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Using 0 for auto means that any zero-initialized ucx_perf_params_t silently asks for auto rotation (this is why test_perf.cc now has to set 1). Can we use a non-zero sentinel, like UCS_MEMUNITS_AUTO, so an unset field keeps a single buffer?

recv(worker, ep, recv_buffer, recv_length, recv_datatype, sn);
offset = next_buffer_offset(&buffer_index, buffer_count,
length);
recv(worker, ep, UCS_PTR_BYTE_OFFSET(recv_buffer, offset),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

For AM the data always lands in m_am_rx_buffer, which is set once to offset 0, so the receiver never rotates and this offset has no effect. Is rotation of the AM receive side intended? With auto mode the rotated sizes (>= 1MB) are exactly the rndv ones that do write into that buffer.

return (params->api == UCX_PERF_API_UCP) &&
((params->command == UCX_PERF_CMD_PUT) ||
(params->command == UCX_PERF_CMD_GET) ||
(params->command == UCX_PERF_CMD_TAG) ||

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why not UCX_PERF_CMD_TAG_SYNC as well? tag_sync_bw uses the same send/recv path.

params->super.flags |= UCX_PERF_TEST_FLAG_VALIDATE;
return UCS_OK;
case 'u':
return parse_buffer_count(opt_arg, &params->super.ucp.buffer_count);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Can we add coverage for the new option? E.g. one -u <count> and one -u auto run of ucp_put_bw/tag_bw in run_ucx_perftest() in contrib/test_jenkins.sh, similar to run_ucx_perftest_sgl.

return 1;
}

return ucs_div_round_up(256 * UCS_MBYTE, length);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Minor: 256 MB is hardcoded here and again in the usage text in perftest_params.c. Please add a define next to UCP_PERF_BUFFER_COUNT_AUTO and use it in both places, so they cannot drift.

Comment thread src/tools/perf/perftest.h
#define TL_RESOURCE_NAME_NONE "<none>"
#define TEST_PARAMS_ARGS \
"t:n:s:W:O:w:D:i:H:oSCIqM:r:E:T:d:x:A:BUe:m:aR:lyzL:F:Y:V"
"t:n:s:W:O:w:D:i:H:oSCIqM:r:E:T:d:x:A:BUe:m:aR:lyzL:F:Y:Vu:"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Minor: please add a long option (e.g. --buffer-count) to TEST_PARAMS_ARGS_LONG too — src/tools/AGENTS.md asks for it for new flags, and -u alone is not self-explanatory.

@svc-nvidia-pr-review

Copy link
Copy Markdown

Residual coverage gaps: no test or CI job exercises buffer_count > 1, so the rotation path (offsets, larger allocation, -u auto sizing) is only covered by manual runs; the gtest change just keeps the existing count at 1. The auto heuristic targets GPU L2 behavior, which cannot be validated in CI without a GPU host; a host-memory -u run would at least cover the offset/allocation logic.

@svc-ucx

svc-ucx commented Nov 23, 2026

Copy link
Copy Markdown

🤖 CI Triage Agent — UCX PR (Tests new on worker 0) · commit da78d1fc

TL;DR: The gtest job crashed in tcp/test_ucp_rma.put_nonblocking/0 — a data-validation failure followed by a TCP send() EIO/connection-reset desynchronized the TCP receive stream, so uct_tcp_ep_handle_put_req() memcpy'd into a bogus/stale put_req->addr and segfaulted. This is in UCT/TCP, not in the perftest code this PR touches — re-run CI, and harden the PUT_REQ path which today validates header length only with ucs_assert (compiled out in release).

Full analysis

Summary: tcp/test_ucp_rma.put_nonblocking/0 <tcp,cuda_copy,rocm_copy/flush_worker> reported "data validation failed" (test/gtest/ucp/test_ucp_memheap.cc:115) and then died with SIGSEGV inside uct_tcp_ep_progress_am_rx() → make: *** [Makefile:5017: test] Segmentation fault (core dumped), failing the Azure job.

Root cause: Evidence from the log, in order:

  1. 15:41:47.163 — test_ucp_memheap.cc:115: Failure / data validation failed for the host→host PUT sizes run (up to 7x14362948): PUT payload was not correctly in place even though the worker flush returned.
  2. 15:41:47.180 — tcp_ep.c:1268 ERROR tcp_ep 0x[REDACTED:Hex High Entropy String] (state=CONNECTED): send(27) failed: Input/output error, then flush.c:110 ERROR req ...: error during flush: Connection reset by remote peer. The TCP connection (over ibs1f0) broke mid-transfer.
  3. Immediately after, in the next sub-case (UCP_MEM_MAP_NONBLOCK, crash stack frames 19/20 = test_ucp_memheap.cc:106, the flush_worker(sender()) call), the receive side parsed the now-desynchronized byte stream as a UCT_TCP_EP_PUT_REQ_AM_ID message and executed memcpy((void*)put_req->addr, ...) → Caught signal 11 ... address not mapped to object at address 0x7ff53b925c80, frame 3 = uct_tcp_ep_progress_am_rx() tcp_ep.c:1537 (the inlined memcpy at tcp_ep.c:1428 inside uct_tcp_ep_handle_put_req).

So a transport-level error left the AM stream out of sync, and the PUT_REQ handling path has no runtime validation: src/uct/tcp/tcp_ep.c:1536 only does ucs_assert(hdr->length == sizeof(uct_tcp_ep_put_req_hdr_t)) and uct_tcp_ep_handle_put_req() does ucs_assert(put_req->addr || !put_req->length) — both compiled out in this non-assert build — so a garbage header becomes an unchecked write to an arbitrary address. Note 413775a3 ("UCT/TCP: Validate AM receive length", #12081) added a real runtime check for regular AM length (tcp_ep.c:1508, uct_tcp_ep_handle_invalid_am_length) but left the PUT_REQ/PUT_ACK branches assert-only.

PR #12419 ("TOOLS/PERF: Rotate message buffers in bandwidth tests") only changes src/tools/perf, which is not linked into the gtest UCP/UCT data path exercised here — the failure is not caused by this PR.

Implicated commit: Not caused by the PR commit da78d1fc. Hardening gap introduced/left by 413775a3 "UCT/TCP: Validate AM receive length (#12081)" (Roie Danino); the underlying pre-existing PUT/flush bug is older (uct_tcp_ep_handle_put_req logic).

File: src/uct/tcp/tcp_ep.c:1428 (crashing memcpy), reached from src/uct/tcp/tcp_ep.c:1536-1538; test assertion at test/gtest/ucp/test_ucp_memheap.cc:115

Suggested fix:

  1. Re-trigger the Azure "Tests new" job for PR TOOLS/PERF: Rotate message buffers in bandwidth tests #12419 — the crash is unrelated to the perftest buffer-rotation change and should not block it.
  2. In uct_tcp_ep_progress_am_rx(), turn the PUT control-header assumptions into runtime checks, e.g. at tcp_ep.c:1535-1549 reject the message via uct_tcp_ep_handle_invalid_am_length()-style teardown when hdr->length != sizeof(uct_tcp_ep_put_req_hdr_t) (PUT_REQ) or hdr->length != sizeof(uint32_t) (PUT_ACK), instead of ucs_assert, so a corrupted stream resets the EP rather than performing an unchecked memcpy to put_req->addr.
  3. Open a separate issue for the primary symptom (silent "data validation failed" on TCP PUT before any error was reported) — it points at worker-flush completing while TCP PUT ACKs are still outstanding; this overlaps with PR UCP/FLUSH: Flush the other lanes after the pending lane #12266 ("UCP/FLUSH: Flush the other lanes after the pending lane"). Also check the worker swx-rdmz-ucx-new-02 / ibs1f0 link, since send() returning EIO on a connected TCP socket is a device-level error.

Related: PR #12419 (this build), #12081 (AM length validation), #12266 (flush ordering)

🛡️ This comment had 1 potential secret(s) redacted (Hex High Entropy String). See request_id 03c3b8c5-8240-455a-9589-7308d1941030 in the triage console for the audit trail.

This branch has not been deployed

No deployments
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