From a1bd26a165675ff2da733274765c8fa0395bf453 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Tue, 5 Mar 2019 08:38:50 -0500 Subject: [PATCH 1/2] update profiling code to decay instead of clearing all stats --- llarp/profiling.cpp | 18 +++++++++--------- llarp/profiling.hpp | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/llarp/profiling.cpp b/llarp/profiling.cpp index c81ec26c4..1a0d2c9ff 100644 --- a/llarp/profiling.cpp +++ b/llarp/profiling.cpp @@ -46,24 +46,24 @@ namespace llarp } void - RouterProfile::Clear() + RouterProfile::Decay() { - connectGoodCount = 0; - connectTimeoutCount = 0; - pathSuccessCount = 0; - pathFailCount = 0; - lastUpdated = llarp::time_now_ms(); + connectGoodCount /= 2; + connectTimeoutCount /= 2; + pathSuccessCount /= 2; + pathFailCount /= 2; + lastUpdated = llarp::time_now_ms(); } void RouterProfile::Tick() { - // 10 minutes - static constexpr llarp_time_t updateInterval = DEFAULT_PATH_LIFETIME; + // 20 minutes + static constexpr llarp_time_t updateInterval = DEFAULT_PATH_LIFETIME * 2; auto now = llarp::time_now_ms(); if(lastUpdated < now && now - lastUpdated > updateInterval) { - Clear(); + Decay(); } } diff --git a/llarp/profiling.hpp b/llarp/profiling.hpp index 2022774a1..da5641295 100644 --- a/llarp/profiling.hpp +++ b/llarp/profiling.hpp @@ -32,9 +32,9 @@ namespace llarp bool IsGood(uint64_t chances) const; - /// clear stats + /// decay stats void - Clear(); + Decay(); // rotate stats if timeout reached void From 4dbeae63ee22f87153bab1fd5abb805c54461d04 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Tue, 5 Mar 2019 08:39:06 -0500 Subject: [PATCH 2/2] handle kqueue code more like epoll's code --- llarp/ev/ev_kqueue.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/llarp/ev/ev_kqueue.cpp b/llarp/ev/ev_kqueue.cpp index 3981f9950..e3ff995ca 100644 --- a/llarp/ev/ev_kqueue.cpp +++ b/llarp/ev/ev_kqueue.cpp @@ -374,13 +374,22 @@ llarp_kqueue_loop::tick(int ms) llarp::ev_io* ev = static_cast< llarp::ev_io* >(events[idx].udata); if(ev) { - if(events[idx].filter & EVFILT_WRITE) + if(events[idx].filter & EV_ERROR) { - ev->flush_write_buffers(events[idx].data); + ev->error(); + } + else if(events[idx.filter] & EV_EOF == 0) + { + if(events[idx].filter & EVFILT_WRITE) + { + ev->flush_write_buffers(events[idx].data); + } + if(events[idx].filter & EVFILT_READ) + { + ev->read(readbuf, + std::min(sizeof(readbuf), size_t(events[idx].data))); + } } - if(events[idx].filter & EVFILT_READ) - ev->read(readbuf, - std::min(sizeof(readbuf), size_t(events[idx].data))); } ++idx; }