Repository navigation
Make the race tests 7x faster by skipping the race detector's exit sleep in the fake CLI - #5
Merged
Merged
Conversation
A -race binary sleeps for GORACE atexit_sleep_ms (one second by default) when it exits with status 0, to catch races at exit. The fake agent-browser is the test binary run once per CLI call, so every call slept a second: the tools tests took 79s with -race here and 282s on a 4-CPU CI runner, against 3.4s without -race. The fake now exits with syscall.Exit, which skips that shutdown. The code under test is still race-checked in the test process. With -race the tools package takes about 10s and the whole suite about 12s.
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
-racebinary sleeps forGORACEatexit_sleep_ms(1000 ms by default) when it exits with status 0, to catch races at exit. The fakeagent-browseris the test binary run once per CLI call, so every fake call slept a second.func main(){}built with-racetakes 1,087 ms against 6 ms without, using no CPU.runtime.main → __tsan::Finalize → usleep.syscall.Exit, which skips that shutdown (internal/testutil/fakecli/fakecli.go). The code under test is still race-checked in the test process; only the fake skips it.go test -race(16-core Mac)internal/mcp/toolsinternal/browserinternal/devtools./...(wall)Test plan
go test -race -count=1 ./...five times in a row: all pass, tools 10.3–11.1 sgo test -count=1 ./...andgo vet ./...,gofmt -lclean