Skip to content

[TENT] Reduce host RDMA polling contention and add NIC-local dispatch - #5595

Open
alogfans wants to merge 2 commits into
mainfrom
codex/tent-rdma-basic-efficiency
Open

alogfans wants to merge 2 commits into
mainfrom
codex/tent-rdma-basic-efficiency

Conversation

@alogfans

@alogfans alogfans commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Concurrent host-memory RDMA spends CPU on repeated batch-status queries and can hand a preselected NIC's slices to workers on the other NUMA node. This PR addresses the baseline perftest-to-TENT efficiency gap with two focused changes:

  • Add the opt-in TENT tebench --poll_backoff flag. It queries eagerly for the first 128 polls, then requests a 1 us sleep between pending queries. The default uses hot polling across thread counts and batch sizes. The flag controls the benchmark caller's wait policy.
  • Add transports/rdma/workers/prefer_nic_local (default false). For preselected NICs, select workers on the NIC's NUMA node using workers' published CPU placement. An independent cursor per NIC covers every matching lane even when NICs alternate. Missing placement falls back to the existing cursor. The option chooses a subset of worker/QP lanes per NIC and should be measured with representative competing traffic.

Enable NIC-local dispatch with:

export MC_TENT_CONF='{"transports":{"rdma":{"workers":{"prefer_nic_local":true}}}}'

Single-host RDMA measurements from the initial revision

The table records the initial revision a33d309. Its PR default rows use the original automatic backoff gate and 1,024 shards. The current revision uses opt-in backoff and 64 shards.

Layout Version Read / write GB/s Read / write P99 ms Read / write CPU seconds
4 NICs, 8 threads, batch 32 Main 173.32 / 173.43 0.440 / 0.404 69.70 / 69.84
4 NICs, 8 threads, batch 32 PR default 174.82 / 173.25 0.412 / 0.410 70.49 / 70.53
4 NICs, 8 threads, batch 32 PR + NIC-local 181.51 / 175.83 0.394 / 0.410 71.25 / 71.25
4 NICs, 32 threads, batch 32 Main 164.19 / 167.39 2.106 / 1.846 180.57 / 181.52
4 NICs, 32 threads, batch 32 PR default 169.67 / 172.46 1.925 / 1.622 51.21 / 49.27
4 NICs, 32 threads, batch 32 PR + NIC-local 175.59 / 175.21 1.601 / 1.594 49.61 / 48.98
4 NICs, 32 threads, batch 1 Main 78.90 / 77.57 0.156 / 0.150 174.99 / 174.92
4 NICs, 32 threads, batch 1 PR + NIC-local 79.43 / 76.72 0.162 / 0.165 189.01 / 189.01
mlx5_1, 1 thread, batch 32 Main 36.64 / 39.09 0.227 / 0.219 35.62 / 35.61
mlx5_1, 1 thread, batch 32 PR + NIC-local 36.78 / 39.41 0.228 / 0.220 21.43 / 21.41

In the initial revision at 32 threads, NIC-local dispatch plus bounded polling improves read/write bandwidth by 6.94% / 4.67%, while initiator CPU time falls 72.53% / 73.02%. At eight threads, NIC-local dispatch improves read/write bandwidth by 4.72% / 1.38%.

Control-case tradeoffs: batch=1 write bandwidth is 1.10% lower by the three-run median; initiator CPU time is about 8% higher and write P99 is 9.73% higher. The smallest NIC-local batch=1 read sample is 73.33 GB/s, versus a 79.43 GB/s median. These cases retain hot polling; the table includes them to expose the measured tradeoffs.

All three-run throughput ranges (GB/s)
Version / layout Operation Min Median Max
baseline-batch1-t32 read 78.222 78.903 79.078
baseline-batch1-t32 write 76.574 77.571 79.112
baseline-shared4-t32 read 163.401 164.194 164.583
baseline-shared4-t32 write 167.216 167.392 167.416
baseline-shared4-t8 read 173.055 173.324 176.064
baseline-shared4-t8 write 173.057 173.425 173.461
baseline-single-t1 read 36.597 36.642 36.782
baseline-single-t1 write 39.068 39.089 39.171
default-shared4-t32 read 168.619 169.670 170.406
default-shared4-t32 write 172.245 172.456 172.586
default-shared4-t8 read 174.064 174.815 175.257
default-shared4-t8 write 172.821 173.254 173.397
numa-batch1-t32 read 73.330 79.428 79.810
numa-batch1-t32 write 76.690 76.720 76.821
numa-shared4-t32 read 175.531 175.591 175.823
numa-shared4-t32 write 175.202 175.206 175.744
numa-shared4-t8 read 180.932 181.510 182.101
numa-shared4-t8 write 175.790 175.826 176.095
numa-single-t1 read 36.552 36.776 36.834
numa-single-t1 write 39.385 39.407 39.433

Measured from pristine main fcb610ad35ea042a140e5f4eb255049f608f4e66 and source tree 6068e2ed88e5f534b8a9c6463afb6488839bd790 (commit a33d3096213a45530cace4549cbe666dd6acdac8) on a dual-NUMA Intel Xeon Platinum 8457C host, using mlx5_1 through mlx5_4. One initiator and one fixed baseline target process share four NICs. Defaults remain six worker lanes and a 64 KiB base slice. Requests are 256 KiB; batch 32 is 8 MiB of logical payload. Both NUMA nodes allocate 1 GiB; each request thread uses its own source batch and random remote window (128 MiB at eight threads, 32 MiB at 32 threads). Rows are medians of three interleaved runs, 1 s warmup + 4 s timed transfer, with the same target retained for each group. GB/s is decimal; latency is per batch. CPU time is cumulative initiator-process user+system CPU seconds, including startup/warmup, while the target remains alive.

The earlier raw ib_read_bw/ib_write_bw small-address-window baseline was about 188.1 GB/s aggregate. A separate control with the message fixed at 256 KiB and only per-QP cyclic address windows enlarged to 32 MiB measured 175.51/177.10 GB/s (read/write). Address layout therefore matters to the residual gap; this PR reports measured TENT gains and does not equate unlike address working sets.

The eight-thread control showed a 1.8% read bandwidth loss with backoff enabled. A follow-up single-host ablation found that backoff alone reduced initiator read CPU time from 180.5 s to 51.9 s at 32 threads. The original automatic gate changed CPU time from 176.6 s to 51.9 s between 31 and 32 threads. Increasing the shard count showed bandwidth changes of −1.2% to +1.6% and modestly higher CPU use with hot polling. This motivated the explicit flag and the return to 64 shards.

Related work

Suggested Merge Priority

  • P0 — Urgent
  • P1 — High
  • P2 — Normal: validated performance improvement
  • P3 — Low

Module

  • Transfer Engine (mooncake-transfer-engine)

Type of Change

  • Performance improvement
  • New feature
  • Documentation update

How Has This Been Tested?

Follow-up 62f7fd6. Built tebench with TENT enabled on Ubuntu 24.04 under WSL2. Passed 48 unit tests across the TENT progress-worker and tebench config, layout, and teardown suites. The build-tree CLI help test passed and reports --poll_backoff defaulting to false. Two loopback TCP runs passed data consistency checks with backoff omitted and enabled, respectively. Changed-file pre-commit checks passed.

Validation commands and results for the initial RDMA revision

Test commands:

cmake --build build --target tebench tent_cuda_plugin \
  tebench_tent_polling_test tebench_tent_config_test \
  tebench_tent_layout_test tebench_tent_teardown_test \
  tent_rdma_numa_dispatch_test tent_rdma_transport_test \
  tent_progress_worker_test request_merge_test tent_runtime_queue_dispatch_test -j12

CUDA_VISIBLE_DEVICES='' \
GTEST_FILTER='-RdmaTransportIntegrationTest.*:RdmaPausedContextRecoveryTest.*' \
ctest --test-dir build --output-on-failure --timeout 120 -j2 \
  -R '^(tebench_tent_(polling|config|layout|teardown)_test|tent_rdma_(numa_dispatch|transport)_test|tent_progress_worker_test|request_merge_test|tent_runtime_queue_dispatch_test)$'

CUDA_VISIBLE_DEVICES='' build/mooncake-transfer-engine/tent/tests/tent_progress_worker_test \
  --gtest_filter='ProgressLockShard.*' --gtest_repeat=20

bash scripts/code_format.sh --staged
pre-commit run --files $(git diff --cached --name-only --diff-filter=ACMR)

Hardware integration is covered by the explicit mlx5_1..4 benchmark matrix rather than the unit test's automatic device selection. The existing CUDA-only tests skip when GPUs are hidden. New tests cover polling thresholds/overflow, sparse and unknown NUMA placement, startup publication, more than 64 workers, disabled fallback, and complete local-lane coverage under alternating NICs.

Representative two-process commands on the same host (use the target segment name printed by the first command):

export MC_TE_FILTERS=mlx5_1,mlx5_2,mlx5_3,mlx5_4
export MC_TE_FILTERS_EXCLUDE=mlx5_0
# Terminal 1: retain the same main target for all three initiator versions.
tebench --backend=tent --xport_type=rdma --tent_transport_hint=rdma \
  --metadata_type=p2p --seg_type=DRAM --local_numa_id=-1 \
  --total_buffer_size=1073741824

# Terminal 2: set MC_TENT_CONF as above for NIC-local; unset it for main/default.
tebench --backend=tent --xport_type=rdma --tent_transport_hint=rdma \
  --metadata_type=p2p --target_seg_name=TARGET_SEGMENT --seg_type=DRAM \
  --local_numa_id=-1 --total_buffer_size=1073741824 --op_type=read \
  --start_num_threads=32 --max_num_threads=32 \
  --start_block_size=262144 --max_block_size=262144 \
  --start_batch_size=32 --max_batch_size=32 --duration=4 \
  --target_access=random --target_window_size=33554432

Test results:

  • Nine selected test executables pass.
  • Existing batch-lock concurrency tests pass 20 consecutive rounds (100 case executions).
  • All changed-file pre-commit hooks pass (clang-format 20).
  • 60 formal bandwidth trials and 10 read/write consistency phases completed; all controls and results are reported above.

Checklist

  • Every commit includes a Signed-off-by trailer matching its author and certifying the DCO.
  • Human submitter has reviewed every changed line and can defend the change end-to-end (draft pending this review).
  • Code formatted using scripts/code_format.sh.
  • Changed-file pre-commit hooks pass.
  • Documentation updated.
  • Tests added.
  • RFC for >500 non-test/non-config LOC — not applicable.

AI Assistance Disclosure

  • No AI tools were used.
  • AI tools were used: OpenAI Codex analyzed the hot path, prepared this patch, ran the native checks and same-host measurements, and drafted this description. Automated diff review is complete; human line-by-line review remains pending, as required by AGENTS.md.
  • The follow-up patch was drafted with Claude, verified with Codex, and reviewed line by line by its submitter.

Bound tebench status polling for large DRAM RDMA batches with at least
32 request threads, spread batch registry locks over cache-line-aligned
shards, and add an opt-in NIC-NUMA-local worker selector with independent
per-NIC cursors. Preserve hot polling for smaller or less concurrent loads.

Signed-off-by: Feng Ren <alogfans@users.noreply.github.com>
@github-actions github-actions Bot added size/M 100-1000 changed lines (additions + deletions) run-ci Transfer Engine labels Nov 17, 2026
@jacklin78911-collab

Copy link
Copy Markdown
Collaborator

Thanks for putting this together — the analysis of the polling path is really helpful.
We tried to understand where the gains come from, and wanted to share what we saw in case
it is useful for the next revision.

Setup. One host, same layout as the PR (initiator and target on the same machine), DRAM,
256 KiB x batch 32, random target access, 4 s, median of 3 interleaved runs. We built each
change separately on fcb610a: base / backoff only / shards only / PR with NIC-local off /
PR with NIC-local on.

We were able to reproduce the headline result: PR + NIC-local vs base at 32 threads gave
+6.27% read / +4.22% write, close to the +6.94% / +4.67% in the description. Splitting it
by change, this is what we observed:

Change Bandwidth Initiator CPU Our reading
tebench polling backoff +0.9% to +3.3% at 32 threads 180.5 -> 51.9 s (read), 179.3 -> 50.0 s (write) Most of the CPU saving seems to come from the benchmark client's polling
Batch lock shards 64 -> 1024 -1.2% to +1.6% +4.5% at 31-32 threads, +8.7% at batch=1 We could not see a clear gain in this workload
prefer_nic_local (vs PR with it off) read +2.9% to +6.0%, write +1.0% unchanged This looks like the main engine-side gain

For reference, runs with identical code paths (backoff not triggered) differed by 0.4% at
8 threads, 0.8% at 31 threads and 4.0% at batch=1, so the batch=1 differences (including the
-1.1% in the description) may be within run-to-run noise.

A few thoughts, for your consideration:

  1. Backoff. With the 32-thread / 8 MiB gate, results change sharply between 31 and 32
    threads (backoff-only CPU 176.6 s -> 51.9 s), which could make runs at different thread
    counts hard to compare. Would it make sense to have tebench wait through waitTransfer
    ([TENT] Add a blocking waitTransfer entry point #5415), or to enable the backoff with an explicit flag? It might also help readers if the
    description noted that the CPU saving is on the benchmark client side.
  2. Shards. In this workload we didn't observe a bandwidth difference, and CPU went up
    slightly with hot polling (our guess is fewer futex waits, so more spinning). Perhaps they
    could go in a separate PR together with a workload that has many concurrent batches, where
    the benefit would be easier to show?
  3. prefer_nic_local. Keeping it opt-in sounds right to us. Since both ends shared memory
    and NUMA in our single-host runs, the effect may be smaller across hosts; cross-host numbers
    would be useful before considering it as a default.
  4. Not covered. We did not measure VRAM. From reading the code, the backoff is host-only,
    the shards matter only with concurrent batches, and NIC-local does not apply to small
    requests that are not preselected, so we would not expect a GPU-path change, but we have
    not verified this.

Happy to rerun anything or share the raw logs and scripts if that would help.

In the single-host ablation of #5595, tebench backoff accounted for most
of the initiator CPU savings. Its automatic 32-thread/8-MiB threshold
also changed the wait policy between adjacent benchmark points. Expose
the same backoff through --poll_backoff, defaulting to hot polling.

Restore the original 64 batch lock shards and remove the new alignment.
The ablation showed no clear throughput gain from the larger shard count
and slightly higher initiator CPU cost with hot polling.

Keep NIC-local dispatch opt-in and document the request-size restriction
and the single-host scope of the measurements.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Liqian Lin <jacklin78911@gmail.com>
@alogfans
alogfans marked this pull request as ready for review November 24, 2026 09:03
Copilot AI balanced review requested due to automatic review settings November 24, 2026 09:03

Copilot AI 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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

4 open issues
What changed in this PR

This PR reduces host-side RDMA polling contention in tebench and adds an opt-in NIC-NUMA-local worker dispatch path for TENT RDMA to improve throughput/CPU efficiency under concurrency.

Changes:

  • Add tebench --poll_backoff to bound polling (128 busy polls, then 1µs sleeps) to reduce initiator CPU.
  • Add transports/rdma/workers/prefer_nic_local to prefer worker lanes on the preselected NIC’s NUMA node via published worker CPU placement.
  • Add RDMA NUMA dispatch cursor utility + unit tests and documentation/config updates.
File Description
mooncake-transfer-engine/​tent/​tests/​rdma_numa_dispatch_test.cpp New gtest coverage for NUMA-aware lane selection behavior and fallbacks.
mooncake-transfer-engine/​tent/​tests/​CMakeLists.txt Build/register new rdma_numa_dispatch unit test.
mooncake-transfer-engine/​tent/​src/​transport/​rdma/​workers.cpp Publish each worker’s bound NUMA node after successful socket binding.
mooncake-transfer-engine/​tent/​src/​transport/​rdma/​rdma_transport.cpp Use NUMA-aware lane cursor when NIC is preselected and option enabled.
mooncake-transfer-engine/​tent/​include/​tent/​transport/​rdma/​workers.h Expose boundNumaNode() accessor and store published NUMA node.
mooncake-transfer-engine/​tent/​include/​tent/​transport/​rdma/​params.h Add prefer_nic_local worker parameter (default false).
mooncake-transfer-engine/​tent/​include/​tent/​transport/​rdma/​numa_dispatch.h New lane cursor to round-robin within a NIC’s NUMA-local worker subset.
mooncake-transfer-engine/​tent/​config/​transfer-engine.json Document config knob prefer_nic_local default.
mooncake-transfer-engine/​tent/​config/​rdma-worker-locality.md New documentation describing NIC-local dispatch and poll backoff behavior.
mooncake-transfer-engine/​benchmark/​utils.h Add XferBenchConfig::poll_backoff.
mooncake-transfer-engine/​benchmark/​utils.cpp Add/parse --poll_backoff flag.
mooncake-transfer-engine/​benchmark/​tent_backend.h Extend waitForBatch to accept a backoff toggle.
mooncake-transfer-engine/​benchmark/​tent_backend.cpp Implement backoff behavior in waitForBatch and wire to config.

Review effort: Lite

Comment on lines +37 to +40
int count = 0;
for (int i = 0; i < num_workers_; ++i)
if (worker_node(i) == node) ++count;
if (!count) return fallback;
Comment on lines +43 to +46
if (!(initialized_ & bit)) {
next_[device] = static_cast<uint32_t>(fallback);
initialized_ |= bit;
}
Comment on lines +47 to +51
const auto ordinal = next_[device]++ % static_cast<uint32_t>(count);
uint32_t current = 0;
for (int i = 0; i < num_workers_; ++i) {
if (worker_node(i) == node && current++ == ordinal) return i;
}
Comment on lines +580 to +581
RdmaNumaLaneCursor numa_lanes(num_workers,
params_->workers.prefer_nic_local);

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

run-ci size/M 100-1000 changed lines (additions + deletions) Transfer Engine

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants