-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce ChannelExecutor
#4882
Changes from all commits
e7b40ea
1589e62
e97ec03
ebf2aa1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -278,6 +278,10 @@ public static ActorSystem Create(string name) | |
|
||
private static ActorSystem CreateAndStartSystem(string name, Config withFallback, ActorSystemSetup setup) | ||
{ | ||
// allows the ThreadPool to scale up / down dynamically | ||
// by removing minimum thread count, which in our benchmarks | ||
// appears to negatively impact performance | ||
ThreadPool.SetMinThreads(0, 0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The differences in the benchmarks with this and without it are massive. However, if this causes problems for users they can easily reset it by calling |
||
var system = new ActorSystemImpl(name, withFallback, setup, Option<Props>.None); | ||
system.Start(); | ||
return system; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,6 +116,26 @@ protected ExecutorServiceConfigurator(Config config, IDispatcherPrerequisites pr | |
public IDispatcherPrerequisites Prerequisites { get; private set; } | ||
} | ||
|
||
internal sealed class ChannelExecutorConfigurator : ExecutorServiceConfigurator | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Used to configure the |
||
{ | ||
public ChannelExecutorConfigurator(Config config, IDispatcherPrerequisites prerequisites) : base(config, prerequisites) | ||
{ | ||
var fje = config.GetConfig("fork-join-executor"); | ||
MaxParallelism = ThreadPoolConfig.ScaledPoolSize( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Re-use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We might actually need to copy HOCON lines over and make them part of the executor config in the future, because having one part of the system depending on a config of another part can be a point of confusion for the end user |
||
fje.GetInt("parallelism-min"), | ||
fje.GetDouble("parallelism-factor", 1.0D), // the scalar-based factor to scale the threadpool size to | ||
fje.GetInt("parallelism-max")); | ||
} | ||
|
||
public int MaxParallelism {get;} | ||
|
||
public override ExecutorService Produce(string id) | ||
{ | ||
Prerequisites.EventStream.Publish(new Debug($"ChannelExecutor-[id]", typeof(FixedConcurrencyTaskScheduler), $"Launched Dispatcher [{id}] with MaxParallelism=[{MaxParallelism}]")); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
return new TaskSchedulerExecutor(id, new FixedConcurrencyTaskScheduler(MaxParallelism)); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// INTERNAL API | ||
/// | ||
|
@@ -306,6 +326,8 @@ protected ExecutorServiceConfigurator ConfigureExecutor() | |
return new CurrentSynchronizationContextExecutorServiceFactory(Config, Prerequisites); | ||
case "task-executor": | ||
return new DefaultTaskSchedulerExecutorConfigurator(Config, Prerequisites); | ||
case "channel-executor": | ||
return new ChannelExecutorConfigurator(Config, Prerequisites); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is how we actually pass the new executor into dispatcher configurations. |
||
default: | ||
Type executorConfiguratorType = Type.GetType(executor); | ||
if (executorConfiguratorType == null) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really the right configuration, rather than a hard thread count of 4.