Skip to content

bench: sample turns in microseconds instead of whole milliseconds - #186

Open
mparrett wants to merge 1 commit into
mainfrom
wt/bench-precision
Open

bench: sample turns in microseconds instead of whole milliseconds#186
mparrett wants to merge 1 commit into
mainfrom
wt/bench-precision

Conversation

@mparrett

Copy link
Copy Markdown
Collaborator

xsofy.perf/time-turn timed each turn with System/currentTimeMillis, so every per-turn sample was floor-quantized to a whole millisecond before any statistic ran. On a ~9 ms turn that hides anything smaller than ~10% from every downstream percentile — and the quantization error is correlated, so summing samples doesn't recover it. We hit this A/B-ing lg builds against the pinned release: two builds whose real difference was ~0.8 ms/turn read as identical 9 ms columns.

Changes:

  • time-turn samples with System/nanoTime and returns integer microseconds. Integer µs keeps aggregation exact, stays readable in the dev console's 'bench dump, and fits a 32-bit int (~35 min/turn) where nanoseconds would overflow at ~2.1 s on TinyGo-class targets.
  • summarize maps carry :unit :us so consumers don't have to guess the unit from magnitude.
  • bench/native.lg prints ms with three decimals (avg-ms/p50-ms/... headers instead of a per-cell suffix).

Same build, before and after:

:wait           285     9ms     9ms    12ms    22ms      (before)
:wait           285     9.966     9.252    13.914    40.708  (after)

Verified: full test suite green (318 tests, 0 fail); the bench runs under both the pinned v1.12.2 lg and a tip build; the console 'bench command still returns in well under a second.

System/currentTimeMillis floor-quantizes a ~9ms turn to an integer
before any stat runs, so sub-ms deltas between builds are invisible to
every downstream percentile. Sample with System/nanoTime and keep
per-turn samples as integer microseconds (readable in the console
'bench dump, and safe in a 32-bit int for TinyGo-class targets);
summarize maps carry :unit :us, and the native driver formats ms with
three decimals.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@mparrett
mparrett requested a review from nnunley August 13, 2026 17:34
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