Skip to content

Commit 03b8cd9

Browse files
shangm2arhimondr
authored andcommitted
Make event loop thread number configurable
1 parent 6f16d8c commit 03b8cd9

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

presto-main/src/main/java/com/facebook/presto/execution/QueryManagerConfig.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public class QueryManagerConfig
7070
private int queryManagerExecutorPoolSize = 5;
7171

7272
private Duration remoteTaskMaxErrorDuration = new Duration(5, TimeUnit.MINUTES);
73-
private int remoteTaskMaxCallbackThreads = 1000;
73+
private int remoteTaskMaxCallbackThreads = Runtime.getRuntime().availableProcessors();
7474

7575
private String queryExecutionPolicy = "all-at-once";
7676
private Duration queryMaxRunTime = new Duration(100, TimeUnit.DAYS);

presto-main/src/main/java/com/facebook/presto/server/remotetask/HttpRemoteTaskFactory.java

+10-9
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,7 @@ public class HttpRemoteTaskFactory
9595
private final QueryManager queryManager;
9696
private final DecayCounter taskUpdateRequestSize;
9797
private final boolean taskUpdateSizeTrackingEnabled;
98-
private final EventLoopGroup eventLoopGroup = new DefaultEventLoopGroup(Runtime.getRuntime().availableProcessors(),
99-
new ThreadFactoryBuilder().setNameFormat("task-event-loop-%s").setDaemon(true).build())
100-
{
101-
@Override
102-
protected EventLoop newChild(Executor executor, Object... args)
103-
{
104-
return new SafeEventLoop(this, executor);
105-
}
106-
};
98+
private final EventLoopGroup eventLoopGroup;
10799

108100
@Inject
109101
public HttpRemoteTaskFactory(
@@ -182,6 +174,15 @@ else if (binaryTransportEnabled) {
182174

183175
this.taskUpdateRequestSize = new DecayCounter(ExponentialDecay.oneMinute());
184176
this.taskUpdateSizeTrackingEnabled = taskConfig.isTaskUpdateSizeTrackingEnabled();
177+
this.eventLoopGroup = new DefaultEventLoopGroup(config.getRemoteTaskMaxCallbackThreads(),
178+
new ThreadFactoryBuilder().setNameFormat("task-event-loop-%s").setDaemon(true).build())
179+
{
180+
@Override
181+
protected EventLoop newChild(Executor executor, Object... args)
182+
{
183+
return new SafeEventLoop(this, executor);
184+
}
185+
};
185186
}
186187

187188
@Managed

presto-main/src/test/java/com/facebook/presto/execution/TestQueryManagerConfig.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public void testDefaults()
5959
.setQueryManagerExecutorPoolSize(5)
6060
.setRemoteTaskMinErrorDuration(new Duration(5, TimeUnit.MINUTES))
6161
.setRemoteTaskMaxErrorDuration(new Duration(5, TimeUnit.MINUTES))
62-
.setRemoteTaskMaxCallbackThreads(1000)
62+
.setRemoteTaskMaxCallbackThreads(Runtime.getRuntime().availableProcessors())
6363
.setQueryExecutionPolicy("all-at-once")
6464
.setQueryMaxRunTime(new Duration(100, TimeUnit.DAYS))
6565
.setQueryMaxExecutionTime(new Duration(100, TimeUnit.DAYS))

0 commit comments

Comments
 (0)