@@ -111,6 +111,8 @@ namespace crimson {
111111 double proportion;
112112 double limit;
113113 bool ready; // true when within limit
114+ uint32_t delta;
115+ uint32_t rho;
114116#ifndef DO_NOT_DELAY_TAG_CALC
115117 Time arrival;
116118#endif
@@ -135,19 +137,28 @@ namespace crimson {
135137 client.limit_inv,
136138 req_params.delta,
137139 false )),
138- ready (false )
140+ ready (false ),
141+ delta (req_params.delta),
142+ rho (req_params.rho)
139143#ifndef DO_NOT_DELAY_TAG_CALC
140144 , arrival(time)
141145#endif
142146 {
143147 assert (reservation < max_tag || proportion < max_tag);
144148 }
145149
146- RequestTag (double _res, double _prop, double _lim, const Time& _arrival) :
150+ RequestTag (double _res,
151+ double _prop,
152+ double _lim,
153+ uint32_t _delta,
154+ uint32_t _rho,
155+ const Time& _arrival) :
147156 reservation (_res),
148157 proportion (_prop),
149158 limit (_lim),
150- ready (false )
159+ ready (false ),
160+ delta (_delta),
161+ rho (_rho)
151162#ifndef DO_NOT_DELAY_TAG_CALC
152163 , arrival(_arrival)
153164#endif
@@ -159,7 +170,9 @@ namespace crimson {
159170 reservation (other.reservation),
160171 proportion (other.proportion),
161172 limit (other.limit),
162- ready (other.ready)
173+ ready (other.ready),
174+ delta (other.delta),
175+ rho (other.rho)
163176#ifndef DO_NOT_DELAY_TAG_CALC
164177 , arrival(other.arrival)
165178#endif
@@ -211,6 +224,8 @@ namespace crimson {
211224 " r:" << format_tag (tag.reservation ) <<
212225 " p:" << format_tag (tag.proportion ) <<
213226 " l:" << format_tag (tag.limit ) <<
227+ " delta:" << tag.delta <<
228+ " rho:" << tag.rho <<
214229#if 0 // try to resolve this to make sure Time is operator<<'able.
215230#ifndef DO_NOT_DELAY_TAG_CALC
216231 " arrival:" << tag.arrival <<
@@ -277,6 +292,7 @@ namespace crimson {
277292 C client;
278293 RequestTag prev_tag;
279294 std::deque<ClientReq> requests;
295+ uint32_t popped_req_rho;
280296
281297 // amount added from the proportion tag as a result of
282298 // an idle client becoming unidle
@@ -301,7 +317,8 @@ namespace crimson {
301317 const ClientInfo& _info,
302318 Counter current_tick) :
303319 client (_client),
304- prev_tag (0.0 , 0.0 , 0.0 , TimeZero),
320+ prev_tag (0.0 , 0.0 , 0.0 , 1 , 1 , TimeZero),
321+ popped_req_rho (1 ),
305322 info (_info),
306323 idle (true ),
307324 last_tick (current_tick),
@@ -329,6 +346,14 @@ namespace crimson {
329346 last_tick = _tick;
330347 }
331348
349+ inline uint32_t get_popped_req_rho () const {
350+ return popped_req_rho;
351+ }
352+
353+ inline void set_popped_req_rho (uint32_t rho) {
354+ popped_req_rho = rho;
355+ }
356+
332357 inline void add_request (const RequestTag& tag,
333358 const C& client_id,
334359 RequestRef&& request) {
@@ -818,7 +843,7 @@ namespace crimson {
818843 } // if this client was idle
819844
820845#ifndef DO_NOT_DELAY_TAG_CALC
821- RequestTag tag (0 , 0 , 0 , time);
846+ RequestTag tag (0 , 0 , 0 , 1 , 1 , time);
822847
823848 if (!client.has_request ()) {
824849 tag = RequestTag (client.get_req_tag (), client.info ,
@@ -872,6 +897,10 @@ namespace crimson {
872897 // pop request and adjust heaps
873898 top.pop_request ();
874899
900+ // store popped request's rho to handle reducing reservation
901+ // tags process when weight-based scheduling case
902+ top.set_popped_req_rho (first.tag .rho );
903+
875904#ifndef DO_NOT_DELAY_TAG_CALC
876905 if (top.has_request ()) {
877906 ClientReq& next_first = top.next_request ();
@@ -899,15 +928,15 @@ namespace crimson {
899928 // data_mtx should be held when called
900929 void reduce_reservation_tags (ClientRec& client) {
901930 for (auto & r : client.requests ) {
902- r.tag .reservation -= client.info .reservation_inv ;
931+ r.tag .reservation -= ( client.get_popped_req_rho () * client. info .reservation_inv ) ;
903932
904933#ifndef DO_NOT_DELAY_TAG_CALC
905934 // reduce only for front tag. because next tags' value are invalid
906935 break ;
907936#endif
908937 }
909938 // don't forget to update previous tag
910- client.prev_tag .reservation -= client.info .reservation_inv ;
939+ client.prev_tag .reservation -= ( client.get_popped_req_rho () * client. info .reservation_inv ) ;
911940 resv_heap.promote (client);
912941 }
913942
0 commit comments