Skip to content

Retire two superseded R-R shadow measurements (#1331/#1118) - #1487

Merged
ryanbr merged 2 commits into
mainfrom
perf/retire-superseded-rr-shadow
Aug 20, 2026
Merged

Retire two superseded R-R shadow measurements (#1331/#1118)#1487
ryanbr merged 2 commits into
mainfrom
perf/retire-superseded-rr-shadow

Conversation

@ryanbr

@ryanbr ryanbr commented Aug 20, 2026

Copy link
Copy Markdown
Owner

Follow-up to #1486. No behaviour change — this only removes instrumentation that has finished its job.

The cost

The shadow de-dup block ran 13 full passes over a night's R-R rows, six of them collapseOverCount — and each collapse sorts the night's ~50–70k intervals.

It runs for every night of an affected strap, and analyzeRecent re-scores ~21 days every 15 minutes. So the phones least able to spare the work were paying the most, for instrumentation that feeds no stored value, permanently.

Why these two specifically

The same-second tolerance sweep (20/34/60) was sizing a fix already ruled out. Every affected night reads crossSecondOverCount — no same-second tolerance can reach duplicates that straddle the boundary. That conclusion is recorded on #1331; the sweep kept measuring it anyway.

xsec was always labelled unshippable — a strict upper bound that over-merges real beats, kept only to size how far a cross-second collapse could get. It has now produced that number in the field:

covXsec=0.80   beatAccXsec=0.26

Coverage driven below 1.0 and accuracy collapsed — it eats real beats, exactly as its own comment predicted. The measurement succeeded, so it can stop running.

What survives

ex (exact duplicates only — provably no real-beat loss) as the honest floor, and dd (40 ms same-second) as the incumbent candidate. The delivery histogram from #1486 supersedes what both retired measurements were reaching for, at one pass instead of nine.

before after
passes per night 13 6
sorts per night 6 2

Parity

Identical on both platforms, verified by counting call sites in each file rather than reading the diff: 6 passes / 2 sorts on each, neither still emits hrv sweep or the xsec fields, and the replacement fragment in the surviving hrv dedup line is byte-identical across the two.

One correction inside this change

An earlier revision of this commit's message said six sorts "became three". It is twoex and dd. Corrected in the code rather than left as a plausible-sounding number, which is the precise failure mode this whole block exists to avoid.

Verification

compileFullDebugKotlin clean · full Android unit suite green · doc_comment_lint clean.

Swift is app-target here, so it needs an app-build run before merge.

ryanbr added 2 commits August 20, 2026 21:42
The shadow de-dup block ran 13 full passes over a night's R-R rows, six of them
collapseOverCount, and each collapse SORTS the night's ~50-70k intervals. It runs
for EVERY night of an affected strap, and analyzeRecent re-scores ~21 days every
15 minutes - so the phones least able to spare the work were paying the most, for
instrumentation that feeds no stored value.

Two of those measurements have finished their job.

The same-second TOLERANCE SWEEP (20/34/60) was sizing a fix already ruled out.
Every affected night reads crossSecondOverCount, so no same-second tolerance can
reach duplicates that straddle the boundary - the conclusion recorded on #1331
before this change.

`xsec`, the 40 ms collapse widened to a 1-second window, was documented from the
start as a strict UPPER BOUND that over-merges real beats, kept only to size how
far a cross-second collapse COULD get. It has now produced that number in the
field: covXsec 0.80 with beatAccXsec 0.26 - coverage driven BELOW 1.0 and
accuracy collapsed, eating real beats exactly as its own comment predicted.

What survives is the honest floor (`ex`, exact duplicates only, provably no
real-beat loss) and the incumbent candidate (`dd`, 40 ms same-second). The
delivery histogram merged in #1486 supersedes what both retired measurements
reached for, and costs one pass rather than nine.

13 passes per night became 6, and six sorts became two, identically on both
platforms - verified by counting call sites in each rather than by reading the
diff. Neither platform still emits `hrv sweep` or the xsec fields, and the
replacement fragment in the surviving `hrv dedup` line is byte-identical across
the two.

An earlier revision of this commit said six sorts "became three". It is two:
ex and dd. Corrected in the code rather than left as a plausible-sounding number,
since that is the whole failure mode this block exists to avoid.

Verification: compileFullDebugKotlin clean, full Android unit suite green,
doc_comment_lint clean.
Re-review. The retirement comment and the surviving `hrv dedup` line both told
the reader the delivery histogram is "below". It is emitted BEFORE the dedup line
- Swift appends it at 1092 against ~1120, Kotlin at 901 against ~928 - so in the
log it sits ABOVE.

A pointer in a diagnostic is only worth anything if it points the right way, and
this one would have sent someone reading a strap log looking past the thing it
was recommending. Four references, two per platform, now say above.

Nothing else changed. Verified this pass: no orphaned variables survive the
deletion on either platform, nothing anywhere consumes `hrv sweep` or the xsec
fields (no readout, test or doc parses them), the delivery histogram is still
wired on both, and the nine surviving fields of the `hrv dedup` line match across
the two platforms name for name.

Verification: compileFullDebugKotlin clean, full Android unit suite green,
doc_comment_lint clean, emitted fragment byte-identical across platforms.
@ryanbr
ryanbr merged commit 22d1ed7 into main Aug 20, 2026
3 checks passed
@ryanbr
ryanbr deleted the perf/retire-superseded-rr-shadow branch August 20, 2026 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant