[ovs-dev] [PATCH] ofproto-dpif-upcall: Improve concurrency by adjust flow-limit

Tao YunXiang taoyunxiang at cmss.chinamobile.com
Tue May 11 07:52:00 UTC 2021


OVS uses a set of gentle mechanisms in ofproto-dpif-upcall.c to control
the number of flows in the datapath. However, this mechanism will make it
difficult for the number of datapath flows to reach a high level in a short time.

Through some tests, I found that the problem is that the flow-limit
increases too slowly, but decreases very quickly. We need adjust the
algorithm to make it increase faster as it decreases.

Through this change, the test result of Apache benchmark can reach 12k from 5k,
the test command is as follows:

ab -n 200000 -c 500 -r http://1.1.1.2/


Author: Tao YunXiang <taoyunxiang at cmss.chinamobile.com>
Signed-off-by: Tao YunXiang <taoyunxiang at cmss.chinamobile.com>
Cc: Ben Pfaff <blp at ovn.org>
---
 ofproto/ofproto-dpif-upcall.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c
index ccf97266c..1ae2ba5e2 100644
--- a/ofproto/ofproto-dpif-upcall.c
+++ b/ofproto/ofproto-dpif-upcall.c
@@ -445,7 +445,7 @@ udpif_create(struct dpif_backer *backer, struct dpif *dpif)
 
     udpif->dpif = dpif;
     udpif->backer = backer;
-    atomic_init(&udpif->flow_limit, MIN(ofproto_flow_limit, 10000));
+    atomic_init(&udpif->flow_limit, ofproto_flow_limit);
     udpif->reval_seq = seq_create();
     udpif->dump_seq = seq_create();
     latch_init(&udpif->exit_latch);
@@ -963,13 +963,13 @@ udpif_revalidator(void *arg)
 
             duration = MAX(time_msec() - start_time, 1);
             udpif->dump_duration = duration;
-            if (duration > 2000) {
+
+            /* Use duration as a reference, adjust the number of flow_limit,
+             * when the duration is small, increase the flow-limit, and vice versa */
+            if (duration >= 1000) {
                 flow_limit /= duration / 1000;
-            } else if (duration > 1300) {
-                flow_limit = flow_limit * 3 / 4;
-            } else if (duration < 1000 &&
-                       flow_limit < n_flows * 1000 / duration) {
-                flow_limit += 1000;
+            } else {
+                flow_limit *= 1000 / duration;
             }
             flow_limit = MIN(ofproto_flow_limit, MAX(flow_limit, 1000));
             atomic_store_relaxed(&udpif->flow_limit, flow_limit);
-- 
2.17.1





More information about the dev mailing list