8000 capture: order live timestamps with a shared monotonic clock by tomrford · Pull Request #82 · tomrford/gocan · GitHub
[go: up one dir, main page]

Skip to content

capture: order live timestamps with a shared monotonic clock - #82

Merged
tomrford merged 1 commit into
mainfrom
feat/capture-monotonic-clock
Sep 11, 2026
Merged

tomrford merged 1 commit into
mainfrom
feat/capture-monotonic-clock

Conversation

@tomrford
@tomrford tomrford commented Sep 11, 2026 •
Copy link
Copy Markdown
Owner

Frames from different buses could receive host timestamps before entering the shared capture lock, leaving timestamps out of append order. Live drivers now use Capture.RecordFrame and RecordEvent, which assign timestamps under that lock from monotonic elapsed time anchored when the capture is created. Append and AppendEvent continue to preserve supplied timestamps.

ASC rejects timestamp regressions instead of silently clamping them; equal timestamps remain valid. Driver timestamp plumbing is removed while retaining per-bus native I/O ordering. The capture clock survives Clear and ignores subsequent wall-clock corrections; suspend behaviour follows Go's platform-dependent monotonic clock.

Validation:

  • Full local race suite, vet, formatting and diff checks passed; Windows amd64/arm64/386 and Linux amd64 compilation passed.
  • Full SocketCAN suite passed on pifive with isolated vcan, both normally and with the race detector, with no skipped tests.
  • Tom reports that the Vector hardware test passed.
  • Independent adversarial/minimalism review found no defects. Python-can 4.6.1 verified ASC payloads, equal timestamps and omission of rejected records.
  • Six alternating pifive benchmark samples show receive throughput changes of -2.4%, -7.5% and -9.1% with 1, 3 and 5 receivers. Five receivers still process 660k records/s, equivalent to 338 Mbps of 64-byte payloads. This excludes physical adapter and trace-export costs.

Note

Medium Risk
Changes timestamp assignment for all live driver paths and ASC export semantics; ordering bugs would affect traces and multi-bus captures, though behavior is heavily tested.

Overview
Introduces Capture.RecordFrame and RecordEvent, which stamp live traffic under the capture lock from monotonic elapsed time anchored at NewCapture, so multi-bus captures get timestamps in append order instead of racing on time.Now() outside the lock. Append / AppendEvent still honor caller-supplied times; drivers (PCAN, SocketCAN, Vector, virtual) now record via the live APIs and no longer thread host timestamps through decode paths.

The ASC writer stops clamping regressing timestamps and returns an error when a record would go backward; equal timestamps stay valid. Docs and tests cover the shared clock (including concurrent multi-bus), ASC rejection, and relaxed virtual RX/TX timestamp equality (RX must not precede TX).

Reviewed by Cursor Bugbot for commit 4ecbf62. Configure here.

@tomrford
tomrford merged commit 9cba256 into main Sep 11, 2026
2 checks passed
@tomrford
tomrford deleted the feat/capture-monotonic-clock branch September 17, 2026 09:12
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

0