Change priority increasing scheme
This commit is contained in:
parent
c85220e6e3
commit
8b3a3efadc
|
@ -56,12 +56,13 @@ typedef struct {
|
||||||
inipri. The item is chosen from the queue based on pri and
|
inipri. The item is chosen from the queue based on pri and
|
||||||
seq. For control frames, they consist of just 1 frame and pri
|
seq. For control frames, they consist of just 1 frame and pri
|
||||||
does not change. For DATA frame, they could split up to several
|
does not change. For DATA frame, they could split up to several
|
||||||
frames. After sending a frame, the pri is increased by 1. If it
|
frames. After sending a frame, the pri becomes |inipri| +
|
||||||
becomes more than lowest priority, then it returns back to inipri
|
|pridecay| and |pridecay| is multiplied by 2. If it becomes more
|
||||||
and do the same sequence again and again. By doing this, the
|
than lowest priority, then it returns back to |inipri| and do the
|
||||||
higher priority long DATA frames don't starve the lower
|
same sequence again and again. By doing this, the higher priority
|
||||||
prioritized streams. */
|
long DATA frames don't starve the lower prioritized streams. */
|
||||||
int pri;
|
int pri;
|
||||||
|
uint32_t pridecay;
|
||||||
int64_t seq;
|
int64_t seq;
|
||||||
} nghttp2_outbound_item;
|
} nghttp2_outbound_item;
|
||||||
|
|
||||||
|
|
|
@ -388,6 +388,7 @@ int nghttp2_session_add_frame(nghttp2_session *session,
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
item->inipri = item->pri;
|
item->inipri = item->pri;
|
||||||
|
item->pridecay = 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -979,12 +980,19 @@ nghttp2_outbound_item* nghttp2_session_pop_next_ob_item
|
||||||
static void nghttp2_outbound_item_adjust_pri(nghttp2_session *session,
|
static void nghttp2_outbound_item_adjust_pri(nghttp2_session *session,
|
||||||
nghttp2_outbound_item *item)
|
nghttp2_outbound_item *item)
|
||||||
{
|
{
|
||||||
|
assert(item->pri > 0);
|
||||||
if(item->pri == NGHTTP2_PRI_LOWEST) {
|
if(item->pri == NGHTTP2_PRI_LOWEST) {
|
||||||
item->pri = item->inipri;
|
nghttp2_stream *stream;
|
||||||
} else if(item->pri > (int32_t)NGHTTP2_PRI_LOWEST/2) {
|
stream = nghttp2_session_get_stream
|
||||||
|
(session, nghttp2_outbound_item_get_data_frame(item)->hd.stream_id);
|
||||||
|
assert(stream);
|
||||||
|
item->pri = item->inipri = stream->pri;
|
||||||
|
item->pridecay = 1;
|
||||||
|
} else if(item->pri + item->pridecay > NGHTTP2_PRI_LOWEST) {
|
||||||
item->pri = NGHTTP2_PRI_LOWEST;
|
item->pri = NGHTTP2_PRI_LOWEST;
|
||||||
} else {
|
} else {
|
||||||
item->pri *= 2;
|
item->pri = item->inipri + item->pridecay;
|
||||||
|
item->pridecay *= 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue