summaryrefslogtreecommitdiff
path: root/controller/PostgreSQL.cpp
diff options
context:
space:
mode:
authorGrant Limberg <[email protected]>2022-06-22 09:25:47 -0700
committerGrant Limberg <[email protected]>2022-06-22 09:43:09 -0700
commit9e8215b2131c4330b5bb72c1ee30ec3399eae0c4 (patch)
tree8a068fab79a0a223ba5db5e018b9ba720ac15ed3 /controller/PostgreSQL.cpp
parente958a83dd4a1ea644554911c54a5e72208632a0f (diff)
adjust sleep between onlineNotification runs. Added timer to output
Diffstat (limited to 'controller/PostgreSQL.cpp')
-rw-r--r--controller/PostgreSQL.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/controller/PostgreSQL.cpp b/controller/PostgreSQL.cpp
index 0d3c6169..db703ad4 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<std::chrono::microseconds>(end - start);;
+ auto dur = std::chrono::duration_cast<std::chrono::microseconds>(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<uint64_t,uint64_t>,std::pair<int64_t,InetAddress>,_PairHasher > lastOnline;
{
std::lock_guard<std::mutex> 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<std::chrono::milliseconds>(end - start);
+ auto total = dur.count();
+
+ fprintf(stderr, "onlineNotification ran in %llu ms", total);
+
+ std::this_thread::sleep_for(std::chrono::seconds(1));
}
}