Skip to content

Commit

Permalink
set tcpNoDelay option on all sockets for 100x speedup
Browse files Browse the repository at this point in the history
  • Loading branch information
jakemac53 committed Oct 18, 2024
1 parent a482288 commit 506fa92
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions pkgs/_macro_client/lib/macro_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class MacroClient {
final Map<int, Completer<Response>> _responseCompleters = {};

MacroClient._(this.macros, this.socket) {
// Nagle's algorithm slows us down >100x, disable it.
socket.setOption(SocketOption.tcpNoDelay, true);
_host = RemoteMacroHost(this);
_start();
}
Expand Down
5 changes: 4 additions & 1 deletion pkgs/_macro_server/lib/macro_server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@ class _Connection {
/// Responses to query requests from the macro.
Stream<Response> get responses => _responsesController.stream;

_Connection(this.socket);
_Connection(this.socket) {
// Nagle's algorithm slows us down >100x, disable it.
socket.setOption(SocketOption.tcpNoDelay, true);
}

@override
String toString() => '_Connection($descriptions)';
Expand Down

0 comments on commit 506fa92

Please sign in to comment.