SIGN IN SIGN UP

[TENT] Remove global lock serialization on per-batch hot paths (#3648)

* [TENT] Remove global lock serialization on per-batch hot paths

progress_mutex_ serialized every submitTransfer / getTransferStatus /
freeBatch call, capping throughput at roughly one core regardless of
caller threads.

Split the engine lock domain per batch:

- 64 BatchShards keyed by BatchID; poll / free / retain lock only the
  batch's shard instead of progress_mutex_.
- The batch registry (alive / active membership) lives inside the same
  shard, so alloc insert, free erase and poll membership checks are O(1)
  set ops under the already-held shard lock instead of a global registry
  mutex.
- enable_runtime_queue=true keeps hot paths on progress_mutex_ (queue
  state is engine-global) and takes the shard only for membership ops.
  Lock order is progress_mutex_ -> shard, never reversed.
- freeBatch fast path frees inline under the shard and holds it through
  deallocation, so pollers cannot observe a dangling Batch*; the
  deferred path releases the shard before taking progress_mutex_.

Signed-off-by: staryxchen <staryxchen@tencent.com>

* [TENT] Apply code_format.sh formatting

Signed-off-by: staryxchen <staryxchen@tencent.com>

---------

Signed-off-by: staryxchen <staryxchen@tencent.com>
S
Stary committed
cd41d58e58ec69e39ea94c307e30a510701c780a
Parent: 468fbf6
Committed by GitHub <noreply@github.com> on 8/25/2026, 12:33:52 PM