From 659942d8c95a2f57f0eca5d57ba4c6c4c9f956fe Mon Sep 17 00:00:00 2001 From: bspark Date: Fri, 15 Jul 2016 13:14:13 +0900 Subject: [PATCH] Modify reducing reservation function to reflect rho effect in weight-based phase. Signed-off-by: bspark --- src/dmclock_server.h | 45 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/src/dmclock_server.h b/src/dmclock_server.h index ee9ec4a..be1a3b4 100644 --- a/src/dmclock_server.h +++ b/src/dmclock_server.h @@ -111,6 +111,8 @@ namespace crimson { #ifndef DO_NOT_DELAY_TAG_CALC Time arrival; #endif + uint32_t rho; + uint32_t delta; RequestTag(const RequestTag& prev_tag, const ClientInfo& client, @@ -132,22 +134,31 @@ namespace crimson { client.limit_inv, req_params.delta, false)), - ready(false) + ready(false), #ifndef DO_NOT_DELAY_TAG_CALC - , arrival(time) + arrival(time), #endif + rho(req_params.rho), + delta(req_params.delta) { assert(reservation < max_tag || proportion < max_tag); } - RequestTag(double _res, double _prop, double _lim, const Time& _arrival) : + RequestTag(double _res, + double _prop, + double _lim, + const Time& _arrival, + uint32_t _rho = 1, + uint32_t _delta = 1) : reservation(_res), proportion(_prop), limit(_lim), - ready(false) + ready(false), #ifndef DO_NOT_DELAY_TAG_CALC - , arrival(_arrival) + arrival(_arrival), #endif + rho(_rho), + delta(_delta) { assert(reservation < max_tag || proportion < max_tag); } @@ -156,10 +167,12 @@ namespace crimson { reservation(other.reservation), proportion(other.proportion), limit(other.limit), - ready(other.ready) + ready(other.ready), #ifndef DO_NOT_DELAY_TAG_CALC - , arrival(other.arrival) + arrival(other.arrival), #endif + rho(other.rho), + delta(other.delta) { // empty } @@ -250,6 +263,7 @@ namespace crimson { C client; RequestTag prev_tag; std::deque requests; + uint32_t popped_req_rho; // amount added from the proportion tag as a result of // an idle client becoming unidle @@ -275,6 +289,7 @@ namespace crimson { Counter current_tick) : client(_client), prev_tag(0.0, 0.0, 0.0, TimeZero), + popped_req_rho(1), info(_info), idle(true), last_tick(current_tick), @@ -303,6 +318,14 @@ namespace crimson { prev_tag.proportion = value - (adjust_by_inc ? info.weight_inv : 0.0); } + inline uint32_t get_popped_req_rho() const { + return popped_req_rho; + } + + inline void set_popped_req_rho(uint32_t rho) { + popped_req_rho = rho; + } + inline void add_request(const RequestTag& tag, const C& client_id, RequestRef&& request) { @@ -779,6 +802,10 @@ namespace crimson { // pop request and adjust heaps top.pop_request(); + // store popped request's rho to handle reducing reservation + // tags process when weight-based scheduling case + top.set_popped_req_rho(first.tag.rho); + #ifndef DO_NOT_DELAY_TAG_CALC if (top.has_request()) { ClientReq& next_first = top.next_request(); @@ -830,7 +857,7 @@ namespace crimson { // data_mtx should be held when called void reduce_reservation_tags(ClientRec& client) { for (auto& r : client.requests) { - r.tag.reservation -= client.info.reservation_inv; + r.tag.reservation -= (client.get_popped_req_rho() * client.info.reservation_inv); #ifndef DO_NOT_DELAY_TAG_CALC // reduce only for front tag. because next tags' value are invalid @@ -838,7 +865,7 @@ namespace crimson { #endif } // don't forget to update previous tag - client.prev_tag.reservation -= client.info.reservation_inv; + client.prev_tag.reservation -= (client.get_popped_req_rho() * client.info.reservation_inv); resv_heap.promote(client); }