From 51c927b8979a690911da9addfec1dc1cf7947a67 Mon Sep 17 00:00:00 2001 From: Edward Chin Date: Tue, 18 Nov 2014 13:21:00 -0800 Subject: [PATCH] add custom getLoad() for multifeed leaf Summary: getLoad() is called in servicerouter loadbalancing when a load_counter is not specified. I added a custom getLoad() for leaf and made it so that different metrics can be tested without code pushes. Changes: 1) Overloaded PriorityThreadManager::getCodel() so you can specify a PRIORITY. aggr->leaf thrift calls are marked as HIGH priority. 2) The value of FLAGS_load_metric determines what metric the custom getLoad() will use (codel, max requests, or fallback to ThriftServer::getLoad()). 3) Smc listener for FLAGS_load_metric. 4) Removed server->setIsUnevenLoad(false) since there isn't reason this need to be set, and activeRequests_ and getPendingCount() are not tracked when isUnevenLoad_ is false. Test Plan: Run leaf and check that smc listener works. Custom getLoad() won't be called until t5625774 is resolved. Reviewed By: hitesh@fb.com Subscribers: njormrod, folly-diffs@, trunkagent, varunk, fugalh, alandau, nkgupta, bmatheny, jaredg, xie, mshneer, yguo FB internal diff: D1685215 Signature: t1:1685215:1416339297:0d1f8cb0cec27242d95f0067337d80149b0a720e --- folly/experimental/wangle/concurrent/Codel.cpp | 7 ++++++- folly/experimental/wangle/concurrent/Codel.h | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/folly/experimental/wangle/concurrent/Codel.cpp b/folly/experimental/wangle/concurrent/Codel.cpp index d6558d4c..527058ce 100644 --- a/folly/experimental/wangle/concurrent/Codel.cpp +++ b/folly/experimental/wangle/concurrent/Codel.cpp @@ -80,7 +80,12 @@ bool Codel::overloaded(std::chrono::microseconds delay) { } int Codel::getLoad() { - return std::min(100, (int)codelMinDelay_.count() / FLAGS_codel_interval); + return std::min(100, (int)codelMinDelay_.count() / + (2 * FLAGS_codel_target_delay)); +} + +int Codel::getMinDelay() { + return (int) codelMinDelay_.count(); } }} //namespace diff --git a/folly/experimental/wangle/concurrent/Codel.h b/folly/experimental/wangle/concurrent/Codel.h index f969fc36..16f0205b 100644 --- a/folly/experimental/wangle/concurrent/Codel.h +++ b/folly/experimental/wangle/concurrent/Codel.h @@ -50,6 +50,8 @@ class Codel { // Return: 0 = no delay, 100 = At the queueing limit int getLoad(); + int getMinDelay(); + private: std::chrono::microseconds codelMinDelay_; std::chrono::time_point codelIntervalTime_; -- 2.34.1