forked from irungentoo/toxcore
-
Notifications
You must be signed in to change notification settings - Fork 284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix indices calculation for congestion control. #1268
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kurnevsky
force-pushed
the
congestion_fixes
branch
from
November 21, 2018 12:16
05a33c2
to
15dc105
Compare
Codecov Report
@@ Coverage Diff @@
## master #1268 +/- ##
========================================
+ Coverage 83.3% 83.3% +<.1%
========================================
Files 82 82
Lines 14827 14867 +40
========================================
+ Hits 12361 12398 +37
- Misses 2466 2469 +3
Continue to review full report at Codecov.
|
* Tuesday, 2018-11-20 at 09:22 -0800 - Evgeny Kurnevsky <[email protected]>:
Does somebody know what it means? It seams `send_array_ratio` variable
means the time that is required to send all packets from the send queue
with the current calculated speed. And if it's higher than 2 seconds
the `packet_send_rate` will be reduced. Why?
I agree with your analysis (this being the first time I've looked at
this code). So the idea seems to be that we have a target of keeping the
queue down to a size such that it would take 2 seconds to clear, and we
decrease packet_send_rate as needed to ensure this. Calling it a 'ratio'
is indeed maybe a bit misleading, because the units matter; I'd call it
something like TARGET_QUEUE_CLEARANCE_TIME.
In any case, I checked the changes in this PR, and I approve. It seems
when the code was first written CONGESTION_QUEUE_ARRAY_SIZE was a power
of 2 so the wrapping wasn't a problem. But now it is.
|
zugz
approved these changes
Nov 24, 2018
kurnevsky
force-pushed
the
congestion_fixes
branch
from
November 27, 2018 20:41
15dc105
to
3438309
Compare
hugbubby
force-pushed
the
congestion_fixes
branch
2 times, most recently
from
December 13, 2018 00:32
33b3a48
to
0e2155e
Compare
hugbubby
changed the title
Fix indices calculation for congestion control.
WIP: Fix indices calculation for congestion control.
Dec 13, 2018
hugbubby
changed the title
WIP: Fix indices calculation for congestion control.
Fix indices calculation for congestion control.
Dec 13, 2018
hugbubby
changed the title
Fix indices calculation for congestion control.
WIP: Fix indices calculation for congestion control.
Dec 13, 2018
hugbubby
changed the title
WIP: Fix indices calculation for congestion control.
Fix indices calculation for congestion control.
Dec 13, 2018
kurnevsky
force-pushed
the
congestion_fixes
branch
from
December 16, 2018 19:17
0e2155e
to
97370ba
Compare
Also added and used the new crypto_malloc and crypto_free. The latter also zeroes out the memory safely. The former only exists for symmetry (static analysis can detect asymmetric usages).
iphydf
force-pushed
the
congestion_fixes
branch
from
January 3, 2019 11:13
97370ba
to
e532057
Compare
This pull request was closed.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes:
It seems the second index for
sum
calculated in a wrong way:c-toxcore/toxcore/net_crypto.c
Line 2536 in d89f83f
pos
is a value between 0 and CONGESTION_QUEUE_ARRAY_SIZE. So the valuepos - (CONGESTION_QUEUE_ARRAY_SIZE - 1)
is likely to be overflowed. It's unsigned so it won't lead to out-of-bounds access but incorrect value will be taken instead.Move incrementing of
last_sendqueue_counter
- it seems pretty illogical that it's used before and after incrementing:c-toxcore/toxcore/net_crypto.c
Line 2530 in d89f83f
c-toxcore/toxcore/net_crypto.c
Line 2538 in d89f83f
Take remainder of the division so that
last_sendqueue_counter
won't be overflowed.Also I can't understand the meaning of this comparison:
c-toxcore/toxcore/net_crypto.c
Line 2586 in d89f83f
Does somebody know what it means? It seams
send_array_ratio
variable means the time that is required to send all packets from the send queue with the current calculated speed. And if it's higher than 2 seconds thepacket_send_rate
will be reduced. Why? There comments says:But how the send queue size and the link speed can be compared? They have different units of measurement. Or do I miss something?
This change is