Skip to content

[TE] Increase TCP queued transfer admission thresholds - #3710

Merged
alogfans merged 1 commit into
kvcache-ai:mainfrom
alogfans:dev/increase-tcp-threshold
Sep 1, 2026
Merged

alogfans merged 1 commit into
kvcache-ai:mainfrom
alogfans:dev/increase-tcp-threshold

Conversation

@alogfans

Copy link
Copy Markdown
Collaborator

Description

This PR raises the classic TCP transport's default per-peer queued transfer and pending admission limits.

Previously, TCP used:

  • kDefaultQueuedTransfersPerPeer = 1024
  • kMaxQueuedTransfersPerPeer = 65535
  • kDefaultPendingAdmissionsPerPeer = 1024
  • kMaxPendingAdmissionsPerPeer = 65535

This change increases them to:

  • default queued transfers per peer: 65535
  • max queued transfers per peer: 1048576
  • default pending admissions per peer: 65535
  • max pending admissions per peer: 1048576

The intent is to reduce premature QUEUE_FULL hard rejections under high TCP transfer fanout while preserving bounded admission behavior.

Note: this branch currently also adds extern/yalantinglibs as a new gitlink without a .gitmodules update. Please confirm whether that submodule pointer is intentional before merging.

Module

  • Transfer Engine (mooncake-transfer-engine)
  • Mooncake Store (mooncake-store)
  • Reshard (mooncake-reshard)
  • Mooncake EP (mooncake-ep)
  • Mooncake PG (mooncake-pg)
  • Integration (mooncake-integration)
  • P2P Store (mooncake-p2p-store)
  • Python Wheel (mooncake-wheel)
  • Common (mooncake-common)
  • Mooncake RL (mooncake-rl)
  • CI/CD
  • Docs
  • Other

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Breaking change
  • Documentation update
  • Performance improvement
  • Other

How Has This Been Tested?

Not run yet.

Test commands:

# Not run

Test results:

  • Unit tests pass
  • Integration tests pass (if applicable)
  • Manual testing done (describe below)

Checklist

  • I have performed a self-review of my own code
  • I have formatted my code using ./scripts/code_format.sh
  • I have run pre-commit on the files changed in this PR and all hooks pass
  • I have updated the documentation (if applicable)
  • I have added tests to prove my changes are effective
  • For changes >500 LOC: I have filed an RFC issue

AI Assistance Disclosure

  • No AI tools were used
  • AI tools were used (specify below)

AI assistance was used to inspect the TCP admission behavior and draft this PR description. The human submitter should review and validate all changed lines before merge.

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.

Pull request overview

This PR updates the Transfer Engine’s classic TCP transport defaults to allow substantially more per-peer queued transfers and pending admissions before hard rejection, aiming to reduce QUEUE_FULL under high fanout.

Changes:

  • Increased default per-peer queued transfer limit from 1024 to 65535.
  • Increased max per-peer queued transfer limit from 65535 to 1048576.
  • Increased default/max pending admission limits in the same way.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 302 to +306
constexpr size_t kDefaultLanesPerPeer = 4;
constexpr size_t kDefaultQueuedTransfersPerPeer = 1024;
constexpr size_t kMaxQueuedTransfersPerPeer = 65535;
constexpr size_t kDefaultPendingAdmissionsPerPeer = 1024;
constexpr size_t kMaxPendingAdmissionsPerPeer = 65535;
constexpr size_t kDefaultQueuedTransfersPerPeer = 65535;
constexpr size_t kMaxQueuedTransfersPerPeer = 1048576;
constexpr size_t kDefaultPendingAdmissionsPerPeer = 65535;
constexpr size_t kMaxPendingAdmissionsPerPeer = 1048576;
Comment on lines +303 to +306
constexpr size_t kDefaultQueuedTransfersPerPeer = 65535;
constexpr size_t kMaxQueuedTransfersPerPeer = 1048576;
constexpr size_t kDefaultPendingAdmissionsPerPeer = 65535;
constexpr size_t kMaxPendingAdmissionsPerPeer = 1048576;
Comment on lines +303 to +306
constexpr size_t kDefaultQueuedTransfersPerPeer = 65535;
constexpr size_t kMaxQueuedTransfersPerPeer = 1048576;
constexpr size_t kDefaultPendingAdmissionsPerPeer = 65535;
constexpr size_t kMaxPendingAdmissionsPerPeer = 1048576;

@catyans catyans left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Raising both default per-peer limits from 1,024 to 65,535 is not safe without a byte-based bound or load evidence. PeerConnectionGroup retains each TcpWorkItem and its associated task/source-buffer lifetime, while the code already notes that the item limit does not bound queued bytes and that a connected payload can stall a lane indefinitely. With this change, one slow or stalled peer can retain 65,535 queued items plus another 65,535 pending admissions by default, turning an early QUEUE_FULL signal into potentially very large memory retention and extreme tail latency. The configured maximum of 1,048,576 makes the same failure mode substantially worse.

Please keep the conservative default until admission is also bounded by queued bytes, and add a sustained slow/stalled-peer benchmark reporting queue depth, queued bytes/RSS, rejection rate, and tail latency before increasing it. The PR currently says it has not been tested, so there is no evidence that this 64x increase improves throughput without destabilizing overload behavior.

@alogfans

alogfans commented Aug 27, 2026 •

Copy link
Copy Markdown
Collaborator Author

@catyans Thanks for raising this. I agree that a byte-based admission bound is the proper long-term solution, and this change is not intended to establish the final overload policy.

This is a temporary operational adjustment because the existing 1,024-item threshold is too small for normal TCP workloads: it triggers QUEUE_FULL before the TCP transport can maintain its normal pipeline depth, preventing expected throughput even without an abnormal slow or stalled peer. The increase is intended to remove that immediate item-count bottleneck while we implement more appropriate byte-based accounting and collect queue-depth/RSS/tail-latency data.

A follow-up should add queued-byte limits and the slow/stalled-peer measurements you suggested; the default can then be recalibrated based on those results.

@alogfans
alogfans requested a review from catyans September 1, 2026 03:13

@catyans catyans left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for clarifying the intended scope. Re-reviewed the current head: this only adjusts the existing item-count defaults and maxima; it does not change queue ownership, admission timeout, or QUEUE_FULL semantics. Given that this is an operational stopgap and all checks are green, LGTM.

suggestion (non-blocking): please follow through with queued-byte admission and slow/stalled-peer measurements covering queue depth, RSS, rejection rate, and tail latency. The larger configurable maxima make those resource bounds and observability especially important.

@staryxchen staryxchen left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. But I think it's better leaving default value not change.

@alogfans

alogfans commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator Author

@staryxchen In some stress workload (e.g. running tebench), the default value is relatively small. Note: If some users report this, they can change the config file to increase the default value in the release.

@alogfans
alogfans merged commit c5f1023 into kvcache-ai:main Sep 1, 2026
30 checks passed
@alogfans
alogfans deleted the dev/increase-tcp-threshold branch September 9, 2026 08:21
whn09 added a commit to whn09/DeepInfer that referenced this pull request Oct 23, 2026
…mits for Mooncake <= 0.3.13

A Store transfer that cannot complete blocks for Mooncake's fixed 60 s timeout. Open a breaker on the first
transfer failure or a get slower than DEEPINFER_HICACHE_L3_SLOW_S (5 s); while open, skip reads and drop queued
puts; close after DEEPINFER_HICACHE_L3_COOLDOWN_S (30 s, doubling on consecutive trips, capped at 10 min).

Mooncake <= 0.3.13 queues at most 1024 TCP transfers per peer, fewer than one long prompt's batch put; default
MC_TCP_MAX_QUEUED_TRANSFERS_PER_PEER / MC_TCP_MAX_PENDING_ADMISSIONS_PER_PEER to 65535 (the default since
kvcache-ai/Mooncake#3710) unless set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants