0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 04:10:24 +00:00

Avoid resetting Websocket idle_timeout timer too often

`perf` has shown that Cowboy spends a lot of time
cancelling and starting this timer. Instead of resetting
for every data received, we now only reset a field in the
state.

Before it was working like this:

- start idle timeout timer
- on trigger, close the connection
- on data, cancel and start again

Now it's working like this:

- start idle timeout timer for a tenth of its duration, with tick number = 0
- on trigger, if tick number != 10
  - start the timer again, again for a tenth of its duration
  - increment tick number
- on trigger, if tick number = 10
  - close the connection
- on data, set tick number to 0
This commit is contained in:
Loïc Hoguin 2025-01-08 13:23:19 +01:00
parent 643b335ba8
commit 086f60cca4
No known key found for this signature in database
GPG key ID: 8A9DF795F6FED764
3 changed files with 45 additions and 15 deletions

View file

@ -9,6 +9,7 @@ PROJECT_REGISTERED = cowboy_clock
PLT_APPS = public_key ssl # ct_helper gun common_test inets
CT_OPTS += -ct_hooks cowboy_ct_hook [] # -boot start_sasl
#CT_OPTS += +JPperf true +S 1
# Dependencies.