PR #5241 ยท stacked on #5139 ยท permalinks at head 96c48d50, removed code at base 68bd259c
Two pages on this PR. This one: why the hold got shorter.
Background. A rollout snapshot saves in-flight rollouts so a crashed run can resume them. While it captures state, it holds the data-plane barrier, so every rollout waits. The time spent under it is the hold. Staging keys are listed to check that every row the saved state points at still exists. A TQ capture copies TransferQueue's state into memory while the barrier is held, so the slow disk write can happen after rollouts resume. The copy (the "view") stays in the storage actors' memory until it is written and released. Dotted words have a short explanation: hover or tap them.
Why it should be faster. Three changes. (1) The ~9 s recovery-state build moves to a thread, so the listings and the capture happen while it runs. (2) The new nrl_list_keys returns keys only, not every key's tags: 4.84 s โ 1.02 s at 2.6M keys. (3) Staging is listed once, and Gym's check reuses that listing.
What does not get faster. The build itself (still ~9 s, now the floor of the hold). The listings and the controller capture are calls on one TQ controller actor that runs one call at a time, so they still wait for each other there. The benchmark does not include Gym's check, so the third change is not in the numbers.
Widths use 50 px per second where the PR measured a number (build, staging listing, totals). Small boxes are not to scale.
capture(), before
# controller event loop, barrier held env.check_against_cut(cut) # Gym lists staging itself, with tags await check_replay() # KV_LIST, with tags state = build_recovery_state() # ~9 s, on the loop await check_staging() # lists staging again, with tags view = await tq_capture() # retain a TQ view
capture(), after
# controller event loop, barrier held env.check_against_cut(cut) phases = { "replay_inventory": check_replay(), # keys only "recovery_state": to_thread(build_recovery_state), # maps copied first, on the loop "staging_inventory": check_staging(env), # list once; Gym check, then RL check "tq_capture": tq_capture(), } results = await run_capture_phases(phases) # all start now; on failure, release the view
Real code: capture, _run_capture_phases, list_staging_keys, list_sample_ids.