misc/wasm: performance of runtime.gopark #56100
Labels
arch-wasm
WebAssembly issues
NeedsFix
The path to resolution is known, but the work has not been done.
Performance
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Interrupted a time.Sleep with function callbacks
The whole program:
What did you expect to see?
only calling one setTimeout every 50 ms
What did you see instead?
it seems that every time the program is interrupted while sleeping, it clears the timeouts and recreates them, leading to excessive amounts of setTimeout and clearTimeout calls
When logging scheduleTimeoutEvent and clearTimeoutEvent, the console is flooded with messages clearing the timeout only to recreate it moments later
On a separate, bigger, project
On another project, runtime.gopark takes up approximately 25% of execution time. Most of this is due to repeated calls of setTimeout and clearTimeout. It appears that the go runtime does a clearTimeout and setTimeout whenever it is awoken.
I implemented a patch that improves performance by keeping setTimeout tasks alive and counting the number of references to them:
but this would ideally be fixed on the Go side
perf after above change:
The text was updated successfully, but these errors were encountered: