Skip to content

[TransferEngine] Enable TCP connection pool by default - #3569

Merged
alogfans merged 1 commit into
kvcache-ai:mainfrom
alogfans:dev/enable-tcp-conn-pool
Aug 24, 2026
Merged

alogfans merged 1 commit into
kvcache-ai:mainfrom
alogfans:dev/enable-tcp-conn-pool

Conversation

@alogfans

Copy link
Copy Markdown
Collaborator

Description

Enable the TCP connection pool by default for TCP transport. Close #3540

Without MC_TCP_ENABLE_CONNECTION_POOL enabled, services that rely on sustained TCP transfers can fail to start or quickly run into socket/ephemeral-port exhaustion. This change makes the pooled connection path the default while preserving the existing rollback behavior:

  • MC_TCP_ENABLE_CONNECTION_POOL unset: connection pool enabled
  • MC_TCP_ENABLE_CONNECTION_POOL=1/true/yes: connection pool enabled
  • MC_TCP_ENABLE_CONNECTION_POOL=0/false/no: connection pool disabled

Docs were updated to reflect the new default and the explicit disable values.

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?

Test commands:

cmake --build build --target tcp_write_visibility_test

env -u MC_TCP_ENABLE_CONNECTION_POOL \
  build/mooncake-transfer-engine/tests/tcp_write_visibility_test \
  --gtest_color=no --gtest_brief=1

Test results:

  • Build passed for tcp_write_visibility_test
  • 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)

Codex was used to make the scoped code/docs update and run local build/test checks. Human review is still required for all changed lines.

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

Enables the TCP transport’s connection-pool path by default in TcpTransport, making sustained TCP transfers less likely to exhaust ephemeral ports unless pooling is explicitly disabled via MC_TCP_ENABLE_CONNECTION_POOL.

Changes:

  • Default TcpTransport to use the connection pool (enable_connection_pool_ = true) unless MC_TCP_ENABLE_CONNECTION_POOL is set to a disable value.

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

std::atomic_bool running_;
std::thread thread_;
bool enable_connection_pool_ = false;
bool enable_connection_pool_ = true;

@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

@alogfans
alogfans merged commit 36fdd89 into kvcache-ai:main Aug 24, 2026
26 of 28 checks passed
@alogfans
alogfans deleted the dev/enable-tcp-conn-pool branch September 9, 2026 08:21
alogfans pushed a commit that referenced this pull request Oct 7, 2026
The pool has been enabled by default since #3569, but the docs still
present it as opt-in and the troubleshooting guide's "known limitations"
describe the removed dynamic pool (cleanupIdleConnections, pool_mutex_),
not the lane-based implementation the flag now selects.

- index.md: document the default-on behavior, the bounded per-peer lanes,
  the clean-exchange reuse rule, and the 0/false/no opt-out.
- troubleshooting.md: reframe the ephemeral-port fix around the default,
  and replace the stale limitations with the lane implementation's actual
  caveats (no idle reaping, no keepalive probe on reuse, dirty-socket
  discard + lane cooldown retry).

Verified with sphinx html build (no warnings on either page) and
pre-commit run --files on both files.
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.

[Bug]: Error occurs when Mooncake runs with multiple instances or DP on a single node under the same IP

3 participants