Penalize cycle according to effective weight

This commit is contained in:
Tatsuhiro Tsujikawa 2015-04-17 21:17:22 +09:00
parent 57644e0256
commit 1a12a9b397
2 changed files with 9 additions and 3 deletions

View File

@ -2246,9 +2246,10 @@ static void session_outbound_item_schedule(nghttp2_session *session,
int32_t weight) { int32_t weight) {
size_t delta = item->frame.hd.length * NGHTTP2_MAX_WEIGHT / weight; size_t delta = item->frame.hd.length * NGHTTP2_MAX_WEIGHT / weight;
assert(session->last_cycle <= item->cycle); if (session->last_cycle < item->cycle) {
session->last_cycle = item->cycle;
}
session->last_cycle = item->cycle;
item->cycle = session->last_cycle + delta; item->cycle = session->last_cycle + delta;
} }

View File

@ -101,7 +101,12 @@ static int stream_push_item(nghttp2_stream *stream, nghttp2_session *session) {
return 0; return 0;
} }
item->cycle = session->last_cycle; /* Penalize item by delaying scheduling according to effective
weight. This will delay low priority stream, which is good.
OTOH, this may incur delay for high priority item. Will see. */
item->cycle =
session->last_cycle +
NGHTTP2_DATA_PAYLOADLEN * NGHTTP2_MAX_WEIGHT / stream->effective_weight;
switch (item->frame.hd.type) { switch (item->frame.hd.type) {
case NGHTTP2_DATA: case NGHTTP2_DATA: