From 953273004a12c2d143503a1da78cba5791c326b2 Mon Sep 17 00:00:00 2001 From: Ted Blackman Date: Sat, 4 Jun 2022 17:18:21 -0500 Subject: [PATCH 1/6] ames: clog at 100kB instead of 5 messages --- pkg/arvo/sys/vane/ames.hoon | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/pkg/arvo/sys/vane/ames.hoon b/pkg/arvo/sys/vane/ames.hoon index b2b4f8c9b..5fdc79af2 100644 --- a/pkg/arvo/sys/vane/ames.hoon +++ b/pkg/arvo/sys/vane/ames.hoon @@ -2182,7 +2182,7 @@ ?: =(0 (end 0 bone)) ~ `u=message-pump-state - :: clogged: are five or more response messages unsent to this peer? + :: clogged: are outgoing messages to this peer using too much memory? :: =/ clogged=? =| acc=@ud @@ -2192,14 +2192,15 @@ =. acc %+ add acc %+ add - :: in-flight messages - :: - (sub [next current]:i.pumps) - :: queued messages - :: - ~(wyt in unsent-messages.i.pumps) + =- (roll - add) + (turn ~(tap to unsent-messages.i.pumps) |=(b=@ (met 3 b))) + ?~ unsent-fragments.i.pumps + 0 + (met 3 fragment.i.unsent-fragments.i.pumps) + :: 100.000 chosen so roughly 10.000 peers could be + :: clogged without killing the loom :: - ?: (gte acc 5) + ?: (gte acc 100.000) %.y $(pumps t.pumps) :: if clogged, notify client vanek From d2ea33ddfeb1a842d3bb4448dfdb87747b6d4dce Mon Sep 17 00:00:00 2001 From: Ted Blackman Date: Sun, 5 Jun 2022 08:49:47 -0500 Subject: [PATCH 2/6] ames: condense message size calculation Co-authored-by: fang --- pkg/arvo/sys/vane/ames.hoon | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/arvo/sys/vane/ames.hoon b/pkg/arvo/sys/vane/ames.hoon index 5fdc79af2..48cfd6b92 100644 --- a/pkg/arvo/sys/vane/ames.hoon +++ b/pkg/arvo/sys/vane/ames.hoon @@ -2192,8 +2192,9 @@ =. acc %+ add acc %+ add - =- (roll - add) - (turn ~(tap to unsent-messages.i.pumps) |=(b=@ (met 3 b))) + %+ roll ~(tap to unsent-messages.i.pumps) + |= [a=@ b=@ud] + (add b (met 3 a)) ?~ unsent-fragments.i.pumps 0 (met 3 fragment.i.unsent-fragments.i.pumps) From 1380e83b55cb7a4e1cba09d0bb5df4d4f306bbd6 Mon Sep 17 00:00:00 2001 From: Ted Blackman Date: Wed, 15 Jun 2022 15:17:21 -0600 Subject: [PATCH 3/6] ames: clog on 5 messages and 100kB --- pkg/arvo/sys/vane/ames.hoon | 55 +++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/pkg/arvo/sys/vane/ames.hoon b/pkg/arvo/sys/vane/ames.hoon index 48cfd6b92..4a19c10f5 100644 --- a/pkg/arvo/sys/vane/ames.hoon +++ b/pkg/arvo/sys/vane/ames.hoon @@ -2182,29 +2182,44 @@ ?: =(0 (end 0 bone)) ~ `u=message-pump-state - :: clogged: are outgoing messages to this peer using too much memory? :: =/ clogged=? - =| acc=@ud - |- ^- ? - ?~ pumps - %.n - =. acc - %+ add acc - %+ add - %+ roll ~(tap to unsent-messages.i.pumps) - |= [a=@ b=@ud] - (add b (met 3 a)) - ?~ unsent-fragments.i.pumps - 0 - (met 3 fragment.i.unsent-fragments.i.pumps) - :: 100.000 chosen so roughly 10.000 peers could be - :: clogged without killing the loom + |^ &(nuf-messages nuf-memory) :: - ?: (gte acc 100.000) - %.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 + =| mem=@ud + |- ^- ? + ?~ pumps | + =. mem + ;: add mem + %+ roll ~(tap to unsent-messages.i.pumps) + |=([a=@ b=@ud] (add b (met 3 a))) + :: + ?~ unsent-fragments.i.pumps + 0 + (met 3 fragment.i.unsent-fragments.i.pumps) + == + :: 100.000 chosen so roughly 10.000 peers could be + :: clogged without killing the loom + :: + ?: (gte mem 100.000) + & + $(pumps t.pumps) + -- + :: if clogged, notify client vane :: ?. clogged peer-core From 0190a477f51f9ce3f9f9b4392ff9d688076aec1b Mon Sep 17 00:00:00 2001 From: Ted Blackman Date: Wed, 15 Jun 2022 15:35:41 -0600 Subject: [PATCH 4/6] ames: adjust comments --- pkg/arvo/sys/vane/ames.hoon | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkg/arvo/sys/vane/ames.hoon b/pkg/arvo/sys/vane/ames.hoon index 4a19c10f5..3301e403a 100644 --- a/pkg/arvo/sys/vane/ames.hoon +++ b/pkg/arvo/sys/vane/ames.hoon @@ -2185,6 +2185,7 @@ :: =/ clogged=? |^ &(nuf-messages nuf-memory) + :: +nuf-messages: are there enough messages to mark as clogged? :: ++ nuf-messages =| num=@ud @@ -2198,6 +2199,7 @@ ?: (gte num 5) & $(pumps t.pumps) + :: +nuf-memory: is enough memory used to mark as clogged? :: ++ nuf-memory =| mem=@ud @@ -2212,9 +2214,6 @@ 0 (met 3 fragment.i.unsent-fragments.i.pumps) == - :: 100.000 chosen so roughly 10.000 peers could be - :: clogged without killing the loom - :: ?: (gte mem 100.000) & $(pumps t.pumps) From dd812283ac6b303bb2f205e6b82c90a3dc88b155 Mon Sep 17 00:00:00 2001 From: yosoyubik Date: Thu, 9 Feb 2023 10:47:49 +0100 Subject: [PATCH 5/6] ames: optimize memory measurement Co-authored-by: Joe Bryan --- pkg/arvo/sys/vane/ames.hoon | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/pkg/arvo/sys/vane/ames.hoon b/pkg/arvo/sys/vane/ames.hoon index 6254ea8f3..81e41e248 100644 --- a/pkg/arvo/sys/vane/ames.hoon +++ b/pkg/arvo/sys/vane/ames.hoon @@ -2595,14 +2595,11 @@ |- ^- ? ?~ pumps | =. mem - ;: add mem - %+ roll ~(tap to unsent-messages.i.pumps) - |=([a=@ b=@ud] (add b (met 3 a))) - :: - ?~ unsent-fragments.i.pumps - 0 - (met 3 fragment.i.unsent-fragments.i.pumps) - == + %+ 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) From abbd95f2ce636050a81e59be7bec2df18cb73fe2 Mon Sep 17 00:00:00 2001 From: yosoyubik Date: Thu, 9 Feb 2023 13:12:50 +0100 Subject: [PATCH 6/6] ames: fix typo --- pkg/arvo/sys/vane/ames.hoon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/arvo/sys/vane/ames.hoon b/pkg/arvo/sys/vane/ames.hoon index 81e41e248..25cfd1e54 100644 --- a/pkg/arvo/sys/vane/ames.hoon +++ b/pkg/arvo/sys/vane/ames.hoon @@ -2598,7 +2598,7 @@ %+ add %- ~(rep in unsent-messages.i.pumps) |=([a=@ b=_mem] (add b (met 3 a))) - ?~ unsent-fragments.i.pumps. 0 + ?~ unsent-fragments.i.pumps 0 (met 3 fragment.i.unsent-fragments.i.pumps) ?: (gte mem 100.000) &