Merge branch 'ted/ames-clog-less' into yu/adjust-clog

This commit is contained in:
yosoyubik 2023-02-12 08:36:39 +01:00
commit f2f339e4f3

View File

@ -2571,27 +2571,40 @@
?: =(0 (end 0 bone))
~
`u=message-pump-state
:: clogged: are five or more response messages unsent to this peer?
::
=/ clogged=?
=| acc=@ud
|- ^- ?
?~ pumps
%.n
=. acc
%+ add acc
%+ add
:: in-flight messages
::
(sub [next current]:i.pumps)
:: queued messages
::
~(wyt in unsent-messages.i.pumps)
|^ &(nuf-messages nuf-memory)
:: +nuf-messages: are there enough messages to mark as clogged?
::
?: (gte acc 5)
%.y
$(pumps t.pumps)
:: if clogged, notify client vanek
++ nuf-messages
=| num=@ud
|- ^- ?
?~ pumps |
=. num
;: add num
(sub [next current]:i.pumps)
~(wyt in unsent-messages.i.pumps)
==
?: (gte num 5)
&
$(pumps t.pumps)
:: +nuf-memory: is enough memory used to mark as clogged?
::
++ nuf-memory
=| mem=@ud
|- ^- ?
?~ pumps |
=. mem
%+ add
%- ~(rep in unsent-messages.i.pumps)
|=([a=@ b=_mem] (add b (met 3 a)))
?~ unsent-fragments.i.pumps 0
(met 3 fragment.i.unsent-fragments.i.pumps)
?: (gte mem 100.000)
&
$(pumps t.pumps)
--
:: if clogged, notify client vane
::
?. clogged
peer-core