Repository: spark
Updated Branches:
  refs/heads/master fb2008431 -> 02ac379e8


[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 <[email protected]>

Closes #14879 from zsxwing/netty-thread.


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/02ac379e
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/02ac379e
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/02ac379e

Branch: refs/heads/master
Commit: 02ac379e8645ce5d32e033f6683136da16fbe584
Parents: fb20084
Author: Shixiong Zhu <[email protected]>
Authored: Tue Aug 30 13:22:21 2016 -0700
Committer: Shixiong Zhu <[email protected]>
Committed: Tue Aug 30 13:22:21 2016 -0700

----------------------------------------------------------------------
 .../main/java/org/apache/spark/network/util/NettyUtils.java   | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/02ac379e/common/network-common/src/main/java/org/apache/spark/network/util/NettyUtils.java
----------------------------------------------------------------------
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 10de9d3..5e85180 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. */


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to