PC-Storage: DirectStorage on Windows, io_uring on native Linux, safe portable I/O fallback #33

Open
opened 2026-11-26 21:02:00 +00:00 by github-bot · 1 comment
Owner

@⁠ProhorovIlja on GitHub · 2026-11-21 23:07 UTC · original

Use implemented portable native_asset_stream fallback (PR #29) as a correctness oracle: bounded reads, future completion, cancellation, checksum and EOF protection. Implement Windows overlapped IOCP then DirectStorage with valid installed runtime/GDeflate decoder, and Linux io_uring+portable fallback on verified kernel. No assumption a retail game uses GDeflate or that direct DLL swap helps. Add deterministic source-built legal compressed data, cancel/race/queue-full/truncation/OOM tests and measure p50/p95/p99 stalls, CPU cost, actual NVMe throughput, file cache behavior. Never upload title assets/EXE into CI.

2026-11-22 portable native baseline completed

PR #29 merged a source-built portable Windows/Linux worker-thread file reader with bounded chunk sizes (4 MiB), async futures, cancellation, overflow/EOF checks, FNV-1a fixture integrity and shutdown draining. On Linux+Windows Actions run 44960097323 all tests passed: generated synthetic 2 MiB file, 64 async chunks, checksum, missing/invalid/cancelled reads and destructor futures. An additional worker startup failure cleanup patch also passed both platforms. Source docs: NATIVE_ASSET_STREAMING.

Still pending: actual DirectStorage and io_uring runtime/backend dispatch, legal format-specific codecs, GPU uploads and measured performance against the portable reference. FNV-1a is not cryptographic authentication.

**@⁠ProhorovIlja** on GitHub · 2026-11-21 23:07 UTC · [original](https://github.com/ProhorovIlja/NativeX-Runtime/issues/33) Use implemented portable native_asset_stream fallback (PR #29) as a correctness oracle: bounded reads, future completion, cancellation, checksum and EOF protection. Implement Windows overlapped IOCP then DirectStorage with valid installed runtime/GDeflate decoder, and Linux io_uring+portable fallback on verified kernel. No assumption a retail game uses GDeflate or that direct DLL swap helps. Add deterministic source-built legal compressed data, cancel/race/queue-full/truncation/OOM tests and measure p50/p95/p99 stalls, CPU cost, actual NVMe throughput, file cache behavior. Never upload title assets/EXE into CI. ## 2026-11-22 portable native baseline completed [PR #29](https://github.com/ProhorovIlja/Scarlett-Windows-Compat/pull/29) merged a source-built portable Windows/Linux worker-thread file reader with bounded chunk sizes (4 MiB), async futures, cancellation, overflow/EOF checks, FNV-1a fixture integrity and shutdown draining. On [Linux+Windows Actions run 44960097323](https://github.com/ProhorovIlja/Scarlett-Windows-Compat/actions/runs/44960097323) all tests passed: generated synthetic 2 MiB file, 64 async chunks, checksum, missing/invalid/cancelled reads and destructor futures. An additional worker startup failure cleanup patch also passed both platforms. Source docs: [NATIVE_ASSET_STREAMING](https://github.com/ProhorovIlja/Scarlett-Windows-Compat/blob/main/docs/NATIVE_ASSET_STREAMING.md). Still pending: **actual DirectStorage and io_uring** runtime/backend dispatch, legal format-specific codecs, GPU uploads and measured performance against the portable reference. FNV-1a is not cryptographic authentication.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 21:02:00 +00:00
Author
Owner

@⁠Yoshi-233 on GitHub · 2026-11-25 02:05 UTC · original

I tested the short-read case for a future Linux io_uring backend against the portable Reader at b3087ce0ab191227dc9e7af37cab97a0b097bb98. A request for 32 bytes returned a successful kernel completion of 7 bytes after I truncated the file. An exact-read backend needs to check the byte count before it publishes the buffer. Portable Reader range and short-read checks

I built the three portable stream CTests from a clean checkout. All three passed. In a separate local probe, I submitted 64 buffered reads in batches of eight against a generated 256 KiB file. All 237,856 bytes matched both the generated input and the portable reader. The FNV-1a checksums also matched. The probe produced the same results across six runs. The host ran Ubuntu 24.04.5 x86-64, kernel 7.0.0-43-generic, and liburing 2.5 on ext4 on a SATA HDD. I confirmed io_uring_setup and io_uring_enter with strace.

Read request Raw completion (bytes) Portable Reader
0 bytes at EOF 0 Ok, empty
1 byte at EOF 0 InvalidRange, empty
16 bytes starting 7 bytes before EOF 7 InvalidRange, empty
1 byte starting 1 byte past EOF 0 InvalidRange, empty

For the truncation case, the original file covered offset 128 through 159. I prepared the 32-byte read, truncated the file to 135 bytes, then submitted it. The 7 returned bytes matched the original data. A fresh portable request after truncation returned InvalidRange. For a future backend, I would test that a previously validated request which reaches EOF early completes as ShortRead with an empty payload. These results cover buffered-read correctness. NVMe throughput and in-flight cancellation remain open.

Minimal reproducer for the 7-byte completion

Save as repro.c on Linux with the liburing development headers installed. Run cc -O2 repro.c -o repro -luring && ./repro. Expected output is requested=32 completed=7.

#include <liburing.h>
#include <stdio.h>
#include <unistd.h>

int main(void) {
    FILE *file = tmpfile();
    struct io_uring ring;
    char buf[32];
    if (!file || ftruncate(fileno(file), 4096) || io_uring_queue_init(2, &ring, 0))
        return 1;
    struct io_uring_sqe *sqe = io_uring_get_sqe(&ring);
    if (!sqe) return 1;
    io_uring_prep_read(sqe, fileno(file), buf, sizeof buf, 128);
    if (ftruncate(fileno(file), 135) || io_uring_submit(&ring) != 1)
        return 1;
    struct io_uring_cqe *cqe;
    if (io_uring_wait_cqe(&ring, &cqe)) return 1;
    int bytes = cqe->res;
    io_uring_cqe_seen(&ring, cqe);
    io_uring_queue_exit(&ring);
    fclose(file);
    printf("requested=32 completed=%d\n", bytes);
    return bytes == 7 ? 0 : 1;
}
**@⁠Yoshi-233** on GitHub · 2026-11-25 02:05 UTC · [original](https://github.com/ProhorovIlja/NativeX-Runtime/issues/33#issuecomment-7150308415) I tested the short-read case for a future Linux `io_uring` backend against the portable `Reader` at `b3087ce0ab191227dc9e7af37cab97a0b097bb98`. A request for 32 bytes returned a successful kernel completion of **7 bytes** after I truncated the file. An exact-read backend needs to check the byte count before it publishes the buffer. [Portable Reader range and short-read checks](https://github.com/ProhorovIlja/NativeX-Runtime/blob/b3087ce0ab191227dc9e7af37cab97a0b097bb98/src/native_asset_stream.cpp#L22-L40) I built the three portable stream CTests from a clean checkout. All three passed. In a separate local probe, I submitted 64 buffered reads in batches of eight against a generated 256 KiB file. All 237,856 bytes matched both the generated input and the portable reader. The FNV-1a checksums also matched. The probe produced the same results across six runs. The host ran Ubuntu 24.04.5 x86-64, kernel `7.0.0-43-generic`, and liburing 2.5 on ext4 on a SATA HDD. I confirmed `io_uring_setup` and `io_uring_enter` with `strace`. | Read request | Raw completion (bytes) | Portable Reader | | --- | ---: | --- | | 0 bytes at EOF | 0 | `Ok`, empty | | 1 byte at EOF | 0 | `InvalidRange`, empty | | 16 bytes starting 7 bytes before EOF | 7 | `InvalidRange`, empty | | 1 byte starting 1 byte past EOF | 0 | `InvalidRange`, empty | For the truncation case, the original file covered offset 128 through 159. I prepared the 32-byte read, truncated the file to 135 bytes, then submitted it. The 7 returned bytes matched the original data. A **fresh** portable request after truncation returned `InvalidRange`. For a future backend, I would test that a previously validated request which reaches EOF early completes as `ShortRead` with an empty payload. These results cover buffered-read correctness. NVMe throughput and in-flight cancellation remain open. <details> <summary>Minimal reproducer for the 7-byte completion</summary> Save as `repro.c` on Linux with the liburing development headers installed. Run `cc -O2 repro.c -o repro -luring && ./repro`. Expected output is `requested=32 completed=7`. ```c #include <liburing.h> #include <stdio.h> #include <unistd.h> int main(void) { FILE *file = tmpfile(); struct io_uring ring; char buf[32]; if (!file || ftruncate(fileno(file), 4096) || io_uring_queue_init(2, &ring, 0)) return 1; struct io_uring_sqe *sqe = io_uring_get_sqe(&ring); if (!sqe) return 1; io_uring_prep_read(sqe, fileno(file), buf, sizeof buf, 128); if (ftruncate(fileno(file), 135) || io_uring_submit(&ring) != 1) return 1; struct io_uring_cqe *cqe; if (io_uring_wait_cqe(&ring, &cqe)) return 1; int bytes = cqe->res; io_uring_cqe_seen(&ring, cqe); io_uring_queue_exit(&ring); fclose(file); printf("requested=32 completed=%d\n", bytes); return bytes == 7 ? 0 : 1; } ``` </details>
This discussion has been locked. Commenting is limited to contributors.
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.

Dependencies

No dependencies set

Reference
github/ProhorovIlja--NativeX-Runtime#33
No description provided.