Skip to content

Commit

Permalink
Modify reducing reservation function to reflect rho effect
Browse files Browse the repository at this point in the history
in weight-based phase.

Signed-off-by: bspark <[email protected]>
  • Loading branch information
bspark8 authored and TaewoongKim committed Dec 20, 2016
1 parent 2c1ad4a commit 659942d
Showing 1 changed file with 36 additions and 9 deletions.
45 changes: 36 additions & 9 deletions src/dmclock_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
}
Expand All @@ -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
}
Expand Down Expand Up @@ -250,6 +263,7 @@ namespace crimson {
C client;
RequestTag prev_tag;
std::deque<ClientReq> requests;
uint32_t popped_req_rho;

// amount added from the proportion tag as a result of
// an idle client becoming unidle
Expand All @@ -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),
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -830,15 +857,15 @@ 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
break;
#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);
}

Expand Down

0 comments on commit 659942d

Please sign in to comment.