Skip to content

fix: increase performance test tolerance to prevent flaky failures#64

Open
Yanhu007 wants to merge 1 commit intoelliotchance:masterfrom
Yanhu007:fix/flaky-performance-test
Open

fix: increase performance test tolerance to prevent flaky failures#64
Yanhu007 wants to merge 1 commit intoelliotchance:masterfrom
Yanhu007:fix/flaky-performance-test

Conversation

@Yanhu007
Copy link
Copy Markdown

@Yanhu007 Yanhu007 commented Apr 14, 2026

Fixes #61

Problem

TestGetElement/Performance (and similar performance subtests for Set and Get) intermittently fail on Go 1.24+ because the tolerance of 0.5 * res1.NsPerOp() is too tight.

When the absolute timings are small (e.g., 48 ns/op), a 50% tolerance allows only 24 ns difference, but benchmark noise can easily exceed that:

Error: Max difference between 48 and 79 allowed is 24, but difference was -31

Fix

Increase the tolerance from 0.5x to 1.0x the baseline. This still validates O(1) behavior (the 4x-larger map should complete within 2x the time of the smaller map) while being robust against benchmark variance on fast runtimes.

All tests pass.


This change is Reviewable

The O(1) performance assertions used a tolerance of 0.5x the
baseline (res1.NsPerOp), which is too tight on faster runtimes
like Go 1.24 where absolute timings are smaller and GC/scheduler
variance is relatively larger.

Increase tolerance to 1.0x the baseline, which still validates
O(1) behavior (res4 should be within 2x of res1) while being
robust against benchmark noise.

Fixes elliotchance#61
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.

TestGetElement/Performance unstable when tested with go1.24

1 participant