Skip to content
About
Main content

Five limits and their escapes

Which five things are impossible in memory management, and what does each way of living with them cost?

Dmitri's post-mortem

After the fourth incident, Dmitri Volkov writes a post-mortem for the whole team. He does not list bugs. He lists what the machine does not allow, and for each limit, what Voltara chose to do about it. Amara reads it and decides to turn it into a one-page note for the team. This article is that note, in full.

What this mechanism forbids

Five things are impossible. No mechanism here gets around any of them. Each one can only be worked around at a price.

  1. You cannot time-share capacity. The state is the work, so taking memory back destroys the work instead of delaying it. This is the root constraint, and everything else follows from it.
  2. You cannot know a footprint before producing it. The estimate inherits the optimizer's error distribution (Where the grant number comes from: the most important item in this article). That distribution has a , and no amount of statistics work removes it.
  3. You cannot account for memory you did not allocate. Any holder outside your is invisible. In a system that runs user code (, libraries), such a holder always exists.
  4. You cannot make eviction free when eviction has correctness preconditions. Evicting a depends on the being flushed first. So the 's own latency is not bounded by the buffer pool.
  5. You cannot isolate bandwidth by bounding bytes. Capacity and bandwidth are different resources with different . The mechanisms here handle only one of them: capacity.

The escapes, and what each costs

An "escape" is a way to live with a limit. None is free, except two.

EscapeBuysCosts
Take ownership from the layer below (buffer pool, , off-heap)policy informed by knowledge the layer below lacksyou now own the bugs it used to prevent: dangling pointers, leaks, fragmentation
Declare intent instead of inferring it (scan , registered consumers)beats any adaptive policyrequires universal participation; the one sets your reserve
Ration at admission (grants, footprint admission)attributable failure at zero costmemory reserved and never used; queries queued that would have fit
on ordinary dayscorrelated, total failure on the day the peaks coincide
completion instead of failurethe , the , and a feedback loop into the pressure it relieves
Reformulate the operation ()removes the need for the mechanism entirelyavailable only when the algebra permits; nothing to trade
Measure instead of estimate (, ghost lists)ground truth beats any estimatoronly works for repeated plans and repeated access
Buy RAMeverything, brieflythe return curve of added memory is concave (each GB helps less than the last), and data grows faster than the budget

The two rows with no real cost are declare intent and reformulate the operation. They are the ones practitioners reach for last. That is this mechanism's most useful practical lesson. Before you tune a policy, ask: can the caller tell me what it is going to do? Before you build a spill path, ask: can the operation be rewritten so that it does not need to hold the state at all?