Compare commits

...
Author SHA1 Message Date
poli0981 2f3b64978d Merge commit 'f70a9153facc701c29d823df50d60c07ce26b29d' into fix/agent-pending-readings 2026-11-14 17:06:41 +07:00
poli0981 f3e653532d Merge branch 'feat/watchdog-grid' into fix/agent-pending-readings 2026-11-14 16:38:28 +07:00
poli0981andClaude Fable 5.2 5c176fec6e test(guard): the measurement case prints the numbers it parsed, never a line of the log as it stands (SonarCloud cppsecurity:S5145)
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-14 16:38:25 +07:00
poli0981 95ded194ef Merge commit '4f02a17380ebdb39095c7f6e43d15114b41c58ab' into feat/watchdog-grid 2026-11-14 16:15:12 +07:00
poli0981andClaude Fable 5.2 270db60a25 fix(agent): a reading that waits for a sample is no longer overwritten by the next one - two wait, the older is carried first; the guide says whose switches the latency table shows (D150, the Agent's half; D151)
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-14 16:09:06 +07:00
poli0981 d2c2ca0464 Merge branch 'feat/latency-frames-log' into feat/watchdog-grid 2026-11-14 15:56:58 +07:00
poli0981andClaude Fable 5.2 58e7b3e556 fix(overlay): the watchdog's periodic tick is on a grid of one second, and a tick the loader woke no longer takes the driver read or publishes region 5 - a read a second whatever a tick's work took (D150, the Overlay's half; in no release yet)
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-14 15:56:57 +07:00
poli0981andClaude Fable 5.2 207a0c7cdb test(guard): the log case's expected words are widened before they are multiplied (Qodana native: bugprone-implicit-widening-of-multiplication-result, two)
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-14 15:51:01 +07:00
poli0981andClaude Fable 5.2 e9ff143cc9 feat(overlay): the frames of NVIDIA's latency report are counted for the native log - each by its GPU span and the driver's active time, in batches that belong to one state of the sleep status (D148, D151; nothing published, no new call, no further member; in no release yet)
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-14 15:26:03 +07:00
8 changed files with 254 additions and 8 deletions

No files matched your search

+13
View File
@@ -59,6 +59,19 @@ numeric core and does not move; the heading is the full version — corrected 20
had nothing to publish. Its once-a-second round is now due at fixed moments whatever the work took, and a round
woken early no longer publishes or takes a reading. Two readings are never less than half a second apart.
Nothing on a game's own threads changed.
- **A reading that waits for a sample is no longer overwritten by the next one** (D150; the capture agent's
half). The agent kept one reading from the game until a sensor sample could carry it, and replaced it when
another arrived first. When a reading landed just after a sample, that sample went without and a reading was
lost a little later — in one session of the owner's, one sample in five for four minutes. Two readings may now
wait and the older is stored first; a point can stand up to a second after its reading was taken. With the
sensor interval above one second, not every reading is stored, as before.
### Changed
- **The guide says whose switches the latency table shows**: the driver's, not the game's menu. `bLowLatencyMode`
is also on when *Low Latency Mode* is set for the game in the NVIDIA App, and `bUseGameSleep` says whether the
game itself paces its frames through Reflex — in some games only with frame generation on (the owner's word,
2026-11-14, and what Clair Obscur's sessions of that afternoon read).
## Releases
+2 -1
View File
@@ -131,7 +131,8 @@ shown is recorded too, from outside the game. ([Capture](docs/04_CAPTURE.md))
second. They are the driver's numbers, not FrameLedger's measurement. **The stages overlap and do not add up to
the total**, and the graphics card's stage includes the time the card waited — in one game it is longer than the
whole frame; the driver's own figure for the card's active time is shown beside it where the driver gives one.
One point is one reading; with the sensor interval set above one second, some readings are not stored.
One point is one reading, drawn at the sample that carried it — up to a second after it was taken; with the
sensor interval set above one second, some readings are not stored.
FrameLedger asks the driver for them from inside the game; a read that is slow or faults is switched off until the game is closed, and the session says so.
([Advanced metrics](guide/12-advanced-metrics.md))
+5
View File
@@ -496,6 +496,11 @@ Because Tier-1 and Tier-2 sessions carry different fields, every query that comp
> Sensor series are aligned to `t_ms` (milliseconds from `qpc_epoch`) and a tick with no reading is stored as
> **−1** — never 0, which would be a reading — because temperatures, loads, power and memory are never negative.
>
> **A reading taken inside a game stands at the sample that carried it** (0.1.0-beta.49, owner decision D150): the
> Overlay publishes about once a second and the Agent samples exactly once a second, so a publication waits for
> the next sample — two may wait, the older is carried first (`PendingInGameReadings`). An `adv.*` point that
> came from a game can therefore stand up to a second after its read; a tick with nothing waiting is NaN.
>
> **`t_ms` is the time axis; `hz` is the fallback** (written here 2026-11-14, owner decision D146 — the code cited
> this rule before the page had it). Every series of a session is stored beside `t_ms`, which carries each
> sample's own time, and the App draws against it; `hz` is read only for a row that has no `t_ms`
+8
View File
@@ -130,6 +130,14 @@ What the region is, as a contract between the two sides:
ends — and every one after it a second's. A reader takes ranges and "seen" words as *since the request*, which
they are, and never reads a single publication as complete. No game thread writes the region, so the seqlock has a single writer: `seq` odd, the fields,
`seq` even.
- **A publication waits for a sample, and is not replaced while it waits** (0.1.0-beta.49, owner decision D150;
the Agent's half). `SessionRecorder` looks at the region and at the telemetry poller about ten times a second
and attaches a publication's readings to the newest sample it drains. It used to keep one set and overwrite it:
a publication that landed just after a sample left that sample without a report, and at the next change of
step the set that had waited was overwritten — one sample in five for minutes in the owner's session 223. Two
sets now wait, the older is carried first (`PendingInGameReadings`): a session lacks a report at one sample at
most when the two fall out of step, and loses no reading after it. With the sensor interval above a second
more publications arrive than samples and the oldest is pushed out, as before.
- **The reader keeps its last consistent copy** (`ShmRingReader.AdvancedState`): null until something was published
for its request;
the same copy while `seq` has not moved, without copying 1472 bytes again; and that copy still when the writer is
+5 -1
View File
@@ -92,7 +92,11 @@ of simulation to the end of the graphics card's work. They are seven lines under
second, each the average of the frames of one reading, in microseconds. A table beside them shows the driver's
low-latency state as five switches, by NVIDIA's own names, each *On*, *Off* or *On at times, off at others*, and
`fgMultiplier`: every frame-generation multiplier the driver gave during the session (*1, 2* is a session that
generated frames at ×2 for part of it).
generated frames at ×2 for part of it). **They are the driver's switches, not the game's menu.** `bLowLatencyMode`
is on when the game switched Reflex on *and* when **Low Latency Mode** is set for that game in the NVIDIA App —
an override there shows here, and can read *On at times, off at others* in a game whose own setting never
changed. `bUseGameSleep` says whether the game itself is pacing its frames through Reflex; some games do that
only while frame generation is on, so read the two together.
**The stages overlap; they are not parts that add up to the total.** And *GPU render, start to end* includes the
time the card spent waiting between pieces of work — in one game it is longer than the whole frame. So a second
@@ -0,0 +1,62 @@
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
using System.Diagnostics.CodeAnalysis;
using FrameLedger.Application.Advanced;
namespace FrameLedger.Application.Recording;
/// <summary>
/// What a hooked game published and no telemetry sample carries yet (owner decision D150): at most
/// <see cref="Capacity"/> sets of readings, the older taken first.
/// </summary>
/// <remarks>
/// <para>
/// <b>Why not one.</b> A publication arrives about once a second and a sample exactly once a second, on two clocks,
/// and the recorder looks at both every tenth of a second or so. Until 0.1.0-beta.49 it kept the newest set and
/// overwrote it: when a publication landed just after a sample, a look could fall between the two - that sample went
/// without, and at the next change of step the set that had waited was overwritten by its successor. In the owner's
/// sessions that was one sample in five without a report for minutes on end (HANDOFF, item 46).
/// </para>
/// <para>
/// <b>What two give.</b> A set that waited is carried by the next sample instead of being replaced, so with both sides
/// on a second a session lacks a report at one sample at most - the first time the two fall out of step - and loses
/// none after it. A reading then stands at the sample after the one it would have ridden: a second later, no more.
/// </para>
/// <para>
/// <b>What it does not give.</b> With the sensor interval above a second more sets arrive than samples: a third
/// pushes the oldest out, and not every reading is stored - as before, and as the guide says.
/// </para>
/// </remarks>
public sealed class PendingInGameReadings
{
/// <summary>The most sets that wait: the one a sample is about to carry, and the one that arrived meanwhile.</summary>
public const int Capacity = 2;
private readonly Queue<IReadOnlyList<AdvancedReading>> _waiting = new(Capacity);
/// <summary>How many sets wait.</summary>
public int Count => _waiting.Count;
/// <summary>A publication's readings. A set with nothing in it does not wait: it would only stand in a real one's way.</summary>
/// <param name="readings">The readings of one publication.</param>
public void Offer(IReadOnlyList<AdvancedReading> readings)
{
ArgumentNullException.ThrowIfNull(readings);
if (readings.Count == 0)
{
return;
}
if (_waiting.Count == Capacity)
{
_ = _waiting.Dequeue();
}
_waiting.Enqueue(readings);
}
/// <summary>The oldest set that waits, which then waits no longer; false when none does.</summary>
/// <param name="readings">The set, when there is one.</param>
public bool TryTake([NotNullWhen(true)] out IReadOnlyList<AdvancedReading>? readings) => _waiting.TryDequeue(out readings);
}
@@ -374,7 +374,7 @@ public sealed class SessionRecorder : ISessionRecorder
// What the game told its upscaler (train B): read inside the game by the Overlay, only for a session that
// records Advanced metrics - the same condition the shared reader is held under.
private readonly InGameAdvancedSampler? _inGame = advanced is null ? null : new InGameAdvancedSampler();
private IReadOnlyList<AdvancedReading>? _inGamePending;
private readonly PendingInGameReadings _inGamePending = new();
private (IReadOnlyList<AdvancedFact> Facts, AdvancedInGameStatus Status, InGameCallStates Calls) _inGameContext =
([], AdvancedInGameStatus.Unknown, default);
private IReadOnlyList<AdvancedFact> _sessionWithGame = [];
@@ -417,8 +417,9 @@ public sealed class SessionRecorder : ISessionRecorder
FollowAdapter(progress.AdapterLuid);
if (_inGame?.Take(progress.InGameAdvanced) is { } fresh)
{
// The newest stands until a telemetry sample carries it: both arrive once a second, out of step.
_inGamePending = fresh;
// It waits until a telemetry sample carries it: both arrive once a second, out of step - and it is no
// longer replaced by the one after it (owner decision D150; PendingInGameReadings says why).
_inGamePending.Offer(fresh);
}
DrainTelemetry();
@@ -631,13 +632,12 @@ public sealed class SessionRecorder : ISessionRecorder
_drained.Clear();
poller.Drain(_drained);
if (_inGamePending is { } pending && _drained.Count > 0)
if (_drained.Count > 0 && _inGamePending.TryTake(out IReadOnlyList<AdvancedReading>? pending))
{
// What the game said rides the newest sample of this drain, beside whatever the Agent's own reader
// gave it: one tick, one set of readings.
// gave it: one tick, one set of readings - the oldest that waits.
TelemetrySample newest = _drained[^1];
_drained[^1] = newest with { Advanced = newest.Advanced is { Count: > 0 } own ? [.. own, .. pending] : pending };
_inGamePending = null;
}
writer.AddSensors(_drained);
@@ -0,0 +1,153 @@
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
using FluentAssertions;
using FrameLedger.Application.Advanced;
using FrameLedger.Application.Recording;
namespace FrameLedger.Application.Tests.Recording;
/// <summary>
/// What a hooked game published and no sample carries yet (owner decision D150): two sets may wait, the older is
/// carried first, and a set that waited is no longer overwritten by the one after it.
/// </summary>
public sealed class PendingInGameReadingsTests
{
private static IReadOnlyList<AdvancedReading> Set(int second) => [new AdvancedReading("adv.nvapi.reflex.frame_report.total", second)];
private static double Second(IReadOnlyList<AdvancedReading> set) => set[0].Value;
[Fact]
public void Nothing_waits_until_something_is_offered()
{
var pending = new PendingInGameReadings();
pending.Count.Should().Be(0);
pending.TryTake(out IReadOnlyList<AdvancedReading>? none).Should().BeFalse();
none.Should().BeNull();
}
[Fact]
public void Two_publications_between_two_samples_are_both_carried_the_older_first()
{
var pending = new PendingInGameReadings();
pending.Offer(Set(1));
pending.Offer(Set(2));
pending.Count.Should().Be(2);
pending.TryTake(out IReadOnlyList<AdvancedReading>? first).Should().BeTrue();
Second(first!).Should().Be(1);
pending.TryTake(out IReadOnlyList<AdvancedReading>? second).Should().BeTrue();
Second(second!).Should().Be(2);
pending.TryTake(out _).Should().BeFalse();
}
[Fact]
public void A_third_pushes_the_oldest_out_so_a_slow_sensor_interval_keeps_the_two_newest()
{
var pending = new PendingInGameReadings();
pending.Offer(Set(1));
pending.Offer(Set(2));
pending.Offer(Set(3));
pending.Count.Should().Be(PendingInGameReadings.Capacity);
pending.TryTake(out IReadOnlyList<AdvancedReading>? first).Should().BeTrue();
Second(first!).Should().Be(2);
pending.TryTake(out IReadOnlyList<AdvancedReading>? second).Should().BeTrue();
Second(second!).Should().Be(3);
}
[Fact]
public void A_publication_with_no_reading_does_not_wait()
{
var pending = new PendingInGameReadings();
pending.Offer(Set(1));
pending.Offer([]);
pending.Count.Should().Be(1);
pending.TryTake(out IReadOnlyList<AdvancedReading>? first).Should().BeTrue();
Second(first!).Should().Be(1);
}
[Fact]
public void A_null_set_is_refused()
{
var pending = new PendingInGameReadings();
Action offer = () => pending.Offer(null!);
offer.Should().Throw<ArgumentNullException>();
}
/// <summary>
/// The owner's sessions, as the recorder sees them. Each second has one publication and one sample. In step, one
/// look of the recorder finds both - the publication is taken first, the sample carries it. Out of step, the
/// publication lands just after the sample: a look falls between them, so the sample is drained before its
/// publication is taken. The phase wanders, so a session goes in and out of step.
/// </summary>
[Fact]
public void A_session_that_falls_out_of_step_and_back_lacks_one_sample_and_loses_no_reading()
{
var pending = new PendingInGameReadings();
var carried = new List<double?>();
void Sample() => carried.Add(pending.TryTake(out IReadOnlyList<AdvancedReading>? set) ? Second(set) : null);
int second = 0;
for (int round = 0; round < 3; round++)
{
for (int i = 0; i < 4; i++)
{
// In step: the publication, then the sample, in one look.
pending.Offer(Set(++second));
Sample();
}
for (int i = 0; i < 4; i++)
{
// Out of step: the sample is drained in one look, its publication is taken in the next.
Sample();
pending.Offer(Set(++second));
}
}
// Twenty-four seconds, twenty-four samples: one without a reading - the first that fell out of step - and
// every reading up to the last carried once, in order. The last one waits for a sample that never came.
carried.Should().HaveCount(24);
carried.Count(static c => c is null).Should().Be(1);
carried[4].Should().BeNull();
carried.Where(static c => c is not null).Should().Equal(Enumerable.Range(1, 23).Select(static s => (double?)s));
pending.Count.Should().Be(1);
}
/// <summary>The rule until 0.1.0-beta.49, on the same session: what the change is for.</summary>
[Fact]
public void The_rule_before_it_lacked_a_sample_at_every_fall_out_of_step_and_lost_a_reading_at_every_return()
{
IReadOnlyList<AdvancedReading>? newest = null;
var carried = new List<double?>();
void Sample()
{
carried.Add(newest is null ? null : Second(newest));
newest = null;
}
int second = 0;
for (int round = 0; round < 3; round++)
{
for (int i = 0; i < 4; i++)
{
newest = Set(++second);
Sample();
}
for (int i = 0; i < 4; i++)
{
Sample();
newest = Set(++second);
}
}
carried.Count(static c => c is null).Should().Be(3);
carried.Where(static c => c is not null).Should().HaveCount(21).And.NotContain(8d).And.NotContain(16d);
}
}