From fa86c8eb74b58170d93503dfd8b56788259258b5 Mon Sep 17 00:00:00 2001 From: Carl Mastrangelo Date: Mon, 18 Jul 2016 11:37:37 -0700 Subject: [PATCH] benchmarks: daemonize threads to reduce the number of stacktraces --- .../java/io/grpc/benchmarks/netty/AbstractBenchmark.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/benchmarks/src/jmh/java/io/grpc/benchmarks/netty/AbstractBenchmark.java b/benchmarks/src/jmh/java/io/grpc/benchmarks/netty/AbstractBenchmark.java index 2f6692b320..c458c41624 100644 --- a/benchmarks/src/jmh/java/io/grpc/benchmarks/netty/AbstractBenchmark.java +++ b/benchmarks/src/jmh/java/io/grpc/benchmarks/netty/AbstractBenchmark.java @@ -55,6 +55,7 @@ import io.netty.channel.local.LocalAddress; import io.netty.channel.local.LocalChannel; import io.netty.channel.local.LocalServerChannel; import io.netty.channel.nio.NioEventLoopGroup; +import io.netty.util.concurrent.DefaultThreadFactory; import java.net.InetAddress; import java.net.InetSocketAddress; @@ -64,6 +65,7 @@ import java.net.SocketAddress; import java.net.SocketException; import java.net.UnknownHostException; import java.util.Enumeration; +import java.util.concurrent.ThreadFactory; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicLong; @@ -227,7 +229,8 @@ public abstract class AbstractBenchmark { } // Always use a different worker group from the client. - serverBuilder.workerEventLoopGroup(new NioEventLoopGroup()); + ThreadFactory serverThreadFactory = new DefaultThreadFactory("STF pool", true /* daemon */); + serverBuilder.workerEventLoopGroup(new NioEventLoopGroup(0, serverThreadFactory)); // Always set connection and stream window size to same value serverBuilder.flowControlWindow(windowSize.bytes()); @@ -376,10 +379,11 @@ public abstract class AbstractBenchmark { server = serverBuilder.build(); server.start(); channels = new ManagedChannel[channelCount]; + ThreadFactory clientThreadFactory = new DefaultThreadFactory("CTF pool", true /* daemon */); for (int i = 0; i < channelCount; i++) { // Use a dedicated event-loop for each channel channels[i] = channelBuilder - .eventLoopGroup(new NioEventLoopGroup(1)) + .eventLoopGroup(new NioEventLoopGroup(1, clientThreadFactory)) .build(); } }