Skip to content

Commit

Permalink
Make event loop thread number configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
shangm2 authored and arhimondr committed Feb 14, 2025
1 parent 6f16d8c commit 03b8cd9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public class QueryManagerConfig
private int queryManagerExecutorPoolSize = 5;

private Duration remoteTaskMaxErrorDuration = new Duration(5, TimeUnit.MINUTES);
private int remoteTaskMaxCallbackThreads = 1000;
private int remoteTaskMaxCallbackThreads = Runtime.getRuntime().availableProcessors();

private String queryExecutionPolicy = "all-at-once";
private Duration queryMaxRunTime = new Duration(100, TimeUnit.DAYS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,7 @@ public class HttpRemoteTaskFactory
private final QueryManager queryManager;
private final DecayCounter taskUpdateRequestSize;
private final boolean taskUpdateSizeTrackingEnabled;
private final EventLoopGroup eventLoopGroup = new DefaultEventLoopGroup(Runtime.getRuntime().availableProcessors(),
new ThreadFactoryBuilder().setNameFormat("task-event-loop-%s").setDaemon(true).build())
{
@Override
protected EventLoop newChild(Executor executor, Object... args)
{
return new SafeEventLoop(this, executor);
}
};
private final EventLoopGroup eventLoopGroup;

@Inject
public HttpRemoteTaskFactory(
Expand Down Expand Up @@ -182,6 +174,15 @@ else if (binaryTransportEnabled) {

this.taskUpdateRequestSize = new DecayCounter(ExponentialDecay.oneMinute());
this.taskUpdateSizeTrackingEnabled = taskConfig.isTaskUpdateSizeTrackingEnabled();
this.eventLoopGroup = new DefaultEventLoopGroup(config.getRemoteTaskMaxCallbackThreads(),
new ThreadFactoryBuilder().setNameFormat("task-event-loop-%s").setDaemon(true).build())
{
@Override
protected EventLoop newChild(Executor executor, Object... args)
{
return new SafeEventLoop(this, executor);
}
};
}

@Managed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void testDefaults()
.setQueryManagerExecutorPoolSize(5)
.setRemoteTaskMinErrorDuration(new Duration(5, TimeUnit.MINUTES))
.setRemoteTaskMaxErrorDuration(new Duration(5, TimeUnit.MINUTES))
.setRemoteTaskMaxCallbackThreads(1000)
.setRemoteTaskMaxCallbackThreads(Runtime.getRuntime().availableProcessors())
.setQueryExecutionPolicy("all-at-once")
.setQueryMaxRunTime(new Duration(100, TimeUnit.DAYS))
.setQueryMaxExecutionTime(new Duration(100, TimeUnit.DAYS))
Expand Down

0 comments on commit 03b8cd9

Please sign in to comment.