From 942a0f831f739d602d5da5d58df8e646c69f4b0a Mon Sep 17 00:00:00 2001 From: Sonic Build Admin Date: Thu, 9 Oct 2025 20:05:37 +0000 Subject: [PATCH] [ZmqOrch] Optimize memory by popping batch size at a time **What I did** 1. Used a reference instead of a unnecessary copy of a set object 2. Optimize memory by popping batch size at a time **NOTE: Please merge only after the below two PR's are merged** https://github.com/sonic-net/sonic-swss-common/pull/1084 https://github.com/sonic-net/sonic-sairedis/pull/1660 **Why I did it** To reduce peak memory usage when applying high-volume dash configuration **How I verified it** **Details if related** --- orchagent/dash/dashvnetorch.cpp | 2 +- orchagent/zmqorch.cpp | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/orchagent/dash/dashvnetorch.cpp b/orchagent/dash/dashvnetorch.cpp index f163ee35..adc6e7e6 100644 --- a/orchagent/dash/dashvnetorch.cpp +++ b/orchagent/dash/dashvnetorch.cpp @@ -438,7 +438,7 @@ void DashVnetOrch::addPaValidation(const string& key, VnetMapBulkContext& ctxt) string underlay_ip_str = to_string(ctxt.metadata.underlay_ip()); string pa_ref_key = ctxt.vnet_name + ":" + underlay_ip_str; - auto vnet_underlay_ips = vnet_table_[ctxt.vnet_name].underlay_ips; + auto& vnet_underlay_ips = vnet_table_[ctxt.vnet_name].underlay_ips; std::string underlay_sip_str = to_string(ctxt.metadata.underlay_ip()); if (vnet_underlay_ips.find(underlay_sip_str) != vnet_underlay_ips.end()) { diff --git a/orchagent/zmqorch.cpp b/orchagent/zmqorch.cpp index 1a9b8995..d9232190 100644 --- a/orchagent/zmqorch.cpp +++ b/orchagent/zmqorch.cpp @@ -9,14 +9,11 @@ void ZmqConsumer::execute() { SWSS_LOG_ENTER(); - size_t update_size = 0; auto table = static_cast(getSelectable()); - do - { - std::deque entries; - table->pops(entries); - update_size = addToSync(entries); - } while (update_size != 0); + + std::deque entries; + table->pops(entries); + addToSync(entries); drain(); }