The 100 ms turn budget
The rule that refuses any data module turn longer than 100 ms on device, why tests on web and Bun do not catch it, every place the app yields for it, and guidance for new code.

On an iPhone, Exact refuses any stretch of synchronous data module work that takes longer than 100 ms. Nothing in the browser or in Bun enforces this, so code that passes every fast test can still fail on a phone with real data. This is the most important runtime constraint for anyone changing the data module.

The rule

From Exact's reference:

On Hermes each turn of an answer has 100 ms of wall clock: its call, or its resumption after a fetch, storage step or yield it awaited, until it awaits the next. A turn over it is refused as Unavailable (`walk` took 401.8 ms, over the 100 ms budget for one turn; …), and the message names the repair: await scheduler.yield() every few thousand items of a long loop.

A turn is one uninterrupted run of an answer: from its call, or from the point it resumes after an await, until its next await of a fetch, a storage step or a yield. await scheduler.yield() ends the turn, and "the answer goes on in a new one with its own 100 ms" (guide).

The constants

Constant

Value

Meaning

DEFAULT_BUDGET_MS

100.0

"The per-turn budget a module is held to, unless the host says otherwise: its own time, on the calling thread's CPU clock where there is one, with a wall backstop of ten budgets"

SLOW_LOAD_MS

50.0

A module load longer than this is journalled

DEFAULT_MAX_HEAP

64 << 20

The 64 MiB heap ceiling

The app does not override any of them.

Why tests do not catch it

    Web. "The browser keeps no such budget" (reference). bun exact.mjs test web runs the same code with no limit.

    Bun. "Bun has no scheduler". The app's helper uses optional chaining, so in Bun a yield is a no-op and nothing measures the turn.

    Small fixtures. Even on iOS, a test with two identities finishes in a few milliseconds. The failure appears at real sizes: a vault of a few dozen identities, a long agent session.

Only a run on iOS (simulator or device) at realistic data size proves a change, see Simulators and devices and the race harness in Real vault compatibility suite.

The helper

/** Cooperatively start a fresh Exact CPU turn; Bun callers simply continue. */ export async function yieldCryptoTurn(): Promise<void> { await (globalThis as …).scheduler?.yield() }

Defined in src/crypto/primitives.ts L74-L77 and exported from the crypto package.

Where the app yields

The full list of yields in the code, and the vault connect failure that produced most of them, is in Where the app yields for the turn budget.

Guidance for new code

    Any loop that does crypto per item (key derivation, signing, hashing large inputs) needs await yieldCryptoTurn() inside the loop. Exact's general advice is to yield "every few thousand items" of a cheap loop.

    Split phases: decrypt, decode, merge, encode and encrypt each get their own turn.

    "The function that yields is async, and so is every caller that awaits it."

    Never hold an invariant across a yield without rechecking it. Another answer can run in between. addFromMnemonic checks uniqueness after the derivation for this reason (me/sources.ts L33-L34).

    Keep algorithms linear in the size of a person's data.

    Try anything that scales with a vault, an inbox or a transcript on iOS at real size before calling it done.

Do you like what you are reading? Subscribe to receive updates.

Unsubscribe anytime

Comments