From 4234c7c719f542193c358e67200e3c88041a1a26 Mon Sep 17 00:00:00 2001 From: --add <--add> Date: Mon, 3 Apr 2023 12:38:53 +0300 Subject: [PATCH 1/3] latest changes --- lib/conntest.ml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/conntest.ml b/lib/conntest.ml index e2c95fc..af25411 100644 --- a/lib/conntest.ml +++ b/lib/conntest.ml @@ -348,6 +348,26 @@ module Make *) Log.debug (fun m -> m "feed_source: packet_index_diff < 0"); let did_set = ref false in + let map_rev_shortcircuit f r = + let i = ref 0 in + let len = Ring.length r in + let ring_copy = Array.copy r.Ring.ring in + while !i < len do + let idx_opt = Ring.wrap_reverse_i r !i in + match idx_opt with + | None -> i := len + | Some idx -> + let value_opt = Ring.get_previous r !i in + match value_opt with + | None -> i := len + | Some x -> + match f x with + | None -> i := len + | Some y -> + ring_copy.(idx) <- Some y; i := succ !i + done; + { r with Ring.ring = ring_copy } + in (*> goto perf; could use something like 'find_map_rev' * which would try the latest packets first - * which should be more often hit From 6b7ba873b0ad76c9df2fbdc2b57633631c028189 Mon Sep 17 00:00:00 2001 From: --add <--add> Date: Mon, 3 Apr 2023 12:58:22 +0300 Subject: [PATCH 2/3] shortcircuit if the Ring contains None fixed --- lib/conntest.ml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/conntest.ml b/lib/conntest.ml index af25411..2fd6afa 100644 --- a/lib/conntest.ml +++ b/lib/conntest.ml @@ -359,7 +359,7 @@ module Make | Some idx -> let value_opt = Ring.get_previous r !i in match value_opt with - | None -> i := len + | None -> ring_copy.(idx) <- None; i := succ !i | Some x -> match f x with | None -> i := len @@ -367,6 +367,7 @@ module Make ring_copy.(idx) <- Some y; i := succ !i done; { r with Ring.ring = ring_copy } + in (*> goto perf; could use something like 'find_map_rev' * which would try the latest packets first - From 5613968967f6ce2e6dd43c9171e2603da19eef58 Mon Sep 17 00:00:00 2001 From: --add <--add> Date: Mon, 3 Apr 2023 13:33:18 +0300 Subject: [PATCH 3/3] map_rev moved inside ring module --- lib/conntest.ml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/conntest.ml b/lib/conntest.ml index 2fd6afa..6c97f76 100644 --- a/lib/conntest.ml +++ b/lib/conntest.ml @@ -132,6 +132,27 @@ module Make done; !acc + let map_rev_shortcircuit f r = + let i = ref 0 in + let len = length r in + let ring_copy = Array.copy r.ring in + while !i < len do + let idx_opt = wrap_reverse_i r !i in + match idx_opt with + | None -> i := len + | Some idx -> + let value_opt = get_previous r !i in + match value_opt with + | None -> ring_copy.(idx) <- None; i := succ !i + | Some x -> + match f x with + | None -> i := len + | Some y -> + ring_copy.(idx) <- Some y; i := succ !i + done; + { r with ring = ring_copy } + + end module Udp_flow = struct