From 0c462420a29eaba26c0868e3686ce30d4f63fcf4 Mon Sep 17 00:00:00 2001 From: Kamil Cudnik Date: Tue, 16 Nov 2021 19:47:46 +0100 Subject: [PATCH] [orchagent] Flush pipeline every 1 second, not only when select will timeout (#2003) * Added flush for async communication pipeline, every 1 second, not only if select will timeout. --- orchagent/orchdaemon.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/orchagent/orchdaemon.cpp b/orchagent/orchdaemon.cpp index f01a6ded7a49..9b533676ceb5 100644 --- a/orchagent/orchdaemon.cpp +++ b/orchagent/orchdaemon.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include "orchdaemon.h" #include "logger.h" @@ -645,6 +646,8 @@ void OrchDaemon::start() m_select->addSelectables(o->getSelectables()); } + auto tstart = std::chrono::high_resolution_clock::now(); + while (true) { Selectable *s; @@ -652,6 +655,17 @@ void OrchDaemon::start() ret = m_select->select(&s, SELECT_TIMEOUT); + auto tend = std::chrono::high_resolution_clock::now(); + + auto diff = std::chrono::duration_cast(tend - tstart); + + if (diff.count() >= SELECT_TIMEOUT) + { + tstart = std::chrono::high_resolution_clock::now(); + + flush(); + } + if (ret == Select::ERROR) { SWSS_LOG_NOTICE("Error: %s!\n", strerror(errno));