Skip to content
About
Main content

What it costs to take a resource back

Why does memory need an admission gate while CPU and disk are scheduled, and what does the gate force you to estimate?

What does it cost to take a resource back?

Ownership and Residency were about one consumer using memory well. This article is about arbitration: many consumers share one pool, and someone must decide who gets what. Everything in it follows from one property. Take any machine resource and ask: what does it cost to take it back from a holder in the middle of use?

Resource (cost of taking it back)Control mechanism
CPUone context switch, ~1–5 µscontinuous scheduling
Disk bandwidthfinish the current I/Oqueue and reorder
Networkone packetshape and pace
Memory capacityeverything the holder has built so far?

( means taking a resource away from a holder who has not finished with it.)

For memory, the state is the work. Imagine a that has spent four minutes building a 40 GB hash table. If you take 40 GB away from it, you do not slow the join down. You destroy it.

An admission gate is a check at the door: "may this query start, and with how much memory?" And an admission gate always brings an estimation problem with it, because you must know the demand before the demand exists. This one fact generates the whole article. There are three mechanisms (grants, admission, pressure signalling) and one problem under all of them: the estimate is wrong, and it is wrong in a known direction.

The core tension

You can run the gate in two ways:

Reserve conservatively
Buysisolation, predictable latency, failures you can attribute, higher concurrency
Costsmemory reserved and never used; queries queued that would have fitcorrelated OOM when peaks coincide
Assumesnothingthat the peaks of different queries are independent
Who pays when wrongthe queued query, visiblyan arbitrary query, invisibly

Where you stand on this line is a statement about how strongly you believe your workload's peaks are correlated (happen at the same time). The recurring problem here is that independence is assumed but false: components are assumed to peak at different times, and they usually peak together. Monday at 9 am is the example.