Back the coverage accumulator off on large apps - #37
Merged
Conversation
The periodic takePreciseCoverage() that guards against Chrome being killed mid-collection ran on a fixed 100ms timer. That assumes the call is cheap, and it isn't: V8 serialises every loaded script, so the cost scales with the app. Measured on a mid-size Ember app, with only a handful of unit tests running: calls=24 mean=35.2ms median=2ms p90=98ms max=188ms (29% over 50ms) Against a 100ms interval that leaves the browser doing little except producing coverage, and testem runs N of these per machine. On a large suite it pushed tests past their own timeouts — an app with ~32 browsers per CI machine saw 141 tests time out that otherwise pass. Schedule the next take off how long the last one actually took, at roughly a 1/10 duty cycle, never sooner than the configured floor. Small apps keep the current cadence, large apps back off on their own rather than needing every consumer to rediscover this and hand-tune it. Adds chrome.cacheInterval (default 100) for that floor.
Contributor
Coverage reports
Each artifact is the scenario's From this CI run for a1e5386. |
Merged
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.
Note
Made with Claude Code. Apologies if I've misjudged the tradeoff here — the duty-cycle factor is a number I picked from measurements on one app, so push back if you'd rather it were shaped differently.
The problem
The proactive accumulator (the safety net for Chrome being SIGTERMed before the final take lands) re-takes coverage on a fixed 100ms timer. That assumes
takePreciseCoverageis cheap. It isn't — V8 serialises every currently-loaded script, so the cost scales with the app.I instrumented the call on a mid-size Ember app, running only a handful of unit tests:
p90 is essentially the whole interval. The browser spends most of its time producing coverage rather than running tests, and testem runs N browsers per machine.
On a large suite (~32 browsers per CI machine) this was enough to push 141 tests past their 10s QUnit timeout — tests that pass with coverage off. Both the acceptance and non-acceptance shards went red purely from the overhead, with no coverage errors at all.
The change
Schedule the next take off how long the last one actually took, at roughly a 1/10 duty cycle, and never sooner than a configured floor:
Self-tuning rather than a knob felt right here: the cost depends on the app under test, so every consumer would otherwise have to hit this and discover the reason before knowing what to set.
chrome.cacheInterval(default100) is exposed for the floor anyway.The accumulator's purpose is unaffected — it's a fallback for the shutdown race, and a few hundred ms of staleness is well inside what the
/_coveragehandler's live take covers.Testing
Full suite passes locally: 5 files / 41 tests,
oxlint+oxfmtclean.What I have not done is prove the 141 timeouts go away, because that needs this released and consumed by the app in question. I can confirm it once it's out — happy to hold the release until then if you'd rather see that evidence first.
Unsure about