test(cloudflare): stop comparing call-order timing halves in perf regression test - #266
Merged
Merged
Conversation
…ression test The first-half-vs-second-half average comparison was flaky: repeated local runs show the first 2-3 calls in the loop are consistently ~100x faster than the rest (interpreter/GC warm-up in the benchmark loop itself, not fetchConfig()), so whichever half absorbed that warm-up boundary swung its average unpredictably and the 3x ratio assertion passed or failed essentially at random. Switching to a median-based comparison doesn't fix it either (verified empirically: 10-27x ratio every run) since the warm-up split confounds any first-half/second-half comparison regardless of statistic used. Replaced with a per-call absolute ceiling, which still catches a real regression (a hang, or an accidental O(n^2) over repeated calls) without being sensitive to that noise. Verified stable across 21 consecutive runs (isolated, full-file, and full-directory).
|
🎉 This PR is included in version 3.14.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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
fetchConfig()calls, failing if the second half was >3x slower.fetchConfig(). Whichever half absorbed that warm-up boundary swung its average unpredictably, so the ratio assertion passed or failed close to at random depending on system load.fetchConfig()has no accumulating per-call state that could cause a real slowdown across repeated calls (confirmed by readingCloudflareFirewallService/CloudflareClient— its internalApiCachewould make repeat calls faster, not slower).Test plan
cloudflare/__tests__/directory run 3x in a row — 506/506 tests pass each time--cimode run once — 19/19 passeslinton the changed file — 0 errors (pre-existingno-consolewarnings only, not introduced by this change)tsc --noEmit— clean