Granularity¶
Category: Foundations · Status: stub · Lessons: chapter 07, Parallelism
One line: How big the pieces of work handed to separate tasks are: too coarse leaves cores idle, too fine spends more on coordinating the pieces than on the work in them.
Also called: task granularity, coarse-grained, fine-grained.
How it connects¶
- See also: Oversubscription, Speedup and Amdahl's law
In each language¶
| Rust | Rayon's with_min_len ↗ stops a parallel iterator splitting below a given length |
| Java | ForkJoinTask ↗ gives a rule of thumb: a task should perform more than 100 and less than 10000 basic computational steps |
| Python | Executor.map ↗ with ProcessPoolExecutor takes a chunksize; a larger one can greatly speed up long iterables |
| C# | Custom partitioners ↗ group loop iterations into ranges when each one does little work |
Where to read more¶
- In the books: Pro TBB, Michael Voss, Rafael Asenjo, James Reinders — ch. 16, 'Tuning TBB Algorithms: Granularity, Locality, Parallelism, and Determinism'
- In the books: Grokking Concurrency, Kirill Bobrov — ch. 7, 'Decomposition' → 'Granularity'
- Notes: granularity - async ↗
- Reference: Wikipedia: Granularity (parallel computing) ↗