Repository navigation
Set TCP_NODELAY on TCP connections - #186
Merged
Merged
Conversation
Each MDI message is sent as two writes, a small header and then the data. With Nagle's algorithm on, the data waits for the header's ACK, which the receiver delays (up to 40 ms on Linux), so many exchanges stall. Setting TCP_NODELAY on the connecting and the accepting socket removes the stall. Measured with LAMMPS driving an ML potential engine over MDI (1554 atoms, 1000 MD steps, Tesla T4, same node and environment): MPI 349-353 s, TCP 480 s, TCP with TCP_NODELAY 348-349 s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 🚀 New features to boost your workflow:
|
Collaborator
|
@paulsaxe Thanks for the update! I'ts now merged. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Every MDI message goes out as two writes: a small header, then the data. With Nagle's algorithm on, which is the default, the data waits until the header is acknowledged. The receiver delays that ACK (by up to 40 ms on Linux) while it waits for the rest of the message, so many exchanges stall. This PR sets
TCP_NODELAYon the socket afterconnectintcp_request_connectionand afteracceptintcp_accept_connection. Ifsetsockoptfails, the connection still works, just as it does today, so the failure is ignored.Measured cost. LAMMPS drove an ML-potential engine (Python,
pymdi) over MDI: 1554 atoms, 1000 MD steps, on a Tesla T4 node. Both codes ran on the same node in the same conda environment:-method MPI-method TCP-method TCPwithTCP_NODELAYThe
TCP_NODELAYruns used anLD_PRELOADshim that sets the option at exactly these two call sites. Model compute was the same in every run, so the entire difference is the stall.Tests. With this change, the non-MPI test suite passes on macOS (arm64):
pytest -k "not mpi", 24 passed, including the 10 TCP tests.🤖 Generated with Claude Code