Imagine a scenario where a task can be divided into sub-tasks, each of which does some long running process. Assuming that this heavy task occurs only in 5/100 requests submitted to the server. Would it be wise to use a ForkJoinPool for this 5% of tasks? What are the disadvantages of splitting a small task into smaller sub-tasks and using a ForkJoinPool to run said small task?
Assume that I cannot decide whether to split or not split a task, therefore I split all tasks by default and run it on a ForkJoinPool.
I read this in the java docs recenty,
ForkJoinTasks should perform relatively small amounts of computation. Large tasks should be split into smaller subtasks, usually via recursive
decomposition. As a very rough rule of thumb, a task should perform more than 100 and less than 10000 basic computational steps, and should avoid indefinite looping. If tasks are too big, then parallelism cannot improve throughput. If too small, then memory and internal task maintenance overhead may overwhelm processing.