Conversation
Add a -rtc <n> flag that measures the drift of the Notecard's real-time
clock against the host computer's clock, emitting one line per second for
<n> seconds:
<n> rtc: avgDriftMsPerSecond:<rate> driftSecsPerDay:<projected>
Each second the host clock is sampled alongside the Notecard's clock via
card.time with "now":true, which reports the time as a floating-point
<epoch-seconds>.<microseconds> value.
To keep the reported figures stable rather than dominated by per-sample
USB/serial latency jitter, two techniques are used:
- Minimum round-trip filtering: each sample takes several rapid reads
and keeps the one with the lowest host round-trip time, using the
round-trip midpoint as the aligned host timestamp.
- Least-squares regression: instead of deriving the rate from just the
baseline and the current sample, the drift (microseconds of drift
since start) is regressed against host-elapsed time across every
sample collected so far. The slope is the drift rate, so per-sample
noise averages out and both reported figures converge as the run
lengthens. Regressing the drift residual directly avoids the
catastrophic cancellation of computing a slope near 1.0 and
subtracting 1.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a -rtc flag that measures the drift of the Notecard's real-time clock against the host computer's clock, emitting one line per second for seconds:
rtc: avgDriftMsPerSecond: driftSecsPerDay:
Each second the host clock is sampled alongside the Notecard's clock via card.time with "now":true, which reports the time as a floating-point . value.
To keep the reported figures stable rather than dominated by per-sample USB/serial latency jitter, two techniques are used:
Minimum round-trip filtering: each sample takes several rapid reads and keeps the one with the lowest host round-trip time, using the round-trip midpoint as the aligned host timestamp.
Least-squares regression: instead of deriving the rate from just the baseline and the current sample, the drift (microseconds of drift since start) is regressed against host-elapsed time across every sample collected so far. The slope is the drift rate, so per-sample noise averages out and both reported figures converge as the run lengthens. Regressing the drift residual directly avoids the catastrophic cancellation of computing a slope near 1.0 and subtracting 1.