Skip to content

stdlib-complexity: on Windows the 15.6 ms CPU-time tick is a quarter of the 50 ms sample, so a linear row reads 7.8x at n×4 and fails (btree-map-str-descending, v0.16.0.1 Windows leg, twice) #2894

Closed

Description

@ehartford

v0.16.0.1 Windows x86_64 leg (win10, seed-driven :test), twice in a row:

btree-map-str-descending        n=1000  small_ns=2500000        large_ns=19531250       within_bound=false
panic at test/complexity/stdlib.w:454:9: assertion failed

Both numbers are tick-quantized: Windows counts process CPU time in 15.6 ms scheduler ticks (the #1998 comment says so), and elapsed samples until the clock moved SAMPLE_NS = 50 ms, about three ticks. A large run of ~3 repetitions carries up to one tick of error, 5 ms per run, against a bound of small×6+1 ms = 16 ms; the true n log n ratio (~4.5x, 11 ms) plus the quantization lands at 19.5 ms. The same row passed on the same VM an hour earlier: the verdict is the clock's granularity, not the container's complexity.

Fix: measure the clock's tick at start (spin until cpu_time_ns changes twice) and sample at least ~20 ticks (max(50 ms, 20×tick)): Linux and macOS keep 50 ms, Windows samples ~310 ms and the quantization error drops under 5%. The run grows from ~19 s to ~1 min on Windows only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions