From 9e8215b2131c4330b5bb72c1ee30ec3399eae0c4 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 22 Jun 2022 09:25:47 -0700 Subject: [PATCH] adjust sleep between onlineNotification runs. Added timer to output --- controller/PostgreSQL.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/controller/PostgreSQL.cpp b/controller/PostgreSQL.cpp index 0d3c61697..db703ad46 100644 --- a/controller/PostgreSQL.cpp +++ b/controller/PostgreSQL.cpp @@ -899,7 +899,7 @@ void PostgreSQL::initializeMembers() networkId = ""; auto end = std::chrono::high_resolution_clock::now(); - auto dur = std::chrono::duration_cast(end - start);; + auto dur = std::chrono::duration_cast(end - start); total += dur.count(); ++count; if (count > 0 && count % 10000 == 0) { @@ -1678,6 +1678,8 @@ void PostgreSQL::onlineNotification_Redis() std::string controllerId = std::string(_myAddress.toString(buf)); while (_run == 1) { + auto start = std::chrono::high_resolution_clock::now(); + std::unordered_map< std::pair,std::pair,_PairHasher > lastOnline; { std::lock_guard l(_lastOnline_l); @@ -1696,7 +1698,14 @@ void PostgreSQL::onlineNotification_Redis() } catch (sw::redis::Error &e) { fprintf(stderr, "Error in online notification thread (redis): %s\n", e.what()); } - std::this_thread::sleep_for(std::chrono::seconds(10)); + + auto end = std::chrono::high_resolution_clock::now(); + auto dur = std::chrono::duration_cast(end - start); + auto total = dur.count(); + + fprintf(stderr, "onlineNotification ran in %llu ms", total); + + std::this_thread::sleep_for(std::chrono::seconds(1)); } }