Storage is a map of 32-byte slots. Consecutive small variables share a slot if they fit. The first read of a slot in a transaction is cold (2100 gas); later reads are warm (100). Writing a zero slot to non-zero costs 20000.
uint128 a; uint128 b; // one slot uint256 c; bool d; // two slots
Cache storage reads in memory inside loops, and prefer `calldata` for read-only external arguments.