ScarletNX / ScarletNX documentation / Regression inventory for the buffer cache rewrite · ← previous · next →
Change detection
D1. Write tracking keeps one generation for each 4K page in a shared table.
- Without the rule: a scan protects again the pages that it reports. With no shared table, the question of one cache
entry hid a write from another entry over the same memory.
- Comment:
buffer.c, above WW_LEAF_SHIFT.
- Check:
check_wt_two_consumers in tests/vulkan_write_tracking.inc.
D2. A 4 MB leaf is scanned at most one time in each write epoch.
- Without the rule: each texture and buffer check made its own scan. One game made 5,600 scans in a frame. An epoch
starts at each submission and at the end of each wait of the stream.
- Comment:
buffer.c, above g_wleaf_seen.
- Check:
vk_ww_stats counts the leaves that the scanner and the checks scan. No test holds the count.
D3. A scanner thread scans the leaves, each scan claims its leaves, and a check waits only for a leaf in scan.
- Without the rule: a scan of a leaf takes about 9 us in one game. Done by the checks, the scans cost 2.4 k cycles of
each draw's setup on the GPU thread. One lock over all scans made checks wait out whole passes, 0.5 ms each. The
claim also keeps the order that correctness needs. The written pages are in
g_wres before the leaf says that it
was scanned, so a check of the same leaf cannot miss a page that the scan protected again.
- Comment:
buffer.c, above WW_RES_N.
- Check:
check_wt_concurrent in tests/vulkan_write_tracking.inc.
D4. The scanner visits only the leaves that a check needed at some time.
- Without the rule: one game had 15 used leaves under a top of 18090. Passes that tested every leaf below the top
were a sixth of the samples of the runtime. A pass to the last leaf of the address space read 131072 leaves at
512 GiB.
- Comment:
buffer.c, above WW_EVER_WORDS and above g_wleaf_top.
- Check: no test covers it.
vk_ww_stats gives the time of the scanner.
D5. A job on the GPU thread checks against the epoch that was newest when the job started.
- Without the rule: a later submission can start an epoch while the job runs. What the CPU wrote for that submission
is for the later job to see. The rule also gives the scanner the time until the job starts.
- Comment:
buffer.c, the member ww_stream of t_buffer.
- Check:
check_stream_epoch in tests/vulkan_headless.c.
D6. The pages that a scan found get a generation newer than every baseline taken before.
- Without the rule: those baselines were taken before the scan protected the pages again, and their caches possibly
read memory before the writes. The write would be lost for them.
- Comment:
buffer.c, ww_take_scanned.
- Check:
check_wt_record_submit in tests/vulkan_write_tracking.inc.
D7. A write through one address of a page is marked at the other addresses of that page.
- Without the rule: a view and its source are the same pages. A cache over one address did not learn of a write
through the other. Past 64 other addresses the answer for the range is -1, and the caches compare contents.
- Comment:
buffer.c, above WW_PEER_N and above WW_PEERS.
- Check:
check_wt_alias, check_wt_shared and check_wt_hot_alias in tests/vulkan_write_tracking.inc.
D8. Memory that changes with no write that the tracker sees is marked written by the next query.
- Without the rule: decommitted pages read as zero, and no scan reports them.
- Comment:
buffer.c, above WW_CHG_N (the code is vk_mem_changed).
- Check:
check_wt_runtime_writes in tests/vulkan_write_tracking.inc.
D9. A full list of written ranges grows its last range, so the tracker marks more pages and never fewer.
- Without the rule: a dropped range is a lost write. With the rule, a cache over the extra pages only checks its
contents one time.
- Comment:
buffer.c, above WW_PEER_N, above WW_CHG_N and at ww_note.
- Check: no test covers the full lists.
D10. A scan skips the pages that an import of unified memory holds.
- Without the rule: the driver takes those pages again at each submission, writable. A scan reported that as writes
of the CPU. After a scan protected them, the driver faulted every one of them in again.
vk_written_since cannot
answer for those pages.
- Comment:
buffer.c, ww_scan_free.
- Check: no test covers it directly.
tests/vulkan_uma_imports.inc runs imports with the tracker on.
D11. A page that a landing wrote counts as written by the CPU only when its bytes differ from the landing's.
- Without the rule: the ownership lets go of landed pages, and a page that is watched again reads as written. The
next scan reported all of them. Taken for a CPU write, the report made targets that were drawn there after the
publish give up their pixels for the older bytes of memory. One game's reflection array, drawn whole over the
memory of the previous one, kept seven layers of it, NaN included. The bytes are read through the mirror of the
pool, which no trap covers.
- Comment:
buffer.c, above WwLanded (the code is vk_ww_landed and landed_unchanged).
- Check:
check_wt_owned in tests/vulkan_write_tracking.inc.
D12. The list of landed pages stays sorted by a merge of the new entries.
- Without the rule: each landing sorted all the entries again with
qsort for its few new ones. That was a
fourteenth of one game's GPU thread.
- Comment:
buffer.c, above g_wland_sorted and landed_sort.
- Check:
check_wt_landed_order in tests/vulkan_write_tracking.inc.
D13. The clock of the tracker moves only when a query marks pages, and at its wrap the caches compare contents
for good.
- Without the rule: baselines cannot be ordered against a wrapped clock. A clock that moved at each query would reach
its wrap in a session, at thousands of queries a frame.
- Comment:
buffer.c, vk_written_since.
- Check: no test covers the wrap.
D14. A leaf that a range covers whole, and that has no table, gets only its newest generation.
- Without the rule: the kernel side can unmap gigabytes at once, and a table for each leaf would be made for nothing.
- Comment:
buffer.c, ww_mark_pages.
- Check: no test covers it.
check_wt_runtime_writes covers a decommit of a small range.
D15. With write tracking, a buffer of its own is checked only when its memory was written.
- Without the rule: each check hashed the range. The exception is a source of the copy engine on pool pages, which
is compared. Those pages can be written where the tracker does not look, and what a copy lands in keeps a stale
byte for good.
- Comment:
buffer.c, buf_get, at tracked.
- Check:
check_dma_untracked_source in tests/vulkan_headless.c.
D16. With no write tracking, a stable buffer of its own is checked every few submits, and a big one is sampled
between.
- Without the rule: each check hashed the whole range. The cost of the rule is that a CPU write shows that many
submits late. A write of the GPU front end always shows at once.
- Comment:
buffer.c, buf_get.
- Check: no test runs the path with no tracking.
check_wt_sampled covers the samples.
D17. The sample hash serves only the checks that write tracking cannot answer.
- Without the rule: a stable range that the CPU rewrites with the same bytes took the samples at each write. When
the tracker stops its answers for a range, the next check hashes it whole first.
- Comment:
buffer.c, buf_get, at told.
- Check:
check_wt_sampled in tests/vulkan_write_tracking.inc.
D18. After a GPU-side write, a buffer of its own copies the stamped pages again and does not hash the range.
- Without the rule: a write to one page of a big buffer hashed all of it, most of one game's GPU thread. A small
range is hashed all the same. GPU-side writes beside it stamp its pages, and in one game 760 such ranges a frame
were 78% unchanged. Each copy ended the rendering pass.
- Comment:
buffer.c, patch_dirty, and buf_get at the call.
- Check: no test names
patch_dirty. The copy statistics of the buffer cache give the copies by reason.
D19. A big buffer of its own takes only the pages written since it last matched memory.
- Without the rule: a write anywhere in a 64 MiB window made the cache hash and copy all of it, again at each submit
until it held still for two checks. In one game's underground, where terrain streams in, that was most of each
hitch. The limit is
PATCH_MIN, 256 KiB.
- Comment:
buffer.c, above PATCH_MIN (the code is patch_own).
- Check:
check_pass_breaks in tests/vulkan_pass_breaks.inc, the case of a write between two draws.
D20. The written runs of a patch are copied as they are, however many they are.
- Without the rule: past 64 runs, they were joined into one copy from the first to the end of the last. One game's
CPU writes pages all over a 64 MiB window of indices. It copied about 50 MB a frame that way, a quarter of its GPU
thread.
- Comment:
buffer.c, above Patch.
- Check: no test covers more than 64 runs.
D21. The copy of a patch waits for the draws before it and for an earlier patch.
- Without the rule: the draws recorded before must read the old bytes, and the draws after must read the new bytes.
- Comment:
buffer.c, patch_apply.
- Check:
check_pass_breaks in tests/vulkan_pass_breaks.inc. The first draw reads the old bytes and the second
the new.
D22. Write tracking answers by GPU address, run by run of the host memory behind the range.
- Without the rule: a range that the GPU maps from several pieces of guest memory has no one host pointer. It had no
answer and was hashed whole at every check. In one game's matches that was 140 GB every 600 frames, nearly all of
its GPU thread.
- Comment:
buffer.c, written_since_gva.
- Check:
check_wt_pieces in tests/vulkan_write_tracking.inc asks the same question for a texture.
D23. Data with no buffer of its own goes into staging in one pass that hashes and copies.
- Without the rule: the bytes were read two times, for the hash and then for the copy. That was half of one game's
GPU thread. The bytes are hashed where they are, because the destination can be write-combined staging that is slow
to read back.
- Comment:
buffer.c, buf_get, and cmd.c, vk_hash_copy.
- Check:
check_hash_copy in tests/vulkan_headless.c.
D24. The content hash is XXH3 with the loop that the CPU supports.
- Without the rule: the checks of the buffers hashed hundreds of megabytes a frame in one game. XXH3 keeps the
quality of XXH64 at about three times its speed, 60 GB/s on a Zen 4 core against 19.
- Comment:
cmd.c, above the XXH3 include block before vk_hash.
- Check:
check_hash_copy holds the hash values equal. No test holds the speed.
D25. A compare of a pending result with its original bytes reads only the pages that tracking saw written.
- Without the rule: a storage range of an Ounce program is up to 16 MiB. One written page in it had every byte
compared, a tenth of one game's CPU time.
- Comment:
buffer.c, above org_holds.
- Check:
check_wt_compares in tests/vulkan_write_tracking.inc.
D26. Write tracking stands in for the compare that tells if a pending result can be copied over guest memory.
- Without the rule: every draw that binds memory under pending results asks this of each result. The compare made
the walk quadratic. A frame of 200 composed bindings spent a fifth of the GPU thread in
memcmp. The tracker sees
a write from the next epoch on. A host with no tracking compares.
- Comment:
buffer.c, above copyable_span.
- Check:
check_wt_compares in tests/vulkan_write_tracking.inc.
D27. A span on a page that the result does not map counts as unchanged.
← previous · next →