Skip to content

feat(tebench): support multi-target benchmark runs - #9

Closed
zxpdemonio wants to merge 1 commit into
mainfrom
cruz/tebench-multinode-v2
Closed

zxpdemonio wants to merge 1 commit into
mainfrom
cruz/tebench-multinode-v2

Conversation

@zxpdemonio

Copy link
Copy Markdown

Summary

This PR adds endpoint-level multi-target support to tebench so one initiator can open multiple target segments and distribute worker threads across them. It keeps topology orchestration outside tebench: fan-out, incast, all-to-all, and M-to-N scenarios can be expressed by launching peers with different target segment lists.

Main changes:

  • Add --target_seg_names for comma-separated target segments while preserving existing --target_seg_name behavior.
  • Carry target id through the benchmark runner and backend interfaces so each request is submitted to the selected target segment.
  • Support multi-target execution in both classic TransferEngine and TENT backends.
  • Add write_seed and read_verify operations for multi-process shared-target verification flows.
  • Add overflow-safe range helpers and document the multi-node tebench responsibility boundary.

Validation

  • Built tebench with USE_TENT=ON.
  • Ran tebench_qos_metrics_test: 9 tests passed.
  • Ran local two-target TENT backend smoke: opened 2 target segments and completed successfully.
  • Ran local two-target classic backend smoke: completed successfully.

@zxpdemonio

Copy link
Copy Markdown
Author

Closing this PR because it was opened against the wrong target repository. The intended upstream target is kvcache-ai/Mooncake.

@zxpdemonio zxpdemonio closed this Aug 11, 2026
Bo-Vincent pushed a commit to Bo-Vincent/Mooncake that referenced this pull request Nov 2, 2026
…B contexts (kvcache-ai#5104)

* [TransferEngine] Fix URMA module lifecycle for multi-device UB contexts

urma_init()/urma_uninit() are process-global, but the UB transport paired
them wrongly: UrmaContext::deconstruct() called urma_uninit() once per
context, while UbTransport::init() called urma_init() once per transport and
~UbTransport() never released it.

With a single device the extra uninit() was harmless. With two or more devices
the first context destructor released the whole URMA module while sibling
contexts still held jetties, and the next teardown faulted:

  #0 urma_unbind_jetty ()
  openanolis#1 UrmaEndpoint::deconstruct()      urma_endpoint.cpp:680
  openanolis#2 UbSIEVEEndpointStore::destroy()  ub_context.cpp:145
  openanolis#3 UrmaContext::~UrmaContext()
  kvcache-ai#16 UbTransport::~UbTransport()

Reproduced on a Kunpeng 950 host with 10 URMA devices: any target or initiator
configured with two devices crashed on exit while the same single-device
configuration ran fine.

Let the transport own the module lifetime: drop the per-context uninit(),
record whether init() ran, make uninit() idempotent, and pair init() in the
destructor after the contexts are gone. install() failure paths already call
uninit(), so the guard keeps those from releasing the module twice.

* [TransferEngine] Do not dereference a null URMA context while logging

UbContext::doConstruct() reports a construction failure with

  LOG(INFO) << "failed construct context " << toString();

and UrmaContext::toString() calls getAsyncFd(), which dereferenced
urma_context_ unconditionally. Opening a device can fail - for example when no
configured device name matches, or the mock build is used on a host with real
URMA devices - so the failure was reported as a SIGSEGV instead of an error.

Return -1 when the context has not been created so the existing error path
survives long enough to log and return ERR_DEVICE_NOT_FOUND.

* [TransferEngine] Fix a data race in UrmaContext::retrieveRemoteSeg

retrieveRemoteSeg() is reached from every submitting thread through
UbWorkerPool::submitPostSend(), but it did its cache lookup, malloc and
push_back into remote_seg_list_ with no synchronisation. Two threads that both
miss the cache therefore push concurrently, and when the vector reallocates
both free the old buffer: AddressSanitizer reports

  ERROR: AddressSanitizer: attempting double-free
  openanolis#7 UrmaContext::retrieveRemoteSeg()   urma_endpoint.cpp:364
  openanolis#9 UbWorkerPool::submitPostSend()     ub_context.cpp:271

After the corruption a later malloc()/free() segfaults somewhere unrelated,
which is what a multi-initiator benchmark sees as a random SIGSEGV.

The same function also published the handle in remote_seg_list_ before the
import succeeded, so a failed urma_import_seg() left it for deconstruct() to
free a second time.

Guard the map and the lists with a shared_mutex: shared lock for the hot
lookup path, unique lock for publishing, with a second lookup so a thread that
lost the race drops its own import. Publish only after a successful import.

Verified with four concurrent initiators (2 read + 2 write, 2 devices,
64 KiB blocks) under ASan: before the fix 3 of 8 processes reported a
double-free, after it 8 of 8 are clean across repeated runs, and the
non-instrumented build finishes 5 mixed scenarios with no crash.

* ci: retrigger build (previous run was cancelled by a runner shutdown)

* [TransferEngine] Read the UB device NUMA node from ubcore sysfs

UbContext::socketId() built its path from /sys/class/infiniband/<dev>/device/numa_node.
URMA devices have no infiniband entry, so the lookup always failed and every
UbWorkerPool thread was pinned to node 0 via bindToSocket() regardless of where
the device actually sits.

The node is published two directories above the /sys/class/ubcore/<dev> link,
next to the ub_bus_controller directory, and is formatted as hex (0x01), so a
plain '>> int' would have truncated it to 0 even with the right path.

Resolve the link with realpath(), walk two levels up, and parse the value with
base 0 so the hex form is handled.

On a 4-node Kunpeng 950 (node 0: CPU 0-95, node 1: 96-191, node 2: 192-287,
node 3: 288-383) with udmac1d1e2, which reports numa=0x03:

  before: 3 worker threads Cpus_allowed_list=0-95
  after:  3 worker threads Cpus_allowed_list=288-383

Devices udmac0* report 0x01 and udmac1* report 0x03, so the two device groups
are now pinned to their own nodes instead of both landing on node 0.

* docs: correct the device-name comments in UbContext

The deviceName()/nicPath() comments were copied from the RDMA transport and
still said 'mlx5_3'. URMA devices are named after their ubcore entry
(udmac0d1e2, udmac1d1e6, ...) and the NIC path is '${server}:${port}@${device}',
for example 127.0.0.1:15479@udmac0d1e3.

* docs: point the mock URMA device path at ubcore sysfs

mock_urma.cpp advertised /sys/class/infiniband/mock_device, which does not
exist for any UB device. Nothing reads urma_device_t::path (listUBDevices()
builds /sys/class/ubcore/<name> from the device name), so this was dead data,
but it kept the RDMA spelling that misleads readers of the UB transport.

Verified the mock build still compiles and passes:
  cmake .. -DUSE_UB=ON -DURMA_LIBRARY= ...   # 'building ub_transport with Mock URMA library'
  ./ub_transport_test --metadata_server=P2PHANDSHAKE ...
  [  PASSED  ] 2 tests.

* docs: call the UB endpoint a device, not an RNIC

Two diagnostics in the UB worker pool reported problems on a 'local RNIC'.
UB has no NIC; the value logged next to the message is nicPath(), i.e.
<host>:<port>@<ubep device>, so 'local UB device' describes it accurately.

The '<Transport>: No available RNIC' messages in rdma/barex/ub are left
untouched: that sentence is deliberately shared across transports.

Both builds still compile and the mock UB test passes:
  make -j64 transfer_engine_bench        -> 0 errors
  make -j64 ub_transport_test (mock)     -> 0 errors
  ./ub_transport_test                    -> [  PASSED  ] 2 tests
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.

1 participant