From patchwork Tue Sep 17 15:53:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Maximets X-Patchwork-Id: 1986432 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X7RD763gLz1y1t for ; Wed, 18 Sep 2024 01:54:15 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id AE9A581BFA; Tue, 17 Sep 2024 15:54:12 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id o9PDGRURukmb; Tue, 17 Sep 2024 15:54:11 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.9.56; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org B047C81A27 Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id B047C81A27; Tue, 17 Sep 2024 15:54:11 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 7DEC2C0012; Tue, 17 Sep 2024 15:54:11 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 69174C0011 for ; Tue, 17 Sep 2024 15:54:10 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 42F3081A3B for ; Tue, 17 Sep 2024 15:54:10 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id Fl0XrNU5EjWQ for ; Tue, 17 Sep 2024 15:54:09 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.167.68; helo=mail-lf1-f68.google.com; envelope-from=i.maximets.ovn@gmail.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp1.osuosl.org 2EF0281A27 Authentication-Results: smtp1.osuosl.org; dmarc=none (p=none dis=none) header.from=ovn.org DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 2EF0281A27 Received: from mail-lf1-f68.google.com (mail-lf1-f68.google.com [209.85.167.68]) by smtp1.osuosl.org (Postfix) with ESMTPS id 2EF0281A27 for ; Tue, 17 Sep 2024 15:54:08 +0000 (UTC) Received: by mail-lf1-f68.google.com with SMTP id 2adb3069b0e04-53661ac5ba1so6012999e87.2 for ; Tue, 17 Sep 2024 08:54:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726588447; x=1727193247; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=btXx3+RdFAUjF7nGdGBjOilPiwlqJFD28nxcoBlxyYY=; b=OHsKoM5La89vwglA7zOvZF7JPXP/1mvzGwxpNYxSfuuQ1fuBjobPesOoFjVS8K+YQX rnItwc+hqDCqia1CJ56MwX2p4bzDKai9D1DaxHCN39wNuV9NvnuQlJ//LqBc03omnpr6 0IK7DR7hYeNo5fh4UeT51yEfj7b3cOcGY4RAimq2pXE32DCzdwdvMY/AiXLmDMxpUo+P XqFzJJq0pYbwUcGT5dOvlYmZ8tFarRouuqGYSeUucRexob1NvZtd8537LTDymPcDjGfD dYAnSVsppejd8Hj0OGCHj57uxHFiJhQfocXWFWhCvJ/9AQKfgs+KrDk2sW7vM5RuEFmU 4pMg== X-Gm-Message-State: AOJu0Yx+iiilAsZRZLKVcBdWnyxStftq/EafCpFoTDjEcBUm6Do1J36l p7Wbsi0PdR3pBVrf38k3voyPgLi6Br2iNGocbEMFg0UB3rSWZbs94od7M0mD X-Google-Smtp-Source: AGHT+IH9cvXe4KWDkaAMmdR99DnZOeBjZvHHsXkV3lbRNFajclbynC2IdMF552iNmqB3eDw0U5xIhw== X-Received: by 2002:a05:6512:3d88:b0:533:47ca:9773 with SMTP id 2adb3069b0e04-53678ff4966mr10576300e87.57.1726588446510; Tue, 17 Sep 2024 08:54:06 -0700 (PDT) Received: from im-t490s.redhat.com (ip-86-49-44-151.bb.vodafone.cz. [86.49.44.151]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a90612b3fcesm463414766b.133.2024.09.17.08.54.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Sep 2024 08:54:06 -0700 (PDT) From: Ilya Maximets To: ovs-dev@openvswitch.org Date: Tue, 17 Sep 2024 17:53:55 +0200 Message-ID: <20240917155403.547543-1-i.maximets@ovn.org> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 Subject: [ovs-dev] [PATCH ovn] northd: Don't monitor most of northbound external IDs. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dumitru Ceara , Ilya Maximets Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" ovn-northd copies external IDs from Logical Switch, Router and their Port records to corresponding Southbound Datapath and Port Binding records. IDs in other tables are not used by northd in any way, so there is no point in monitoring them. CMSes tend to create a huge amount of external IDs for every record to the point where they can take literally half of the database data. In high scale clusters that can be several hundreds of MB. Not monitoring them saves a lot of time and memory while downloading initial database snapshots on the first connection and should also reduce the ongoing cost while new resources are being created. This will also help avoiding unnecessary re-computes when external IDs are updated without changing any other data. Tested on a 500 MB Northbound DB that contains 1M ACLs created by ovn-kubernetes in a test cluster mimicking a real world setup. Before the change it took 20 seconds for the ovsdb-server to send out an initial database snapshot and 19 seconds for ovn-northd to receive it, parse and run a full recompute, consuming 5.4 GB of RAM. With the change it takes 15 seconds on the database side and 11 seconds for the ovn-northd, consuming 2.9 GB of RAM. (Note: the test was performed in a sandbox with no OVN chassis connected, so northd didn't generate a lot of logical flows for those ACLs.) So, we saved: - 25% of CPU time on the database side. - 42% of CPU time on the ovn-northd side. - 2.5 GB (46%) of RAM on ovn-northd. Signed-off-by: Ilya Maximets Acked-by: Han Zhou --- northd/ovn-northd.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c index d71114f35..89ef4e870 100644 --- a/northd/ovn-northd.c +++ b/northd/ovn-northd.c @@ -820,6 +820,42 @@ main(int argc, char *argv[]) ovsdb_idl_omit_alert(ovnnb_idl_loop.idl, &nbrec_nb_global_col_hv_cfg_timestamp); + /* Ignore northbound external IDs, except for logical switch, router and + * their ports, for which the external IDs are propagated to corresponding + * southbound datapath and port binding records. */ + const struct ovsdb_idl_column *external_ids[] = { + &nbrec_acl_col_external_ids, + &nbrec_address_set_col_external_ids, + &nbrec_bfd_col_external_ids, + &nbrec_chassis_template_var_col_external_ids, + &nbrec_connection_col_external_ids, + &nbrec_copp_col_external_ids, + &nbrec_dhcp_options_col_external_ids, + &nbrec_dhcp_relay_col_external_ids, + &nbrec_dns_col_external_ids, + &nbrec_forwarding_group_col_external_ids, + &nbrec_gateway_chassis_col_external_ids, + &nbrec_ha_chassis_col_external_ids, + &nbrec_ha_chassis_group_col_external_ids, + &nbrec_load_balancer_col_external_ids, + &nbrec_load_balancer_health_check_col_external_ids, + &nbrec_logical_router_policy_col_external_ids, + &nbrec_logical_router_static_route_col_external_ids, + &nbrec_meter_col_external_ids, + &nbrec_meter_band_col_external_ids, + &nbrec_mirror_col_external_ids, + &nbrec_nat_col_external_ids, + &nbrec_nb_global_col_external_ids, + &nbrec_port_group_col_external_ids, + &nbrec_qos_col_external_ids, + &nbrec_ssl_col_external_ids, + &nbrec_sample_collector_col_external_ids, + &nbrec_sampling_app_col_external_ids, + }; + for (size_t i = 0; i < ARRAY_SIZE(external_ids); i++) { + ovsdb_idl_omit(ovnnb_idl_loop.idl, external_ids[i]); + } + unixctl_command_register("nb-connection-status", "", 0, 0, ovn_conn_show, ovnnb_idl_loop.idl);