liveBook · Manning

Predictability

As explained in Memory Safe C++

Predictability is the property of an operation having an execution time that can be bounded in advance.

A safety-critical system that usually responds in 10 milliseconds but occasionally takes 500 milliseconds may be worse than one that always responds in 50 milliseconds. A fast typical response does not guarantee a timely response when it matters. section 1.3

Predictability means that an operation’s execution time can be bounded in advance. It differs from determinism: a deterministic computation produces the same result for the same inputs, while a predictable operation has a known timing bound. Without such a bound, a system cannot guarantee a timely response. section 1.4.2

Bounding the slowest run is difficult on modern hardware. Caches, pipelines, and branch prediction can make the same instruction sequence take different amounts of time. Worst-case execution time (WCET) analysis addresses the question of how long execution can take. section 1.4.2

Storage choices affect whether allocation costs can be bounded:

  • Stack storage is obtained by adjusting the stack pointer once for the function’s frame. section 1.4.2
  • A general-purpose heap allocator does work that depends on heap state, so a cost measured early may not hold later. Real-time allocators bound that cost. section 1.4.2
  • A common alternative is to allocate what the system needs before it goes live, then stop allocating. section 1.4.2

Pacemaker timing

A pacemaker must deliver impulses at precise intervals. If impulse-generation code sometimes takes 10 microseconds and sometimes 10 milliseconds because garbage collection runs, stimulation can become irregular. The concern is not just speed, but whether the slowest execution can meet the timing requirement. section 1.4.2

Predictability is one part of safety work. Identify hazards throughout the system’s life, verify beyond expected conditions, and design for failures and unexpected inputs. section 1.3

How Memory Safe C++ covers it

How deep it goes
Defines timing bounds, distinguishes determinism, and explains hardware and allocation complications without detailing WCET analysis methods.
Examples
Compares variable and consistent response times and illustrates timing risk with a pacemaker.
What you can do after
Evaluate/understand whether predictable timing supports a system’s response requirements and why allocation choices matter.
How it connects
Connects predictability to determinism, worst-case execution time, memory allocation, and safety verification.

Also explained in

Compare how 3 books explain predictability →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Memory Safe C++. The section links point to the parts of the book it draws on.