Skip to content

Commit

Permalink
Merge pull request #693 from rabbitmq/no-delay-flag
Browse files Browse the repository at this point in the history
Add -tnd to control TCP_NODELAY
  • Loading branch information
acogoluegnes authored Jun 4, 2024
2 parents 10c45a4 + 49be3d0 commit c462f76
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/main/java/com/rabbitmq/perf/PerfTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1361,6 +1361,10 @@ static Options getOptions() {
new Option("tsbs", "tcp-send-buffer-size", true, "value for TCP SO_SNDBUF option"));
options.addOption(
new Option("trbs", "tcp-receive-buffer-size", true, "value for TCP SO_RCVBUF option"));

options.addOption(
new Option("tnd", "tcp-no-delay", true, "value for TCP_NODELAY option"));

return options;
}

Expand Down
12 changes: 11 additions & 1 deletion src/main/java/com/rabbitmq/perf/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,15 @@ static SocketConfigurator socketConfigurator(CommandLineProxy cmd) {
socket.setReceiveBufferSize(receiveBufferSize);
}
});
boolean tcpNoDelay = boolArg(cmd, "tnd", "true");
socketConfigurator = socketConfigurator.andThen(socket -> socket.setTcpNoDelay(tcpNoDelay));
return socketConfigurator;
}

static SocketChannelConfigurator socketChannelConfigurator(CommandLineProxy cmd) {
int sendBufferSize = intArg(cmd, "tsbs", -1);
int receiveBufferSize = intArg(cmd, "trbs", -1);
boolean tcpNoDelay = boolArg(cmd, "tnd", "true");
return SocketChannelConfigurators.defaultConfigurator()
.andThen(
socketChannel -> {
Expand All @@ -184,7 +187,10 @@ static SocketChannelConfigurator socketChannelConfigurator(CommandLineProxy cmd)
if (receiveBufferSize > 0) {
socketChannel.socket().setReceiveBufferSize(receiveBufferSize);
}
});
})
.andThen(
socketChannel -> socketChannel.socket().setTcpNoDelay(boolArg(cmd, "tnd", "true"))
);
}

static SslEngineConfigurator sslEngineConfigurator(CommandLineProxy cmd) {
Expand Down Expand Up @@ -217,6 +223,10 @@ static int intArg(CommandLineProxy cmd, String opt, int def) {
return Integer.parseInt(cmd.getOptionValue(opt, Integer.toString(def)));
}

static boolean boolArg(CommandLineProxy cmd, String opt, String def) {
return Boolean.parseBoolean(cmd.getOptionValue(opt, def));
}

static void exchangeDeclare(Channel channel, String exchange, String type) throws IOException {
if ("".equals(exchange) || exchange.startsWith("amq.")) {
LOGGER.info("Skipping creation of exchange {}", exchange);
Expand Down

0 comments on commit c462f76

Please sign in to comment.