Skip to content

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

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