Compare commits

...
Author SHA1 Message Date
poli0981andClaude Fable 5.1 a03449a5d0 feat(capturehost): a stall diagnostic placed against FrameLedger's own touches on the target
The owner saw Cyberpunk 2077 fall to 1 FPS for about a second under capture and the report
could say nothing about whose it was. The loop now records the QPC moment of every guard scan
and module snapshot (CaptureResult.TouchQpc, the records' own clock), and StallReport prints
the three longest present-to-present intervals with their session time and the nearest host
touch: inside or within 1 s -> FrameLedger is a SUSPECT, re-run on the 30 s cadence; far away ->
not ours. Counts intervals at or over 100 ms; calls itself a diagnostic, not 03_METRICS' stutter.
Four cases pin the placement. No Overlay change.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-05 20:03:52 +07:00
6 changed files with 271 additions and 0 deletions

No files matched your search

+9
View File
@@ -19,6 +19,15 @@ GitHub release body, so a missing section will mean an empty release note.
### Added
- **A stall diagnostic in the report, placed against FrameLedger's own touches on the target.** The
owner saw Cyberpunk 2077 fall to 1 FPS for about a second under capture (2026-09-05) and the report
could say nothing about whose it was. The capture host now records the QPC moment of every guard scan
and module snapshot (`CaptureResult.TouchQpc`, the records' own clock), and `StallReport` prints the
three longest present-to-present intervals with their session time and the nearest host touch: a
touch inside or within 1 s names FrameLedger a SUSPECT and asks for a longer run on the 30 s cadence;
a far one says *not ours*. It counts intervals at or over 100 ms and calls itself a diagnostic — it is
not `03_METRICS`' stutter, which P2's calculators own. Four cases pin the placement.
- **DLSS Frame Generation is NAMED, from the tags the title already sends.** On every NVIDIA title measured
the count was right and the technology unnamed — `Active (technology not identified)` on Cyberpunk at
MFG ×3 and on the three UE titles at ×4 — because `kFeatureDLSS_G` is never evaluated through the export
@@ -167,6 +167,7 @@ internal sealed class CaptureLoop(
return new CaptureResult
{
RuntimeModules = loaded.Set,
TouchQpc = loaded.TouchQpc,
Reason = end,
Verdict = verdict,
AttachRefusal = ShmAttachRefusal.Ok,
@@ -301,8 +302,17 @@ internal sealed class CaptureLoop(
{
public RuntimeModuleSet Set { get; private set; } = RuntimeModuleSet.Empty;
/// <summary>
/// When this host touched the target — a guard scan just completed, and the module snapshot
/// is about to run — as QPC ticks (<see cref="System.Diagnostics.Stopwatch.GetTimestamp"/> is
/// QueryPerformanceCounter on Windows, the clock the records carry). Recorded whether or not a
/// snapshot source exists, because it is the stall diagnostic's alibi, not the snapshot's.
/// </summary>
public List<long> TouchQpc { get; } = [];
public void Take(int pid)
{
TouchQpc.Add(System.Diagnostics.Stopwatch.GetTimestamp());
if (source is not null)
{
Set = Set.Merge(source(pid));
@@ -52,4 +52,11 @@ internal sealed record CaptureResult
/// had no snapshot source.
/// </summary>
public RuntimeModuleSet RuntimeModules { get; init; } = RuntimeModuleSet.Empty;
/// <summary>
/// QPC timestamps of every moment this host touched the target's process — a guard scan
/// completing, followed by the module snapshot — in the records' own clock, so a stall in the
/// frame stream can be checked against what FrameLedger itself was doing at that moment.
/// </summary>
public IReadOnlyList<long> TouchQpc { get; init; } = [];
}
@@ -0,0 +1,146 @@
using System.Globalization;
using System.Text;
using FrameLedger.Shared;
namespace FrameLedger.CaptureHost.Consume;
/// <summary>
/// The longest present-to-present intervals in a stream, each placed against the moments this host
/// touched the target — so "the game dropped to 1 FPS for a second" can be read as ours or not ours.
/// </summary>
/// <remarks>
/// <para>
/// <b>Why this exists.</b> The owner saw Cyberpunk 2077 fall to 1 FPS for about a second under capture
/// (2026-09-05) and the report had nothing to say about it: no frame-time statistic is computed by this
/// throwaway (P2's calculators own them), and nothing correlated a gap with what FrameLedger was doing.
/// FrameLedger touches the target at known moments — the guard's 30 s re-scan enumerates its modules,
/// and the module snapshot reads the same list beside it — and the records carry QPC, the same clock
/// <see cref="System.Diagnostics.Stopwatch.GetTimestamp"/> reads. So a stall can be placed: within a
/// touch window it is a suspect; far from every touch it is the title's own (a shader compile, a
/// level stream, a menu).
/// </para>
/// <para>
/// <b>Not a stutter metric.</b> <c>03_METRICS</c> defines stutter against a rolling median with edge
/// rules and a sufficiency floor, and this prints none of that. It prints the few longest raw
/// intervals and where they sit, which is a diagnostic, and it says so.
/// </para>
/// </remarks>
internal sealed record StallReport
{
/// <summary>One long interval: where it starts in the session, how long it is, and the nearest touch.</summary>
internal sealed record Stall(double AtSeconds, double Milliseconds, double? NearestTouchSeconds)
{
/// <summary>A touch inside the interval or within <see cref="TouchWindowSeconds"/> of it is a suspect.</summary>
public bool NearATouch => NearestTouchSeconds is double d && Math.Abs(d) <= TouchWindowSeconds;
}
/// <summary>How far a host touch may be from a stall and still be named beside it.</summary>
public const double TouchWindowSeconds = 1.0;
/// <summary>Intervals at or above this are counted as stalls — ten presents' worth at 100 FPS.</summary>
public const double StallThresholdMs = 100.0;
public required IReadOnlyList<Stall> Longest { get; init; }
public required int OverThreshold { get; init; }
public required int Intervals { get; init; }
public required int Touches { get; init; }
public static StallReport From(IReadOnlyList<FlFrameRecord> stream, long qpcFrequency, IReadOnlyList<long> touchQpc,
int keep = 3)
{
ArgumentNullException.ThrowIfNull(stream);
ArgumentNullException.ThrowIfNull(touchQpc);
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(qpcFrequency);
var stalls = new List<Stall>();
int over = 0;
int intervals = 0;
if (stream.Count > 1)
{
long origin = (long)stream[0].Qpc;
var candidates = new List<(long StartQpc, long DeltaQpc)>();
for (int i = 1; i < stream.Count; i++)
{
long delta = (long)stream[i].Qpc - (long)stream[i - 1].Qpc;
if (delta <= 0)
{
continue; // a torn or reordered record; the drain reports gaps separately
}
intervals++;
if (delta * 1000.0 / qpcFrequency >= StallThresholdMs)
{
over++;
}
candidates.Add(((long)stream[i - 1].Qpc, delta));
}
foreach ((long startQpc, long deltaQpc) in candidates.OrderByDescending(c => c.DeltaQpc).Take(keep))
{
double at = (startQpc - origin) / (double)qpcFrequency;
double ms = deltaQpc * 1000.0 / qpcFrequency;
double? nearest = null;
foreach (long t in touchQpc)
{
// Distance from the touch to the interval [start, start + delta]: 0 when inside.
double d = t < startQpc ? (t - startQpc) / (double)qpcFrequency
: t > startQpc + deltaQpc ? (t - (startQpc + deltaQpc)) / (double)qpcFrequency
: 0.0;
if (nearest is null || Math.Abs(d) < Math.Abs(nearest.Value))
{
nearest = d;
}
}
stalls.Add(new Stall(at, ms, nearest));
}
}
return new StallReport { Longest = stalls, OverThreshold = over, Intervals = intervals, Touches = touchQpc.Count };
}
/// <summary>The report lines. A diagnostic, and it names itself as one.</summary>
public string Describe()
{
if (Intervals == 0)
{
return " stalls: no interval to read (fewer than two presents)";
}
var sb = new StringBuilder();
sb.Append(" stalls (diagnostic, not 03_METRICS' stutter): ").Append(Num(OverThreshold))
.Append(" interval(s) of ").Append(Num(Intervals)).Append(" at or over ")
.Append(Ms(StallThresholdMs)).Append("; host touches (guard scan + module snapshot): ").Append(Num(Touches));
foreach (Stall s in Longest)
{
sb.AppendLine();
sb.Append(" longest: ").Append(Ms(s.Milliseconds)).Append(" at t=").Append(Sec(s.AtSeconds)).Append(" — ");
if (s.NearestTouchSeconds is not double d)
{
sb.Append("no host touch recorded");
}
else if (s.NearATouch)
{
sb.Append("A HOST TOUCH ").Append(d == 0 ? "INSIDE the interval" : (Math.Abs(d).ToString("0.00", CultureInfo.InvariantCulture) + " s "
+ (d < 0 ? "before" : "after") + " it"))
.Append(" — FrameLedger is a SUSPECT for this one; re-run with a longer --seconds and see whether it recurs on the 30 s cadence");
}
else
{
sb.Append("nearest host touch ").Append(Math.Abs(d).ToString("0.0", CultureInfo.InvariantCulture)).Append(" s away — not ours");
}
}
return sb.ToString();
}
private static string Num(long v) => v.ToString(CultureInfo.InvariantCulture);
private static string Ms(double v) => v.ToString("0.#", CultureInfo.InvariantCulture) + " ms";
private static string Sec(double v) => v.ToString("0.00", CultureInfo.InvariantCulture) + " s";
}
+3
View File
@@ -190,6 +190,9 @@ internal static class Program
HostConsole.Line($" records: {result.Records.Count} ({dominant.Count} on the dominant stream), " +
$"{segments.Count} segment(s), gaps {result.TotalGaps}, dropped {result.TotalDropped}");
HostConsole.Line(FocusNote(result));
// The longest raw intervals, placed against the moments this host touched the target: the
// owner saw a one-second drop to 1 FPS under capture and nothing here could say whose it was.
HostConsole.Line(StallReport.From(dominant, Stopwatch.Frequency, result.TouchQpc).Describe());
// WHICH HOOKS THE WRITER ACTUALLY INSTALLED, and it is not cosmetic.
//
@@ -0,0 +1,96 @@
using System.Diagnostics;
using FluentAssertions;
using FrameLedger.CaptureHost.Consume;
using FrameLedger.Shared;
namespace FrameLedger.CaptureHost.Tests.Consume;
/// <summary>
/// The stall diagnostic: the longest intervals, placed against the host's own touches on the target.
/// </summary>
public sealed class StallReportTests
{
private static readonly long _hz = Stopwatch.Frequency;
/// <summary>A 120 FPS stream with one gap of <paramref name="gapMs"/> after <paramref name="gapAfter"/> presents.</summary>
private static List<FlFrameRecord> StreamWithGap(int presents, int gapAfter, double gapMs, out long gapStartQpc)
{
List<FlFrameRecord> s = [];
long qpc = 5_000_000;
long step = _hz / 120;
gapStartQpc = 0;
for (int i = 0; i < presents; i++)
{
s.Add(new FlFrameRecord { FrameIndex = (uint)i, Qpc = (ulong)qpc, SwapchainId = 1 });
if (i == gapAfter)
{
gapStartQpc = qpc;
qpc += (long)(gapMs / 1000.0 * _hz);
}
else
{
qpc += step;
}
}
return s;
}
[Fact]
public void TheLongestIntervalIsFoundAndPlacedInTheSession()
{
List<FlFrameRecord> s = StreamWithGap(600, 240, 1000.0, out _);
StallReport r = StallReport.From(s, _hz, []);
r.Intervals.Should().Be(599);
r.OverThreshold.Should().Be(1);
r.Longest.Should().HaveCount(3);
r.Longest[0].Milliseconds.Should().BeApproximately(1000.0, 1.0);
r.Longest[0].AtSeconds.Should().BeApproximately(2.0, 0.01, "240 presents at 120 FPS");
r.Longest[0].NearestTouchSeconds.Should().BeNull();
r.Describe().Should().Contain("1 interval(s) of 599 at or over 100 ms").And.Contain("longest: 1000 ms at t=2.00 s")
.And.Contain("no host touch recorded");
}
[Fact]
public void AHostTouchInsideTheStallNamesFrameLedgerAsASuspect()
{
List<FlFrameRecord> s = StreamWithGap(600, 240, 1000.0, out long gapStart);
long touch = gapStart + _hz / 2; // half a second into the gap
StallReport r = StallReport.From(s, _hz, [touch]);
r.Longest[0].NearestTouchSeconds.Should().Be(0.0);
r.Longest[0].NearATouch.Should().BeTrue();
r.Describe().Should().Contain("A HOST TOUCH INSIDE the interval").And.Contain("SUSPECT");
}
[Fact]
public void AHostTouchJustBeforeTheStallIsStillASuspectAndAFarOneIsNot()
{
List<FlFrameRecord> s = StreamWithGap(600, 240, 1000.0, out long gapStart);
StallReport near = StallReport.From(s, _hz, [gapStart - _hz / 4]); // 0.25 s before
StallReport far = StallReport.From(s, _hz, [gapStart + 30 * _hz]); // 30 s after
near.Longest[0].NearestTouchSeconds.Should().BeApproximately(-0.25, 0.01);
near.Longest[0].NearATouch.Should().BeTrue();
near.Describe().Should().Contain("0.25 s before it");
far.Longest[0].NearATouch.Should().BeFalse();
far.Describe().Should().Contain("not ours");
}
[Fact]
public void ASmoothStreamHasNoStallAndStillPrintsItsLongest()
{
List<FlFrameRecord> s = StreamWithGap(300, -1, 0, out _);
StallReport r = StallReport.From(s, _hz, [(long)s[10].Qpc]);
r.OverThreshold.Should().Be(0);
r.Longest[0].Milliseconds.Should().BeApproximately(1000.0 / 120, 0.05);
r.Touches.Should().Be(1);
StallReport.From([s[0]], _hz, []).Describe().Should().Contain("fewer than two presents");
}
}