Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b852d21a54
|
||
|
|
76e89b65de |
No files matched your search
@@ -30,6 +30,23 @@ numeric core and does not move; the heading is the full version — corrected 20
|
||||
|
||||
### Fixed
|
||||
|
||||
- **The native ring-buffer tests no longer pass or fail by the scheduler's luck** (developers only). The
|
||||
hammering-writer test required the reader to keep more than half of the stream, which measured how the operating
|
||||
system scheduled two threads: on a hybrid Intel processor it failed 5 of 200 runs with the ring correct every time.
|
||||
Both concurrency tests now start the writer only once the reader is running, repeat until the reader really read
|
||||
the ring while the writer wrote it, and require that; the small-ring test's old check also passed a reader that
|
||||
started after the writer had finished (`src/native/tests/ring_test.cpp`).
|
||||
|
||||
## [0.1.0-beta.22] - 2026-10-13
|
||||
|
||||
**The twenty-second pre-release: a request the capture agent never answered is said as such, never as a crash.** The
|
||||
same unsigned installer: verify its hash against `SHA256SUMS.txt`, then *More info → Run anyway*.
|
||||
|
||||
**Updating from `0.1.0-beta.21`:** Help ▸ Check for updates, then *Restart to update* with no game running. Nothing is
|
||||
shown to accept and no game is read again: the legal documents and the detection rules (`2026.10.4`) are beta.21's.
|
||||
|
||||
### Fixed
|
||||
|
||||
- **A request the capture agent never answered is said as such, never as a crash.** When the agent stopped, or restarted
|
||||
for an update, while FrameLedger was asking it something, deleting sessions ended in the crash dialog, and turning a
|
||||
game's hooking on or off or making or withdrawing an anti-cheat exception showed *IOException* or *TimeoutException* as
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ hooking on for — and reading the graphics calls the game makes. That is why it
|
||||
resolution, the upscaler, frame generation and ray tracing apart. It is also where its limits come from. This
|
||||
page lists them in plain words; each item links to the document that has the details.
|
||||
|
||||
*Beta software: this page describes version 0.1.0-beta.21.*
|
||||
*Beta software: this page describes version 0.1.0-beta.22.*
|
||||
|
||||
## Games it will not measure
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ pages.
|
||||
|
||||
<!-- accuracy-block:begin -->
|
||||
> ⚠ **What FrameLedger actually measures today — 2026-10-13.** The software is a beta; its latest
|
||||
> **pre-release is `0.1.0-beta.21`** (2026-10-13), an unsigned installer built from that tag with its
|
||||
> **pre-release is `0.1.0-beta.22`** (2026-10-13), an unsigned installer built from that tag with its
|
||||
> checksums published beside it. The source holds the desktop app
|
||||
> (library, store import, charts, settings) and the background Agent, which records a session when a
|
||||
> game in the library runs (unless you switched its recording off), injects only into games you enabled
|
||||
@@ -167,7 +167,7 @@ Elevation is **optional — for everything.** Hooked capture is the normal path
|
||||
|
||||
## Install
|
||||
|
||||
> **The latest pre-release is `v0.1.0-beta.21` (2026-10-13); before it `v0.1.0-beta.20` (2026-10-12), `v0.1.0-beta.19` (2026-10-12), `v0.1.0-beta.18` (2026-10-07), `v0.1.0-beta.17` (2026-10-07), `v0.1.0-beta.16` (2026-10-06), `v0.1.0-beta.15` (2026-10-06), `v0.1.0-beta.14` (2026-10-06), `v0.1.0-beta.13` (2026-10-04), `v0.1.0-beta.12` (2026-10-04), `v0.1.0-beta.11` (2026-10-03), `v0.1.0-beta.10` (2026-09-28), `v0.1.0-beta.9` (2026-09-26), `v0.1.0-beta.8` (2026-09-25), `v0.1.0-beta.7` (2026-09-23), `v0.1.0-beta.6` (2026-09-23), `v0.1.0-beta.5` (2026-09-22), `v0.1.0-beta.4` (2026-09-21), `v0.1.0-beta.3` (2026-09-21), `v0.1.0-beta.2` (2026-09-17) and `v0.1.0-beta.1` (2026-09-16).** They are pre-releases: read `CHANGELOG.md`'s section for the one you install — what it measures, what it does not yet, and how to update — before installing. A source build is `docs/12_BUILD.md`.
|
||||
> **The latest pre-release is `v0.1.0-beta.22` (2026-10-13); before it `v0.1.0-beta.21` (2026-10-13), `v0.1.0-beta.20` (2026-10-12), `v0.1.0-beta.19` (2026-10-12), `v0.1.0-beta.18` (2026-10-07), `v0.1.0-beta.17` (2026-10-07), `v0.1.0-beta.16` (2026-10-06), `v0.1.0-beta.15` (2026-10-06), `v0.1.0-beta.14` (2026-10-06), `v0.1.0-beta.13` (2026-10-04), `v0.1.0-beta.12` (2026-10-04), `v0.1.0-beta.11` (2026-10-03), `v0.1.0-beta.10` (2026-09-28), `v0.1.0-beta.9` (2026-09-26), `v0.1.0-beta.8` (2026-09-25), `v0.1.0-beta.7` (2026-09-23), `v0.1.0-beta.6` (2026-09-23), `v0.1.0-beta.5` (2026-09-22), `v0.1.0-beta.4` (2026-09-21), `v0.1.0-beta.3` (2026-09-21), `v0.1.0-beta.2` (2026-09-17) and `v0.1.0-beta.1` (2026-09-16).** They are pre-releases: read `CHANGELOG.md`'s section for the one you install — what it measures, what it does not yet, and how to update — before installing. A source build is `docs/12_BUILD.md`.
|
||||
|
||||
1. Download the latest `FrameLedger.App-win-Setup.exe` from [Releases](https://github.com/poli0981/frameledger/releases). It installs into `%LOCALAPPDATA%\FrameLedger.App`; your data stays in `%LOCALAPPDATA%\FrameLedger`, and uninstalling asks before touching it.
|
||||
2. SmartScreen may warn — releases are not code-signed (free, open-source project). Verify the SHA-256 checksum published with each release, then **More info → Run anyway**.
|
||||
@@ -216,4 +216,4 @@ GPU telemetry is layered so the project never depends on a proprietary vendor li
|
||||
|
||||
---
|
||||
|
||||
**Status:** pre-release (beta). Twenty-one tagged pre-releases so far; see `CHANGELOG.md` for what each one changed and the accuracy block at the top of this file for what is and is not measured. It is not feature-complete, it certainly still has bugs, and `legal/DISCLAIMER.md` §0 says what that means for you.
|
||||
**Status:** pre-release (beta). Twenty-two tagged pre-releases so far; see `CHANGELOG.md` for what each one changed and the accuracy block at the top of this file for what is and is not measured. It is not feature-complete, it certainly still has bugs, and `legal/DISCLAIMER.md` §0 says what that means for you.
|
||||
+58
-13
@@ -2218,7 +2218,7 @@ game's engine" — was shown to the owner with #299 and released on their word.
|
||||
|
||||
**Owner-only, added to the list below:** item 16.
|
||||
|
||||
## **START HERE** — 2026-10-13, 0.1.0-beta.21: an anti-cheat beside the executable, four itch downloads that are malware, documents that scroll, Play
|
||||
## ~~**START HERE**~~ — 2026-10-13, 0.1.0-beta.21: an anti-cheat beside the executable, four itch downloads that are malware, documents that scroll, Play *(struck 2026-10-13: the head is §beta.22 below)*
|
||||
|
||||
*Status is `CHANGELOG.md` `[0.1.0-beta.21]`; this is what no other file carries. The owner's list (2026-10-13, four items,
|
||||
with screenshots of two game pages): HELLO, HELLO WORLD!'s RPG Maker path is wrong; no anti-cheat is found for Wuthering
|
||||
@@ -2277,6 +2277,34 @@ Privacy Policy 2.10 — then the release.*
|
||||
|
||||
**Owner-only, added to the list below:** item 17.
|
||||
|
||||
## **START HERE** — 2026-10-13, 0.1.0-beta.22: a request the capture agent never answered
|
||||
|
||||
*Status is `CHANGELOG.md` `[0.1.0-beta.22]`; this is what no other file carries.* The owner, during the beta.21
|
||||
train: "Bạn xử lý chip thành 1 pr mới sau release và thành 1 phiên bản mới nhé" — the chip beta.21's review of Play
|
||||
left (§beta.21's traps): every caller of the pipe, not only Play, as its own PR and its own pre-release. One PR — #306,
|
||||
`AgentConnection.AnsweredAsync` and `AgentAnswers.IsUnanswered`, with deleting sessions, the hooking switch, the anti-cheat
|
||||
exception and Play telling *not sent* from *not answered* — then the release.
|
||||
|
||||
**Decisions:** none new. *Not answered* is said as not known (`Agent_Unanswered`) and never as the old words for *not
|
||||
sent* ("nothing was deleted", "nothing changed"): a request the connection closed under may have been carried out.
|
||||
|
||||
**Traps met on the way:**
|
||||
|
||||
- **VSTHRD003 rejects awaiting a `Task` a method was handed** ("work that was not started within your context"): a helper
|
||||
that wraps a request's exceptions takes a `Func<Task<T>>` and starts it itself — which also catches what the request
|
||||
throws before it returns a task.
|
||||
- **`ObjectDisposedException` derives from `InvalidOperationException`**: a `catch (InvalidOperationException)` for "not
|
||||
connected" would read a disposed pipe as "nothing was sent". `AgentConnection` turns it into the `IOException` first,
|
||||
so the callers' split holds.
|
||||
|
||||
**Owner-only, added to the list below:** item 18 — **passed 2026-10-13**.
|
||||
|
||||
**After the release (owner, 2026-10-13):** "Tất cả các item đã đạt yêu cầu. Bạn có thể xử lý chip, phiên bản mới (nếu
|
||||
cần), cập nhật, rồi đóng phiên nhé" — items 16, 17 and 18 passed; the chip beta.22's local gate left (`fl_ring`'s
|
||||
hammering-writer guard, red on a correct ring) became beta.23 PR-1, #308: both concurrency cases guard on drains that
|
||||
overlapped the writer (§Traps, the native-test entry). Merged for the next pre-release; no release, since nothing a
|
||||
user runs changed.
|
||||
|
||||
## Owner-only — no PR can close these
|
||||
|
||||
1. **§S23-2 — branch protection.** `Rules / validate` is not a required status check on
|
||||
@@ -2394,18 +2422,24 @@ Privacy Policy 2.10 — then the release.*
|
||||
together are said in one notice that names both; with the USB drive unplugged nothing is removed; *Remove uninstalled
|
||||
games* off keeps it. (e) The Legal Gate shows the Privacy Policy 2.8
|
||||
once. (f) The `ja` strings marked `review`.
|
||||
16. **beta.20 on real hardware.** (a) **Bound Between Desks:** its page reads *Ren'Py 8.5.0*, and its *Engine version*
|
||||
line says it was read from the engine's version file (`renpy/vc_version.py`); the first sweep after the update reads
|
||||
every game once more (rules `2026.10.3`). (b) The Legal Gate shows the Privacy Policy 2.9 once. (c) The `ja` string
|
||||
marked `review` (`GameDetail_EngineVersion_RenPyVcVersion`).
|
||||
17. **beta.21 on real hardware.** (a) **Wuthering Waves:** after the update, before any session, its page says hooking
|
||||
is off — Anti-Cheat Expert beside its executable, and its Steam id on the title list; Neverness To Everness stays
|
||||
blocked, and GIRLS' FRONTLINE 2's exception stays in force. (b) **Play**, in both modes of Settings ▸ Games ▸ *Play
|
||||
button*, with a Steam game, Alan Wake 2 from the Epic Games Launcher (its link has not been tried on a real game), a
|
||||
GOG game and an itch game — and in Task Manager's Details tab the game's *Elevated* column reads *No*. (c) **The
|
||||
wheel and a touchpad** in Help ▸ User guide, the licence in Help ▸ About and the Legal Gate: about three lines a
|
||||
notch, gliding; at the end of the update notes the window scrolls instead. (d) The Legal Gate shows the Privacy
|
||||
Policy 2.10 once. (e) The `ja` strings marked `review` (Play, Settings ▸ Games, `GameDetail_Supports_None`).
|
||||
16. ~~**beta.20 on real hardware.**~~ **Passed 2026-10-13** — the owner: "Tất cả các item đã đạt yêu cầu" (every item
|
||||
met its requirement). *(The item as written:)* (a) **Bound Between Desks:** its page reads *Ren'Py 8.5.0*, and its
|
||||
*Engine version* line says it was read from the engine's version file (`renpy/vc_version.py`); the first sweep after
|
||||
the update reads every game once more (rules `2026.10.3`). (b) The Legal Gate shows the Privacy Policy 2.9 once. (c)
|
||||
The `ja` string marked `review` (`GameDetail_EngineVersion_RenPyVcVersion`).
|
||||
17. ~~**beta.21 on real hardware.**~~ **Passed 2026-10-13** — the same answer. *(The item as written:)* (a) **Wuthering
|
||||
Waves:** after the update, before any session, its page says hooking is off — Anti-Cheat Expert beside its
|
||||
executable, and its Steam id on the title list; Neverness To Everness stays blocked, and GIRLS' FRONTLINE 2's
|
||||
exception stays in force. (b) **Play**, in both modes of Settings ▸ Games ▸ *Play button*, with a Steam game, Alan
|
||||
Wake 2 from the Epic Games Launcher (its link has not been tried on a real game), a GOG game and an itch game — and
|
||||
in Task Manager's Details tab the game's *Elevated* column reads *No*. (c) **The wheel and a touchpad** in Help ▸
|
||||
User guide, the licence in Help ▸ About and the Legal Gate: about three lines a notch, gliding; at the end of the
|
||||
update notes the window scrolls instead. (d) The Legal Gate shows the Privacy Policy 2.10 once. (e) The `ja` strings
|
||||
marked `review` (Play, Settings ▸ Games, `GameDetail_Supports_None`).
|
||||
18. ~~**beta.22 on real hardware.**~~ **Passed 2026-10-13** — the same answer. *(The item as written:)* (a) The `ja`
|
||||
string marked `review` (`Agent_Unanswered`). (b) Nothing else to run: the change answers a request the agent drops
|
||||
mid-way, which the tests make happen and a person can only meet by chance — if a notice ever says the capture agent
|
||||
did not answer, the page beside it shows what was stored.
|
||||
|
||||
**Answered 2026-08-05, do not re-ask:** remove `gameguard` and keep `guard` (approved
|
||||
over a red `Rules` gate, with the reasoning recorded in the merge commit); vendor NVAPI
|
||||
@@ -2648,6 +2682,17 @@ diagnosis*.
|
||||
nothing, and `ring_test.cpp`'s own header already records that two of its four properties
|
||||
have never been shown red.
|
||||
|
||||
> **Amended 2026-10-13 (beta.23 PR-1, #308): both guards now measure overlap.** The hammering case's own guard,
|
||||
> `accepted > kTotal / 2`, failed 5 of 40 runs and then 5 of 200 on the owner's hybrid i7-14700KF — `mixed` clean every
|
||||
> time — and once made a full local gate red. A share of the stream measured the scheduler: a reader on an efficiency
|
||||
> core keeps less than half, and one the OS does not run until the writer is done keeps one lap (accepted 1024). The
|
||||
> tiny ring's `dropped > 0` was weaker the other way: a reader made to wait for the writer to finish drops nearly
|
||||
> everything (1.6 million over eight attempts) and passed it. Both cases now start the writer only once the reader
|
||||
> is about to loop, count the drains that copied records while the writer was still writing, and repeat — every
|
||||
> attempt checked for its properties — until one attempt made 100 such drains, at most eight times; the tiny ring
|
||||
> also holds that attempt's own `dropped > 0`. A start barrier alone left 1 of 200 (one overlapping drain). Measured:
|
||||
> 1,000 runs, no failure, at most 3 attempts; with the waiting reader, both guards fail in every run.
|
||||
|
||||
- **A self-test's cases can all pass while testing nothing, and their NAMES will not tell
|
||||
you.** Found 2026-08-27 in a PowerShell gate's `-SelfTest`: removing the fail-closed guard
|
||||
from a hash comparison left **all ten cases green**. `[string]::Equals` already refuses
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@
|
||||
HTML comments are not part of the block.
|
||||
-->
|
||||
> ⚠ **What FrameLedger actually measures today — 2026-10-13.** The software is a beta; its latest
|
||||
> **pre-release is `0.1.0-beta.21`** (2026-10-13), an unsigned installer built from that tag with its
|
||||
> **pre-release is `0.1.0-beta.22`** (2026-10-13), an unsigned installer built from that tag with its
|
||||
> checksums published beside it. The source holds the desktop app
|
||||
> (library, store import, charts, settings) and the background Agent, which records a session when a
|
||||
> game in the library runs (unless you switched its recording off), injects only into games you enabled
|
||||
|
||||
+1
-1
@@ -114,7 +114,7 @@ Frame timing is derived from high-resolution timestamps taken at the moment the
|
||||
|
||||
<!-- accuracy-block:begin -->
|
||||
> ⚠ **What FrameLedger actually measures today — 2026-10-13.** The software is a beta; its latest
|
||||
> **pre-release is `0.1.0-beta.21`** (2026-10-13), an unsigned installer built from that tag with its
|
||||
> **pre-release is `0.1.0-beta.22`** (2026-10-13), an unsigned installer built from that tag with its
|
||||
> checksums published beside it. The source holds the desktop app
|
||||
> (library, store import, charts, settings) and the background Agent, which records a session when a
|
||||
> game in the library runs (unless you switched its recording off), injects only into games you enabled
|
||||
|
||||
+124
-70
@@ -33,6 +33,7 @@
|
||||
// added trying to close it and did not; they are kept because they are the right
|
||||
// shape and would catch a wider window.
|
||||
|
||||
#include <algorithm>
|
||||
#include <atomic>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <cstring>
|
||||
@@ -246,6 +247,18 @@ TEST_CASE("a reader stalled exactly ONE FULL LAP does not accept a stale frame",
|
||||
CHECK(out[0].frameIndex == kCap); // the SECOND occupant, not the first
|
||||
}
|
||||
|
||||
// What makes the two concurrency cases below prove anything is that the reader drained the ring WHILE the writer
|
||||
// wrote it (2026-10-13). The hammering case's guard was `accepted > kTotal / 2`, a share of the stream, and that
|
||||
// measured the scheduler rather than the run: on the owner's hybrid i7-14700KF it failed 5 of 40 runs, then 5 of 200,
|
||||
// with `mixed` clean every time. A start barrier (the writer begins only once the reader is about to loop) left 1 of
|
||||
// 200 — a reader the OS did not run while the writer wrote: one drain beside it, accepted 2048. No single run can rule
|
||||
// that out, so each case repeats its run, every attempt checked for its properties, until one attempt made enough
|
||||
// drains that copied records while the writer was still writing. Measured over 1,000 runs: no failure, at most 3
|
||||
// attempts, at least 122 such drains in the best attempt (median 146,981). A reader made to wait for the writer to
|
||||
// finish makes none in all 8 attempts and fails here, where the tiny ring's old `dropped > 0` still passed.
|
||||
constexpr std::uint64_t kMinOverlappedDrains = 100;
|
||||
constexpr int kMaxAttempts = 8;
|
||||
|
||||
TEST_CASE("SPSC under a hammering writer: every accepted record is internally consistent", "[ring]") {
|
||||
// The real concurrency case. The reader may legitimately miss records
|
||||
// (overwrite-oldest) and may see torn ones; what it must NEVER do is accept a
|
||||
@@ -254,44 +267,63 @@ TEST_CASE("SPSC under a hammering writer: every accepted record is internally co
|
||||
constexpr std::uint32_t kBigCap = 1024;
|
||||
constexpr std::uint32_t kTotal = 200000;
|
||||
|
||||
Mapping m{kBigCap};
|
||||
RingWriter w;
|
||||
RingReader rd;
|
||||
REQUIRE(w.Init(m.base(), kBigCap));
|
||||
REQUIRE(rd.Init(m.base(), kBigCap));
|
||||
std::uint64_t mostOverlapped = 0;
|
||||
int attempts = 0;
|
||||
while (mostOverlapped < kMinOverlappedDrains && attempts < kMaxAttempts) {
|
||||
++attempts;
|
||||
Mapping m{kBigCap};
|
||||
RingWriter w;
|
||||
RingReader rd;
|
||||
REQUIRE(w.Init(m.base(), kBigCap));
|
||||
REQUIRE(rd.Init(m.base(), kBigCap));
|
||||
|
||||
std::atomic<bool> done{false};
|
||||
std::thread producer([&] {
|
||||
for (std::uint32_t i = 0; i < kTotal; ++i) {
|
||||
w.Publish(MakeRecord(i));
|
||||
}
|
||||
done.store(true, std::memory_order_release);
|
||||
});
|
||||
|
||||
std::vector<FlFrameRecord> buf(kBigCap);
|
||||
std::uint64_t accepted = 0;
|
||||
std::uint64_t torn = 0;
|
||||
bool mixed = false;
|
||||
|
||||
while (!done.load(std::memory_order_acquire) || rd.ReadIndex() < m.writer()->writeIndex) {
|
||||
const DrainResult r = rd.Drain(buf.data(), kBigCap);
|
||||
for (std::uint32_t i = 0; i < r.copied; ++i) {
|
||||
if (buf[i].qpc != 1000ULL + buf[i].frameIndex) {
|
||||
mixed = true;
|
||||
std::atomic<bool> go{false};
|
||||
std::atomic<bool> done{false};
|
||||
std::thread producer([&] {
|
||||
while (!go.load(std::memory_order_acquire)) {
|
||||
std::this_thread::yield();
|
||||
}
|
||||
if (buf[i].swapchainId != (0xABCD0000u | (buf[i].frameIndex & 0xFFFFu))) {
|
||||
mixed = true; // the tail span belongs to the same frame as the head
|
||||
for (std::uint32_t i = 0; i < kTotal; ++i) {
|
||||
w.Publish(MakeRecord(i));
|
||||
}
|
||||
done.store(true, std::memory_order_release);
|
||||
});
|
||||
|
||||
std::vector<FlFrameRecord> buf(kBigCap);
|
||||
std::uint64_t accepted = 0;
|
||||
std::uint64_t torn = 0;
|
||||
std::uint64_t overlapped = 0; // drains that copied records while the writer was writing
|
||||
bool mixed = false;
|
||||
|
||||
go.store(true, std::memory_order_release);
|
||||
while (!done.load(std::memory_order_acquire) || rd.ReadIndex() < m.writer()->writeIndex) {
|
||||
const bool writing = !done.load(std::memory_order_acquire);
|
||||
const DrainResult r = rd.Drain(buf.data(), kBigCap);
|
||||
for (std::uint32_t i = 0; i < r.copied; ++i) {
|
||||
if (buf[i].qpc != 1000ULL + buf[i].frameIndex) {
|
||||
mixed = true;
|
||||
}
|
||||
if (buf[i].swapchainId != (0xABCD0000u | (buf[i].frameIndex & 0xFFFFu))) {
|
||||
mixed = true; // the tail span belongs to the same frame as the head
|
||||
}
|
||||
}
|
||||
if (writing && r.copied > 0) {
|
||||
++overlapped;
|
||||
}
|
||||
accepted += r.copied;
|
||||
torn += r.gaps;
|
||||
}
|
||||
accepted += r.copied;
|
||||
torn += r.gaps;
|
||||
producer.join();
|
||||
|
||||
INFO("attempt " << attempts << ": accepted " << accepted << ", torn " << torn << ", overlapped drains "
|
||||
<< overlapped << " of " << kTotal);
|
||||
CHECK_FALSE(mixed);
|
||||
mostOverlapped = std::max(mostOverlapped, overlapped);
|
||||
}
|
||||
producer.join();
|
||||
|
||||
INFO("accepted " << accepted << ", torn " << torn << " of " << kTotal);
|
||||
CHECK_FALSE(mixed);
|
||||
// Not a vacuous run: the reader must actually have seen most of the stream.
|
||||
CHECK(accepted > kTotal / 2);
|
||||
INFO("attempts " << attempts << ", most overlapped drains " << mostOverlapped);
|
||||
// Not a vacuous run: in one attempt at least, the reader read the ring while the writer was writing it.
|
||||
CHECK(mostOverlapped >= kMinOverlappedDrains);
|
||||
}
|
||||
|
||||
TEST_CASE("a tiny ring, so the writer laps the reader constantly", "[ring]") {
|
||||
@@ -307,50 +339,72 @@ TEST_CASE("a tiny ring, so the writer laps the reader constantly", "[ring]") {
|
||||
constexpr std::uint32_t kTiny = 8;
|
||||
constexpr std::uint32_t kTotal = 200000;
|
||||
|
||||
Mapping m{kTiny};
|
||||
RingWriter w;
|
||||
RingReader rd;
|
||||
REQUIRE(w.Init(m.base(), kTiny));
|
||||
REQUIRE(rd.Init(m.base(), kTiny));
|
||||
std::uint64_t mostOverlapped = 0;
|
||||
std::uint64_t dropped = 0; // the last attempt's: the one that overlapped, when one did
|
||||
int attempts = 0;
|
||||
while (mostOverlapped < kMinOverlappedDrains && attempts < kMaxAttempts) {
|
||||
++attempts;
|
||||
Mapping m{kTiny};
|
||||
RingWriter w;
|
||||
RingReader rd;
|
||||
REQUIRE(w.Init(m.base(), kTiny));
|
||||
REQUIRE(rd.Init(m.base(), kTiny));
|
||||
|
||||
std::atomic<bool> done{false};
|
||||
std::thread producer([&] {
|
||||
for (std::uint32_t i = 0; i < kTotal; ++i) {
|
||||
w.Publish(MakeRecord(i));
|
||||
}
|
||||
done.store(true, std::memory_order_release);
|
||||
});
|
||||
|
||||
FlFrameRecord buf[kTiny]{};
|
||||
std::uint64_t accepted = 0;
|
||||
std::uint64_t dropped = 0;
|
||||
bool mixed = false;
|
||||
bool poisonAccepted = false;
|
||||
|
||||
while (!done.load(std::memory_order_acquire) || rd.ReadIndex() < m.writer()->writeIndex) {
|
||||
const DrainResult r = rd.Drain(buf, kTiny);
|
||||
for (std::uint32_t i = 0; i < r.copied; ++i) {
|
||||
if (buf[i].qpc != 1000ULL + buf[i].frameIndex ||
|
||||
buf[i].swapchainId != (0xABCD0000u | (buf[i].frameIndex & 0xFFFFu))) {
|
||||
mixed = true;
|
||||
std::atomic<bool> go{false};
|
||||
std::atomic<bool> done{false};
|
||||
std::thread producer([&] {
|
||||
while (!go.load(std::memory_order_acquire)) {
|
||||
std::this_thread::yield();
|
||||
}
|
||||
// An accepted record's seq is the seqlock counter and must be even.
|
||||
// kPoisonSeq here means the payload write reached the guard field.
|
||||
if (buf[i].seq == kPoisonSeq || (buf[i].seq & 1u) != 0u) {
|
||||
poisonAccepted = true;
|
||||
for (std::uint32_t i = 0; i < kTotal; ++i) {
|
||||
w.Publish(MakeRecord(i));
|
||||
}
|
||||
done.store(true, std::memory_order_release);
|
||||
});
|
||||
|
||||
FlFrameRecord buf[kTiny]{};
|
||||
std::uint64_t accepted = 0;
|
||||
std::uint64_t lost = 0;
|
||||
std::uint64_t overlapped = 0; // drains that copied records while the writer was writing
|
||||
bool mixed = false;
|
||||
bool poisonAccepted = false;
|
||||
|
||||
go.store(true, std::memory_order_release);
|
||||
while (!done.load(std::memory_order_acquire) || rd.ReadIndex() < m.writer()->writeIndex) {
|
||||
const bool writing = !done.load(std::memory_order_acquire);
|
||||
const DrainResult r = rd.Drain(buf, kTiny);
|
||||
for (std::uint32_t i = 0; i < r.copied; ++i) {
|
||||
if (buf[i].qpc != 1000ULL + buf[i].frameIndex ||
|
||||
buf[i].swapchainId != (0xABCD0000u | (buf[i].frameIndex & 0xFFFFu))) {
|
||||
mixed = true;
|
||||
}
|
||||
// An accepted record's seq is the seqlock counter and must be even.
|
||||
// kPoisonSeq here means the payload write reached the guard field.
|
||||
if (buf[i].seq == kPoisonSeq || (buf[i].seq & 1u) != 0u) {
|
||||
poisonAccepted = true;
|
||||
}
|
||||
}
|
||||
if (writing && r.copied > 0) {
|
||||
++overlapped;
|
||||
}
|
||||
accepted += r.copied;
|
||||
lost += r.dropped;
|
||||
}
|
||||
accepted += r.copied;
|
||||
dropped += r.dropped;
|
||||
producer.join();
|
||||
dropped = lost;
|
||||
|
||||
INFO("attempt " << attempts << ": accepted " << accepted << ", overlapped drains " << overlapped << " of "
|
||||
<< kTotal);
|
||||
CHECK_FALSE(mixed);
|
||||
CHECK_FALSE(poisonAccepted);
|
||||
mostOverlapped = std::max(mostOverlapped, overlapped);
|
||||
}
|
||||
producer.join();
|
||||
|
||||
INFO("accepted " << accepted << ", dropped " << dropped << " of " << kTotal);
|
||||
CHECK_FALSE(mixed);
|
||||
CHECK_FALSE(poisonAccepted);
|
||||
// Not vacuous in the other direction either: with 8 slots the writer MUST
|
||||
// have lapped us, so a run reporting no drops means the threads never
|
||||
// actually overlapped and the case proved nothing.
|
||||
INFO("attempts " << attempts << ", most overlapped drains " << mostOverlapped << ", dropped " << dropped);
|
||||
// Not vacuous: the reader read the ring while the writer was writing it. `dropped > 0` alone could not say so — a
|
||||
// reader that started after the writer had finished drops nearly everything — and with eight slots the attempt
|
||||
// that overlapped (the last one) is lapped, which the second check holds it to.
|
||||
CHECK(mostOverlapped >= kMinOverlappedDrains);
|
||||
CHECK(dropped > 0);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user