diff --git a/src/main/java/com/rabbitmq/perf/PerfTest.java b/src/main/java/com/rabbitmq/perf/PerfTest.java index e5a24574..937663a5 100644 --- a/src/main/java/com/rabbitmq/perf/PerfTest.java +++ b/src/main/java/com/rabbitmq/perf/PerfTest.java @@ -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; } diff --git a/src/main/java/com/rabbitmq/perf/Utils.java b/src/main/java/com/rabbitmq/perf/Utils.java index c5141322..5449f74f 100644 --- a/src/main/java/com/rabbitmq/perf/Utils.java +++ b/src/main/java/com/rabbitmq/perf/Utils.java @@ -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 -> { @@ -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) { @@ -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);