Package uk.ac.starlink.util
Class SplitPolicy
java.lang.Object
uk.ac.starlink.util.SplitPolicy
Defines the details of a concurrency policy as used by SplitProcessor.
- Since:
- 5 Nov 2019
- Author:
- Mark Taylor
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final short
Default value for maximum average number of subtasks per core.static final int
Default value for minimum subtask size.static final SplitPolicy
Default splitting policy. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a policy with default configuration.SplitPolicy
(Supplier<ForkJoinPool> fjPoolSupplier, int minTaskSize, short maxTasksPerCore) Constructs a policy with supplied configuration options. -
Method Summary
Modifier and TypeMethodDescriptionReturns the ForkJoinPool used by this policy.short
Returns the maximum number of tasks (on average) to be executed on each core as a result of decomposition, or zero for no limit.int
Returns the smallest task size used by this policy.toString()
boolean
willAttemptSplit
(Splittable<?> content) Indicates whether an attempt should be made to split a splittable in order to process it.
-
Field Details
-
DFLT_MIN_TASK_SIZE
public static final int DFLT_MIN_TASK_SIZEDefault value for minimum subtask size. The current value for this is conservative, in that it will not result in concurrency for relatively small jobs. The (JDK8)ForkJoinTask
javadocs recommend as a rough rule of thumb a value in the range of 1e2-1e4 steps, so this possibly could be reduced.- See Also:
-
DFLT_MAX_TASKS_PER_CORE
public static final short DFLT_MAX_TASKS_PER_COREDefault value for maximum average number of subtasks per core. The value of 8 is suggested by the example parallel computation framework sketch in the (JDK8)Spliterator
javadocs.- See Also:
-
DFLT_POLICY
Default splitting policy.
-
-
Constructor Details
-
SplitPolicy
public SplitPolicy()Constructs a policy with default configuration. -
SplitPolicy
Constructs a policy with supplied configuration options.- Parameters:
fjPoolSupplier
- supplier for fork/join pool for execution, or null to use the common pool; if non-null this supplier will be used a maximum of once for lazy acquisitionminTaskSize
- smallest acceptable size of sub-task to split tasks into, or non-positive value for default (DFLT_MIN_TASK_SIZE
)maxTasksPerCore
- maximum number of tasks (on average) to be executed on each core as a result of decomposition, or zero for no limit, or negative value for default limit (DFLT_MAX_TASKS_PER_CORE
)
-
-
Method Details
-
getForkJoinPool
Returns the ForkJoinPool used by this policy.- Returns:
- forkjoinpool
-
getMinTaskSize
public int getMinTaskSize()Returns the smallest task size used by this policy.- Returns:
- smallest acceptable size of sub-task to split tasks into
-
getMaxTasksPerCore
public short getMaxTasksPerCore()Returns the maximum number of tasks (on average) to be executed on each core as a result of decomposition, or zero for no limit.- Returns:
- maximum tasks per core, or zero
-
willAttemptSplit
Indicates whether an attempt should be made to split a splittable in order to process it. If it's too small for instance, false will be returned.- Parameters:
content
- splittable- Returns:
- true iff processing will try to split content
-
toString
-