diff options
| author | QemmHD <290605352+QemmHD@users.noreply.github.com> | 2026-11-25 16:05:35 -0500 |
|---|---|---|
| committer | QemmHD <290605352+QemmHD@users.noreply.github.com> | 2026-11-25 16:35:47 -0500 |
| commit | 6b09de493cef367f2fd48c1e73583a277732c9ff (patch) | |
| tree | 610a6796cc52d4d4aa5b5adf302506d358e9ac64 /runtime/src | |
| parent | db1a22d290f5e86fff9282fce3d4e02e788b05b4 (diff) | |
dstorage: reads into physical pages wait for the title's Submitclaude/dstorage-hold-page-reads
A queue with auto-submit on submits itself once the entries enqueued
since the last submit reach half its capacity. A request whose
destination is a physical page list names its pages through
DestinationPageArray, a pointer into the title's own page-number table,
and the worker reads that table only when the request runs
(page_transfer). The title fills the page table just before Submit. So a
read started by the self-submit found page 0 (the entry failed) or the
number the slot held before (the data landed in a page that now belongs
to something else, with no error).
A self-submit now stops at the first read into physical pages. That read
and every entry behind it wait for the title's Submit, in order, so a
status entry, fence or event behind a held read still comes after it. A
full queue submits the held entries too, since the title cannot call
Submit while it waits in an enqueue. Close submits everything, as
before. A hold also ends after LEONIDA_DSTORAGE_HOLD_MS (2000 ms unless
set; 0 means no limit), so a path that never calls Submit cannot stall
for good. LEONIDA_DSTORAGE_HOLD_PAGES=0 restores the old self-submit of
everything.
"[rt] ds-hold" counts self-submits, held reads, full-queue and timed
releases, and destination lists that named page 0 when written. It is
printed at each power of two of the counter that moved
(runtime/src/dstorage_hold.h).
The idea is from Marvisak/VIctory eddde73; it also appears in
fxceless/victory-fork 79cfdd9. Written anew for this queue.
Test: dstorage_test, test_page_reads_wait_for_submit: a list changed
between the self-submit and Submit, a list still empty at the
self-submit, a full queue, the default and an explicit time limit, no
limit, the switch, and the page-0 counter.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SR1Fv7eQNgZjM6miWPKjHf
Diffstat (limited to 'runtime/src')
| -rw-r--r-- | runtime/src/dstorage_hold.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/runtime/src/dstorage_hold.h b/runtime/src/dstorage_hold.h new file mode 100644 index 000000000..1695c1e7c --- /dev/null +++ b/runtime/src/dstorage_hold.h | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | // Counters of the DirectStorage queues' rule "reads into physical pages wait for the title's Submit" | ||
| 2 | // (shims/dstorage.cpp, docs/directstorage.md). Process-wide, so the log line and the test read the same numbers. | ||
| 3 | #pragma once | ||
| 4 | |||
| 5 | #include <atomic> | ||
| 6 | #include <cstdint> | ||
| 7 | |||
| 8 | namespace leonida::dstorage { | ||
| 9 | |||
| 10 | struct HoldStats { | ||
| 11 | std::atomic<uint64_t> self_submits{0}; // a queue half full submitted itself | ||
| 12 | std::atomic<uint64_t> held_reads{0}; // reads into physical pages such a submit left for the title's Submit | ||
| 13 | std::atomic<uint64_t> full_releases{0}; // a full queue submitted its held entries (the title waits in an enqueue) | ||
| 14 | std::atomic<uint64_t> timed_releases{0}; // LEONIDA_DSTORAGE_HOLD_MS ran out before the title's Submit | ||
| 15 | std::atomic<uint64_t> page0_entries{0}; // destination page lists that named page 0 when their data was written | ||
| 16 | }; | ||
| 17 | |||
| 18 | inline HoldStats& hold_stats() { | ||
| 19 | static HoldStats stats; | ||
| 20 | return stats; | ||
| 21 | } | ||
| 22 | |||
| 23 | } // namespace leonida::dstorage | ||