DirectStorage: keep unpacked file requests on disk and read them back (plan) #2863

Open
opened 2026-11-26 19:48:25 +00:00 by ozimchuk · 0 comments
ozimchuk commented 2026-11-26 19:48:25 +00:00 (Migrated from github.com)
Contributor

Imported from ivall/xcl. Originally posted by ozimchuk on 2026-11-26T19:48:25Z.


Plan: an opt-in XCL_DSTORAGE_CACHE=<folder>. XCL keeps the unpacked bytes of each decoded DirectStorage file request (zlib and BCPack) in the folder. When the same request comes again (same file, size and modification time, offset, source size and decoding), XCL reads the kept bytes instead of decoding again. That covers the same run and every later one. The title's files are not touched, and nothing is title-specific.

Why: the CPU decodes the same streamed data again in every run. On a retail title under Linux, the first 80 s decode 3.5–4.4 GB of zlib output and 80–120 MB of BCPack blocks, which costs 10–14 s of worker time. With the bytes kept from an earlier run, that drops to 0.1–0.3 s, and the time requests spend on the DirectStorage worker roughly halves. Even the first run finds 2,000–5,000 of its own requests again. #1722 (zlib-rs) makes the decode faster, and this avoids it; the two do not conflict.

Limits I'd propose:

  • No eviction: entries stop at XCL_DSTORAGE_CACHE_MB (default 32 GB).
  • Writes go through a thread of their own, so a request never waits for the disk.
  • Each entry is checked against an Adler-32 when read.
  • XCL_DSTORAGE_PARALLEL_DECOMPRESS keeps its own path, without the cache.

I have it working, about 570 lines, 200 of them tests. I'd open it as a draft PR unless this is a direction you'd rather not take.

AI-assisted. Claude Code, Claude Opus 5.5 wrote the code, made the measurements and wrote this.

<!-- greyfinch-sync:ivall/xcl:issue:6634023614 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/issues/2863). Originally posted by [ozimchuk](https://github.com/ozimchuk) on 2026-11-26T19:48:25Z. --- **Plan:** an opt-in `XCL_DSTORAGE_CACHE=<folder>`. XCL keeps the unpacked bytes of each decoded DirectStorage file request (zlib and BCPack) in the folder. When the same request comes again (same file, size and modification time, offset, source size and decoding), XCL reads the kept bytes instead of decoding again. That covers the same run and every later one. The title's files are not touched, and nothing is title-specific. **Why:** the CPU decodes the same streamed data again in every run. On a retail title under Linux, the first 80 s decode 3.5–4.4 GB of zlib output and 80–120 MB of BCPack blocks, which costs 10–14 s of worker time. With the bytes kept from an earlier run, that drops to 0.1–0.3 s, and the time requests spend on the DirectStorage worker roughly halves. Even the first run finds 2,000–5,000 of its own requests again. #1722 (zlib-rs) makes the decode faster, and this avoids it; the two do not conflict. **Limits I'd propose:** - No eviction: entries stop at `XCL_DSTORAGE_CACHE_MB` (default 32 GB). - Writes go through a thread of their own, so a request never waits for the disk. - Each entry is checked against an Adler-32 when read. - `XCL_DSTORAGE_PARALLEL_DECOMPRESS` keeps its own path, without the cache. I have it working, about 570 lines, 200 of them tests. I'd open it as a draft PR unless this is a direction you'd rather not take. AI-assisted. Claude Code, Claude Opus 5.5 wrote the code, made the measurements and wrote this.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl#2863
No description provided.