os/exec: parallel Command.Start() can be very slow #46388
Labels
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Performance
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes (1.16.4).
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Where main.go is https://play.golang.org/p/VN5OqF23nDQ
What did you expect to see?
exec.Command.Start()
times be consistent between serial and parallel runs.What did you see instead?
Parallel
exec.Command.Start()
times can be around 70 times greater than serial ones.Setting
runtime.GOMAXPROCS()
to greater than or equal to the number of concurrent Start()s doesn't help. Setting it to 1 does reduce the effect, but I still get a few starts in the multiple millisecond range.A runtime trace seems to suggest this is caused by os.StartProcess taking a global mutex lock, I think as explained here:
go/src/syscall/exec_unix.go
Lines 20 to 65 in d050238
But I wondered if there's any other way around this for this particular use case?
The text was updated successfully, but these errors were encountered: