Skip to content

[wasm] spread WS based timers over next 6 minutes to prevent heavy throttling#57745

Merged
pavelsavara merged 8 commits intodotnet:mainfrom
pavelsavara:wasm_prevent_timer_throttling
Aug 26, 2021
Merged

[wasm] spread WS based timers over next 6 minutes to prevent heavy throttling#57745
pavelsavara merged 8 commits intodotnet:mainfrom
pavelsavara:wasm_prevent_timer_throttling

Conversation

@pavelsavara
Copy link
Member

@pavelsavara pavelsavara commented Aug 19, 2021

Problem

Chromium browsers throttle setTimeout frequency on inactive pages to 1 sec almost immediately.
5 minutes later they throttle heavily to wakeup each 60 seconds.
That breaks dotnet Timer expectations and also threadpool.

The heavy throttling could be lifted back to 1sec if there was WebSocket activity.
https://developer.chrome.com/blog/timer-throttling-in-chrome-88/#intensive-throttling

Implementation

The idea is to cover the future 6 minutes with "wakeup" timer, each 1 second apart from each other.
1 second, because is the light throttling rate, so it would not help to try to do it more often.
It should be triggered from WS event, so that it's only 1 deep from it.
Every subsequent call would schedule only for uncovered future.

There is [OuterLoop] unit test for this.

Fixes #51041

Loading
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[WASM] Chrome timer throttling affects runtime

3 participants