Skip to content

[Engine] SSD conversation tier: a stalled spill disk aborts the engine via the 60 s watchdog (spill writes are not counted as I/O progress); a timeout that falls back to re-reading would keep the server up #6726

Open

Description

@nabe2030

Area

[Engine] (speed, kernels, models, the server and API)

Desktop app, Terminal or source?

Source (START-HERE.bat, setup.sh or a build)

What happened

This is about what the SSD conversation tier does when the spill disk stops answering. The tier itself works well for us: in an OpenCode-like pattern, a 377,705-token main conversation evicted by 6 short ones came back in 4.25 s from the tier (6,294 MiB read in 3.08 s; the background write took 7.87 s), against 336.5 s without it. In a real OpenCode session where 4 subagents ran at once (five conversations of up to 301K tokens taking turns on one engine; 18 evictions), conversations came back 6 times from the tier (1.2–2.5 s; one of them the 113K-token main conversation) and 4 times from the writer's RAM (0.5 ms), and no evicted conversation had to be re-read.

Our setup puts --conversation-spill-dir on a second consumer NVMe, not on the drive with the model, so that spill writes do not wear the system disk. With the default directory (<data>/conversation-spill), the spill disk is the model's disk, and a stall there stops the engine anyway. With a separate spill disk, the tier adds a new way for the engine to stop.

From reading the source (tag v0.2.20, engine 0.1.66; v0.2.18 and v0.2.19 behave the same), errors on the spill disk are handled gracefully, but a stall is not, and ends in abort().

Errors (handled well):

  • A write that fails (ENOSPC, EIO, rename/fsync error) removes its temporary file. spill_write logs "could not spill …" and the conversation is dropped. The engine and the request go on (conversation_spill.hpp:320, with the write at :339; the writer thread's catch (...) at :709).
  • A read-back that fails (I/O error, bad hash, RAM refusal) logs "… the prompt is read again", and the request re-reads its prompt (generate.cpp:19468-19487).

A stall (not handled):

  • The serve thread waits for the disk with no time limit in four places:
    1. BackgroundWriter::push() blocks while one image is in flight and one is queued (conversation_spill.hpp:659). It is called from the evict sink (generate.cpp:14086).
    2. The RAM gate's eviction loop calls spill_writer->wait_idle() so that the freed memory shows up (generate.cpp:14319). Taking back an image the writer still holds also waits (generate.cpp:19424).
    3. The RAM floor after a capture writes synchronously on the serve thread (spill_put, generate.cpp:14400).
    4. The read-back (take_serial, generate.cpp:19468) reads a multi-GB file on the serve thread.
  • None of these report progress to the stall watchdog.
    • The spill write is called without SessionWriteOptions::progress/phase (conversation_spill.hpp:339), and the read-back limits get no progress.
    • Session SAVE/RESTORE does set both (generate.cpp:18496, 18599, 18625), so it gets an explicit allowance through session_phase_limit_s.
  • The watchdog (generate.cpp:16157-16213) calls abort() after STRATA_WATCHDOG_S (default 60 s) without a beat.
    • It extends this up to STRATA_WATCHDOG_IO_S (default 600 s) only while file_tier_activity() grows. That counts major faults plus read_bytes from /proc/self/io, reads only (generate.cpp:1792).
    • So in cases 1–3, a spill write that makes no progress for 60 s aborts the engine. In case 4, a read that makes no progress at all aborts it after 60 s. A slow read that still moves data waits up to 600 s.
  • After the abort:
    • The request fails, and every parked conversation (RAM tier, and the SSD tier unless --conversation-spill-persist is on) is lost.
    • The server starts a new engine on the next request, about 80 s on this machine for a 524K configuration.
    • If the I/O is stuck in an uninterruptible sleep, the process cannot exit until the device answers.

Why a timeout plus fallback seems better than an abort here. The tier is an optimization: losing one parked conversation costs one re-read, while the abort costs every parked conversation and a restart. Today a stalled spill disk is treated like a stalled GPU, although the tier already has an answer for every other spill failure: drop the entry and re-read.

Possible approaches (opt-in or default, your call):

  1. Bounded waits on the serve thread.
    • Give push() and wait_idle() a deadline, for example STRATA_SPILL_WAIT_S, default 30 s, below the watchdog.
    • On timeout, do not wait for the writer:
      • In case 1, drop the conversation being evicted instead of queueing it.
      • In case 2, count the in-flight image as not freed, and let the RAM gate refuse the park as it already does when no eviction can help.
      • In case 3, skip the spill and drop the image (the existing "skip parking" line).
    • Mark the tier unhealthy and close it, as spill_ready already does when fingerprinting fails, so that later evictions do not queue behind the stuck writer.
  2. Beats for the tier's own I/O. Pass progress and phase to session_file_write/session_file_read from the spill path, as SAVE/RESTORE do. A slow but moving disk then gets the same allowance as a session file, and only a truly stuck one trips the watchdog.
  3. Read-back with a deadline. Run take_serial with a time limit, or on the writer thread with the serve thread waiting with a deadline. On timeout, log "the prompt is read again" and re-read, as on a read error. If the read thread stays blocked in the kernel, keep the tier closed from then on.
  4. At least, say it in the docs: put the SSD tier on a separate drive only if that drive is reliable, because a stall of more than 60 s there ends the engine.

(1) and (3) together keep the server up through a stalled spill disk, at the cost of re-reads. (2) alone prevents false aborts on slow disks, but not on a hung one.

Related:

Smallest steps or command that reproduce it

Not reproduced: we did not hang a disk on purpose. A way to verify the hypothesis would be to put --conversation-spill-dir on a device-mapper delay or flakey target (or a FUSE filesystem that blocks writes), then make a long conversation get evicted by short ones.

What we did run: strata serve with the SSD tier on a second NVMe, an OpenCode v2.0.24 session with subagents (18 evictions, 16 spills, 6 read-backs, 0 failures, no watchdog abort), and a synthetic evict-and-return test (numbers above).

Reproduction status

Unconfirmed static analysis (I read code or ran a scanner; I did not see it fail)

Strata version

Read on v0.2.20 (engine 0.1.66, 4920a3a). Running v0.2.18 (engine 0.1.64, 6e38f58), built from source.

Graphics card, memory and system

Ryzen AI Max+ 395 / Radeon 8060S (gfx1151), 96 GiB VRAM carve-out, ~30 GiB RAM, Linux, ROCm TheRock 7.14.1

Model, size and settings

Qwen3.8-Flash-Next UD-IQ4_XS, 524,288 context, pictures on, --conversation-cache-mib 12288, SSD tier at the default budget (32 GiB) on a second NVMe

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions