Repository navigation
Acknowledge server responses at once on Linux - #27
Merged
Merged
Conversation
nrepl.core opens its socket without a timeout, so a host that doesn't answer at all, like one gone from the network, took over a minute to fail. neorepl now opens the socket itself, giving up after 10 seconds, with TCP_NODELAY set, so its messages go out as they're written.
nREPL writes an eval's done right after its value, and its sockets go without TCP_NODELAY, so the done waits in the server's socket until the client acknowledges the value, which Linux holds back for up to 40ms when the client has nothing to send. Every eval paid that once, and with an eval's forms going out one at a time, once a form: 100 forms took 4s on Linux CI, against 60ms on macOS. On the JVM, neorepl sets TCP_QUICKACK on its socket before each read, as Linux leaves quick acknowledgements again once the client sends, and the same 100 forms take 150ms. babashka has no jdk.net.ExtendedSocketOptions, so on Linux it waits as before, until servers set TCP_NODELAY.
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.
An eval's done waits in nREPL's socket until the client acknowledges its value, and Linux holds that acknowledgement back 40ms, so every eval on Linux paid 40ms, and since #25, every form did. On the JVM, setting TCP_QUICKACK before each read takes that away: 100 forms went from 4s to 150ms on Linux CI. babashka can't set it, so bb on Linux stays slow until nREPL's and bb's servers set TCP_NODELAY, which is where the real fix belongs.
The other commit gives connecting a 10s timeout, which needed neorepl to open its own socket anyway.