tests/fio: regression coverage for ref_time_ticks() ns normalization#2690
Merged
Conversation
PR #2685 normalized ref_time_ticks() to nanoseconds across every platform (Windows used to return raw QPC ticks at the underlying counter's frequency — typically 10 MHz). The fix shipped without a unit test that would have caught a units regression. Add four tests under tests/fio/perf_time.das (sleep() lives in fio, so this is the right neighborhood): - monotonic — 1000 successive reads never go backwards. Catches any signed/unsigned mixup or wrap-around bug in the ns conversion arithmetic. - sleep_roundtrip — sleep(100 ms) -> delta_ns must land in [80 ms, 500 ms]. The 80 ms lower bound is the load-bearing assertion: if Windows reverted to raw QPC ticks (10 MHz counter on the typical box -> a 100 ms wall-clock sleep would surface as 1000000 "ticks" interpreted as ns, i.e. 1 ms), the test would trip. Wide upper bound covers CI runner scheduler jitter. - get_time_usec_agrees — the get_time_usec(t0) helper agrees with (ref_time_ticks() - t0) / 1000 within 5 ms. Two helpers reading the same underlying clock should not drift; if one ever ends up on a different code path, this notices. - units_are_nanoseconds — three back-to-back sleep(100 ms) deltas stay within 200 ms spread. If the unit accidentally changed mid-run (think: thread-local frequency cache going stale), the deltas would diverge wildly. The test runs cleanly in both interpreter and AOT mode on Windows (Win11 local): sleep(100 ms) -> 102-109 ms delta, get_time_usec agrees to within microseconds. tests/aot/CMakeLists.txt:224 already covers tests/fio/*.das via FILE(GLOB CONFIGURE_DEPENDS); cmake reconfigure picks the new file up automatically. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new test file tests/fio/perf_time.das with four regression tests that pin the post‑PR‑#2685 contract that ref_time_ticks() returns nanoseconds on every platform. The tests exercise monotonicity, a sleep(100ms) round‑trip with a load‑bearing 80 ms lower bound (would catch a regression to raw QPC ticks on Windows), agreement between get_time_usec and the raw delta, and inter‑sample uniformity across three back‑to‑back sleeps. The file is automatically picked up by the existing tests/fio/*.das glob in tests/aot/CMakeLists.txt, so no build changes are required.
Changes:
- New tests/fio/perf_time.das with 4 [test] functions covering monotonicity, sleep round‑trip bounds, helper/delta agreement, and ns unit sanity.
- Uses the standard
dastest/testing_boost public+daslib/fio+mathimports consistent with the rest oftests/. - Tolerances chosen to absorb CI scheduler jitter (Windows up to ~200 ms) while still detecting a unit regression.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
PR #2685 normalized
ref_time_ticks()to return nanoseconds on every platform (Windows used to return raw QPC ticks at the underlying counter's frequency — typically 10 MHz). The fix shipped without a unit test that would have caught a units regression.This PR adds
tests/fio/perf_time.daswith four tests:sleep(100 ms)→ delta must land in[80 ms, 500 ms]. The 80 ms lower bound is the load-bearing assertion: if Windows reverted to raw QPC ticks, a 100 ms sleep would surface as ~1 ms in the ns interpretation, tripping the test. Wide upper bound covers CI runner scheduler jitter.get_time_usec(t0)and(ref_time_ticks() - t0) / 1000agree within 5 ms. Two helpers reading the same underlying clock should not drift.sleep(100 ms)deltas stay within 200 ms of each other.tests/aot/CMakeLists.txt:224already coverstests/fio/*.dasviaFILE(GLOB CONFIGURE_DEPENDS); cmake reconfigure picks the new file up automatically (no CMake edit needed).Test plan
daslang.exe dastest.das -- --test tests/fio/perf_time.das— interpreter mode, 4/4 PASS on Windows localdaslang.exe dastest.das -- --test tests/fio— full fio dir, 175/175 PASS (interpreter)test_aot.exe -use-aot dastest.das -- --use-aot --test tests/fio/perf_time.das— AOT mode, 4/4 PASS on Windows local🤖 Generated with Claude Code