Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
nghttp2
Commits
abcdbf00
Commit
abcdbf00
authored
Dec 08, 2015
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Take into account remainder due to integer division when calculating cycle
parent
4bcc14fc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
18 deletions
+33
-18
lib/nghttp2_stream.c
lib/nghttp2_stream.c
+31
-18
lib/nghttp2_stream.h
lib/nghttp2_stream.h
+2
-0
No files found.
lib/nghttp2_stream.c
View file @
abcdbf00
...
...
@@ -80,6 +80,7 @@ void nghttp2_stream_init(nghttp2_stream *stream, int32_t stream_id,
stream
->
queued
=
0
;
stream
->
descendant_last_cycle
=
0
;
stream
->
cycle
=
0
;
stream
->
pending_penalty
=
0
;
stream
->
descendant_next_seq
=
0
;
stream
->
seq
=
0
;
stream
->
last_writelen
=
0
;
...
...
@@ -115,9 +116,14 @@ static int stream_subtree_active(nghttp2_stream *stream) {
/*
* Returns next cycle for |stream|.
*/
static
uint64_t
stream_next_cycle
(
nghttp2_stream
*
stream
,
uint64_t
last_cycle
)
{
return
last_cycle
+
stream
->
last_writelen
*
NGHTTP2_MAX_WEIGHT
/
(
uint32_t
)
stream
->
weight
;
static
void
stream_next_cycle
(
nghttp2_stream
*
stream
,
uint64_t
last_cycle
)
{
size_t
penalty
;
penalty
=
stream
->
last_writelen
*
NGHTTP2_MAX_WEIGHT
+
stream
->
pending_penalty
;
stream
->
cycle
=
last_cycle
+
penalty
/
(
uint32_t
)
stream
->
weight
;
stream
->
pending_penalty
=
penalty
%
(
uint32_t
)
stream
->
weight
;
}
static
int
stream_obq_push
(
nghttp2_stream
*
dep_stream
,
nghttp2_stream
*
stream
)
{
...
...
@@ -125,7 +131,6 @@ static int stream_obq_push(nghttp2_stream *dep_stream, nghttp2_stream *stream) {
for
(;
dep_stream
&&
!
stream
->
queued
;
stream
=
dep_stream
,
dep_stream
=
dep_stream
->
dep_prev
)
{
stream
->
cycle
=
stream_next_cycle
(
stream
,
dep_stream
->
descendant_last_cycle
);
stream
->
seq
=
dep_stream
->
descendant_next_seq
++
;
...
...
@@ -169,6 +174,7 @@ static void stream_obq_remove(nghttp2_stream *stream) {
stream
->
queued
=
0
;
stream
->
cycle
=
0
;
stream
->
pending_penalty
=
0
;
stream
->
descendant_last_cycle
=
0
;
stream
->
last_writelen
=
0
;
...
...
@@ -209,7 +215,6 @@ void nghttp2_stream_reschedule(nghttp2_stream *stream) {
for
(;
dep_stream
;
stream
=
dep_stream
,
dep_stream
=
dep_stream
->
dep_prev
)
{
nghttp2_pq_remove
(
&
dep_stream
->
obq
,
&
stream
->
pq_entry
);
stream
->
cycle
=
stream_next_cycle
(
stream
,
dep_stream
->
descendant_last_cycle
);
stream
->
seq
=
dep_stream
->
descendant_next_seq
++
;
...
...
@@ -225,8 +230,8 @@ void nghttp2_stream_reschedule(nghttp2_stream *stream) {
void
nghttp2_stream_change_weight
(
nghttp2_stream
*
stream
,
int32_t
weight
)
{
nghttp2_stream
*
dep_stream
;
uint64_t
last_cycle
;
uint64_t
cycle
;
int32_t
old_weight
;
size_t
wlen_penalty
;
if
(
stream
->
weight
==
weight
)
{
return
;
...
...
@@ -247,20 +252,28 @@ void nghttp2_stream_change_weight(nghttp2_stream *stream, int32_t weight) {
return
;
}
last_cycle
=
stream
->
cycle
-
stream
->
last_writelen
*
NGHTTP2_MAX_WEIGHT
/
(
uint32_t
)
old_weight
;
nghttp2_pq_remove
(
&
dep_stream
->
obq
,
&
stream
->
pq_entry
);
cycle
=
stream_next_cycle
(
stream
,
last_cycle
)
;
wlen_penalty
=
stream
->
last_writelen
*
NGHTTP2_MAX_WEIGHT
;
if
(
cycle
<
dep_stream
->
descendant_last_cycle
)
{
cycle
=
dep_stream
->
descendant_last_cycle
;
}
/* Compute old stream->pending_penalty we used to calculate
stream->cycle */
stream
->
pending_penalty
=
(
stream
->
pending_penalty
+
(
uint32_t
)
old_weight
-
(
wlen_penalty
%
(
uint32_t
)
old_weight
))
%
(
uint32_t
)
old_weight
;
nghttp2_pq_remove
(
&
dep_stream
->
obq
,
&
stream
->
pq_entry
);
last_cycle
=
stream
->
cycle
-
(
wlen_penalty
+
stream
->
pending_penalty
)
/
(
uint32_t
)
old_weight
;
stream
->
cycle
=
cycle
;
stream
->
seq
=
dep_stream
->
descendant_next_seq
++
;
/* Now we have old stream->pending_penalty and new stream->weight in
place */
stream_next_cycle
(
stream
,
last_cycle
);
if
(
stream
->
cycle
<
dep_stream
->
descendant_last_cycle
)
{
stream
->
cycle
=
dep_stream
->
descendant_last_cycle
;
}
/* Continue to use same stream->seq */
nghttp2_pq_push
(
&
dep_stream
->
obq
,
&
stream
->
pq_entry
);
...
...
lib/nghttp2_stream.h
View file @
abcdbf00
...
...
@@ -197,6 +197,8 @@ struct nghttp2_stream {
int32_t
local_window_size
;
/* weight of this stream */
int32_t
weight
;
/* This is unpaid penalty (offset) when calculating cycle. */
uint32_t
pending_penalty
;
/* sum of weight of direct descendants */
int32_t
sum_dep_weight
;
nghttp2_stream_state
state
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment