Skip to main content

SAFEPOINT_STRIDE

Constant SAFEPOINT_STRIDE 

Source
pub const SAFEPOINT_STRIDE: u64 = 1024;
Expand description

How many instructions run between two budget checks.

A budget check reads an atomic and a clock, and doing that per instruction would cost more than most instructions do. Doing it per call would let a tight arithmetic loop run unbounded. A fixed stride is the arrangement that bounds both: the run notices a cancellation within a known number of instructions, whatever it is doing.

It is public because it is the arithmetic of a contract rather than a tuning knob. ADR 0040 states every bound a stop mode promises in terms of it, and crates/cove-runtime/tests/responsiveness.rs measures each of them, so moving this number moves a stated maximum and costs both.