From patchwork Tue May 11 07:52:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: taoyunxiang X-Patchwork-Id: 1476896 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FfVkb2D1Wz9sWq for ; Tue, 11 May 2021 18:01:59 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 0654B40590; Tue, 11 May 2021 08:01:57 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Wi_haCTXCHkQ; Tue, 11 May 2021 08:01:56 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTP id 0F427404E3; Tue, 11 May 2021 08:01:55 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id E5413C000E; Tue, 11 May 2021 08:01:54 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 9303CC0001 for ; Tue, 11 May 2021 08:01:52 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 7FB8B404E7 for ; Tue, 11 May 2021 08:01:52 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id quMfOGWKmRzb for ; Tue, 11 May 2021 08:01:50 +0000 (UTC) X-Greylist: delayed 00:09:05 by SQLgrey-1.8.0 Received: from cmccmta2.chinamobile.com (cmccmta2.chinamobile.com [221.176.66.80]) by smtp4.osuosl.org (Postfix) with ESMTP id F28A4404E3 for ; Tue, 11 May 2021 08:01:48 +0000 (UTC) Received: from spf.mail.chinamobile.com (unknown[172.16.121.7]) by rmmx-syy-dmz-app06-12006 (RichMail) with SMTP id 2ee6609a37a7e14-02693; Tue, 11 May 2021 15:52:07 +0800 (CST) X-RM-TRANSID: 2ee6609a37a7e14-02693 X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 Received: from yun.localdomain (unknown[112.25.154.146]) by rmsmtp-syy-appsvr04-12004 (RichMail) with SMTP id 2ee4609a37a5a66-c7d57; Tue, 11 May 2021 15:52:06 +0800 (CST) X-RM-TRANSID: 2ee4609a37a5a66-c7d57 From: Tao YunXiang To: dev@openvswitch.org Date: Tue, 11 May 2021 15:52:00 +0800 Message-Id: <20210511075200.19037-1-taoyunxiang@cmss.chinamobile.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <8> References: <8> Cc: Tao YunXiang Subject: [ovs-dev] [PATCH] ofproto-dpif-upcall: Improve concurrency by adjust flow-limit X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" 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 Signed-off-by: Tao YunXiang Cc: Ben Pfaff --- 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);