Skip to content

Preserve sub-millisecond event timestamp precision - #7

Open
bmehta001 wants to merge 6 commits into
mainfrom
bhamehta/fix-event-timestamp-precision
Open

Preserve sub-millisecond event timestamp precision#7
bmehta001 wants to merge 6 commits into
mainfrom
bhamehta/fix-event-timestamp-precision

Conversation

@bmehta001

Copy link
Copy Markdown
Owner

Summary

  • preserve nanosecond-derived 100 ns precision for default POSIX event timestamps
  • use GetSystemTimePreciseAsFileTime on Windows when available, with a Windows 7-compatible fallback
  • add regression coverage for POSIX timestamps retaining sub-millisecond ticks

Fixes microsoft#1514.

Validation

  • git diff --check passed
  • Fresh Windows CMake configuration succeeded
  • The unit-test build was blocked by existing configuration issues: missing gtest/gtest.lib and /WX failures from pre-existing HAVE_MAT_AI macro redefinition / exception-mode warnings

bmehta001 and others added 6 commits August 3, 2026 12:34
Use precise wall-clock time where available and retain nanosecond-derived 100 ns ticks on POSIX so record.time no longer truncates every event to milliseconds. Add regression coverage for POSIX timestamp precision.\n\nCo-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>\nCopilot-Session: 05d1030e-75b0-447f-9856-65091d59a97f
* Stabilize timing-sensitive tests

Use a monotonic injectable clock for kill-switch deadlines, replace the sleep-heavy expiration functional test with deterministic unit coverage, and simulate expired SQLite leases directly.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 77649dd9-3b60-4ca4-861d-8c5ac165d53c

* Restore temporary kill-switch integration coverage

Rewrite killIsTemporary to observe active drops and eventual server delivery instead of sleeping for a fixed expiration window. Keep every wait bounded without adding test-only access to production internals.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 77649dd9-3b60-4ca4-861d-8c5ac165d53c

* Fix Windows CI and harden injected clocks

Rename the temporary kill-switch logger so MSVC /WX no longer promotes C4458 into C2220 in both Windows pipelines.

Files changed:
- lib/offline/KillSwitchManager.hpp: fall back from an empty Clock and invoke injected callbacks outside the mutex.
- tests/unittests/KillSwitchManagerTests.cpp: cover the empty-clock fallback.
- tests/functests/BasicFuncTests.cpp: avoid shadowing the fixture logger member.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 7fe5faca-d77c-45c4-85d3-0d4a00d68a94

* Harden temporary kill-switch polling

Decode only newly arrived requests after releasing the HTTP callback mutex, avoiding repeated parsing and preventing the polling helper from delaying incoming requests. Treat kill-switch activation as a fatal prerequisite while preserving teardown on failure.

Files changed:
- tests/functests/BasicFuncTests.cpp: snapshot new requests outside the decode path and fail fast when activation is not observed.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 7fe5faca-d77c-45c4-85d3-0d4a00d68a94

* Make bad-network teardown test deterministic

Replace external endpoints with an injected HTTP client that holds requests until teardown cancellation, then reports NetworkFailure through the required exactly-once callback. This preserves the real cancellation and callback-drain path without simulator or network timing.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 77649dd9-3b60-4ca4-861d-8c5ac165d53c

* tests: use SentCount() in WaitForRequest instead of m_sent.load() directly

WaitForRequest polled m_sent.load() directly while SentCount() was
already the named accessor for the same value. Using SentCount() keeps
the implementation consistent with the class's own public API and means
any future change to the accessor (e.g. different memory order) is
automatically picked up.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 7fe5faca-d77c-45c4-85d3-0d4a00d68a94

* tests: clean up kill-switch test and reduce lease TTL in offline storage test

BasicFuncTests/killIsTemporary: flatten acceptedAfterKillExpires polling loop.
- Remove redundant pre-loop waitForEvent (nothing sent yet at that point,
  so it always returned false).
- Remove redundant post-loop grace-period block; absorb the 100 ms into
  expiryDeadline so the single loop covers both the poll and the grace.

OfflineStorageTests_SQLite/ReservedRecordsAreReleasedAfterTimeout:
- Reduce lease TTL from 60000 ms to 5000 ms. The value is the storage
  reservation duration, not a wall-clock wait (the test fast-forwards
  expiry via SQL). 5 s is clearer to readers and equally correct.

KillSwitchManager::expiryFromNow: add precondition comment documenting
that seconds > 0 is required and why all callers must guard it.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 7fe5faca-d77c-45c4-85d3-0d4a00d68a94

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 77649dd9-3b60-4ca4-861d-8c5ac165d53c
Copilot-Session: 7fe5faca-d77c-45c4-85d3-0d4a00d68a94
Resolve GetSystemTimePreciseAsFileTime once instead of repeating module and symbol lookups for every event timestamp.\n\nCo-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>\nCopilot-Session: 05d1030e-75b0-447f-9856-65091d59a97f
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.

Event timestamps (record.time) only have millisecond resolution despite 100ns tick field

2 participants