Merge pull request #5827 from urbit/ted/ames-clog-less

ames: %clog less
This commit is contained in:
Josh Lehman 2023-02-13 06:36:57 -08:00 committed by GitHub
commit ad190807c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2571,27 +2571,40 @@
?: =(0 (end 0 bone)) ?: =(0 (end 0 bone))
~ ~
`u=message-pump-state `u=message-pump-state
:: clogged: are five or more response messages unsent to this peer?
:: ::
=/ clogged=? =/ clogged=?
=| acc=@ud |^ &(nuf-messages nuf-memory)
:: +nuf-messages: are there enough messages to mark as clogged?
::
++ nuf-messages
=| num=@ud
|- ^- ? |- ^- ?
?~ pumps ?~ pumps |
%.n =. num
=. acc ;: add num
%+ add acc
%+ add
:: in-flight messages
::
(sub [next current]:i.pumps) (sub [next current]:i.pumps)
:: queued messages
::
~(wyt in unsent-messages.i.pumps) ~(wyt in unsent-messages.i.pumps)
:: ==
?: (gte acc 5) ?: (gte num 5)
%.y &
$(pumps t.pumps) $(pumps t.pumps)
:: if clogged, notify client vanek :: +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 ?. clogged
peer-core peer-core