diff options
author | Shixiong Zhu <shixiong@databricks.com> | 2016-08-30 13:22:21 -0700 |
---|---|---|
committer | Shixiong Zhu <shixiong@databricks.com> | 2016-08-30 13:22:21 -0700 |
commit | 02ac379e8645ce5d32e033f6683136da16fbe584 (patch) | |
tree | 02e2c3381057d028a1f68a8cc9cc30008821874a | |
parent | fb20084313470593d8507a43fcb2cde2a4c854d9 (diff) | |
download | spark-02ac379e8645ce5d32e033f6683136da16fbe584.tar.gz spark-02ac379e8645ce5d32e033f6683136da16fbe584.tar.bz2 spark-02ac379e8645ce5d32e033f6683136da16fbe584.zip |
[SPARK-17314][CORE] Use Netty's DefaultThreadFactory to enable its fast ThreadLocal impl
## What changes were proposed in this pull request?
When a thread is a Netty's FastThreadLocalThread, Netty will use its fast ThreadLocal implementation. It has a better performance than JDK's (See the benchmark results in https://github.com/netty/netty/pull/4417, note: it's not a fix to Netty's FastThreadLocal. It just fixed an issue in Netty's benchmark codes)
This PR just changed the ThreadFactory to Netty's DefaultThreadFactory which will use FastThreadLocalThread. There is also a minor change to the thread names. See https://github.com/netty/netty/blob/netty-4.0.22.Final/common/src/main/java/io/netty/util/concurrent/DefaultThreadFactory.java#L94
## How was this patch tested?
Author: Shixiong Zhu <shixiong@databricks.com>
Closes #14879 from zsxwing/netty-thread.
-rw-r--r-- | common/network-common/src/main/java/org/apache/spark/network/util/NettyUtils.java | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/common/network-common/src/main/java/org/apache/spark/network/util/NettyUtils.java b/common/network-common/src/main/java/org/apache/spark/network/util/NettyUtils.java index 10de9d3a5c..5e85180bd6 100644 --- a/common/network-common/src/main/java/org/apache/spark/network/util/NettyUtils.java +++ b/common/network-common/src/main/java/org/apache/spark/network/util/NettyUtils.java @@ -20,7 +20,6 @@ package org.apache.spark.network.util; import java.lang.reflect.Field; import java.util.concurrent.ThreadFactory; -import com.google.common.util.concurrent.ThreadFactoryBuilder; import io.netty.buffer.PooledByteBufAllocator; import io.netty.channel.Channel; import io.netty.channel.EventLoopGroup; @@ -31,6 +30,7 @@ import io.netty.channel.epoll.EpollSocketChannel; import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.nio.NioServerSocketChannel; import io.netty.channel.socket.nio.NioSocketChannel; +import io.netty.util.concurrent.DefaultThreadFactory; import io.netty.util.internal.PlatformDependent; /** @@ -39,10 +39,7 @@ import io.netty.util.internal.PlatformDependent; public class NettyUtils { /** Creates a new ThreadFactory which prefixes each thread with the given name. */ public static ThreadFactory createThreadFactory(String threadPoolPrefix) { - return new ThreadFactoryBuilder() - .setDaemon(true) - .setNameFormat(threadPoolPrefix + "-%d") - .build(); + return new DefaultThreadFactory(threadPoolPrefix, true); } /** Creates a Netty EventLoopGroup based on the IOMode. */ |