liveBook · Manning

Granularity

As explained in Functional Design and Architecture: Examples in Haskell

Granularity is the size of the independently mutable units into which data or computation is divided.

Granularity describes the size of independently mutable units in a data structure. In a concurrent simulator, an outer map can contain separately mutable values, allowing one internal value to change without updating the whole map. section 8.2.2

Compare the two designs when multiple threads update stored values:

  • Coarse-grained design: use MVar (Map Key Value); replace values in the map and update the outer MVar repeatedly. section 8.2.2
  • Choose finer granularity when repeated updates target individual keys and concurrency benefits from distributing control across values. section 8.2.2

How Functional Design and Architecture: Examples in Haskell covers it

How deep it goes
Explains nested mutable layers and contrasts update costs, while deferring deeper STM treatment.
Examples
Compares nested MVars with a coarse-grained map in a simulator runtime.
What you can do after
Evaluate concurrent data structures by their mutation boundaries and repeated-update costs.
How it connects
Connects granularity to concurrency, STM, and key–value databases.

Also explained in

Compare how 8 books explain granularity →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Functional Design and Architecture: Examples in Haskell. The section links point to the parts of the book it draws on.