-
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
perf: Slightly reduce bandwidth usage when there are few nodes. #2442
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #2442 +/- ##
=======================================
Coverage 71.55% 71.56%
=======================================
Files 75 75
Lines 25200 25291 +91
=======================================
+ Hits 18033 18100 +67
- Misses 7167 7191 +24 ☔ View full report in Codecov by Sentry. |
f62c5e0
to
33c285d
Compare
fc516a3
to
5a06952
Compare
5a06952
to
e5dfb64
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 18 of 25 files at r1, 1 of 4 files at r2, 3 of 7 files at r3, 5 of 5 files at r4, all commit messages.
Reviewable status: 0 of 1 approvals obtained (waiting on @iphydf)
toxcore/mono_time.c
line 169 at r4 (raw file):
mono_time->base_time = 1; #else mono_time->base_time = max_u64(1, (uint64_t)time(nullptr)) * 1000ULL - current_time_monotonic(mono_time);
What does this do?
toxcore/onion_client.c
line 2006 at r4 (raw file):
const Node_format *target = &path_nodes[num]; if (!node_list_contains(targets, targets_count, path_nodes[num].public_key)) {
This saves some bandwidth but at the expense of using more CPU, doing ~15 additional calls to pk_equal
each tox_iterate()
. Is the bandwidth saved worth the trade off, considering that pk_equal
uses an expensive secure memory comparison function?
toxcore/pk_set.c
line 66 at r4 (raw file):
if (pks->size == UINT8_MAX) { return false;
Why not use integer error codes to distinguish between types of failure?
toxcore/pk_set.c
line 94 at r4 (raw file):
} bool pk_set_contains(Pk_Set *pks, const uint8_t *pk)
If this function were moved somewhere else this entire module could be generalized for any data type with just some name changes. Is there a reason we don't want that?
1d6f97a
to
0705090
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 1 approvals obtained (waiting on @JFreegman)
toxcore/mono_time.c
line 169 at r4 (raw file):
Previously, JFreegman wrote…
What does this do?
Added comment.
toxcore/onion_client.c
line 2006 at r4 (raw file):
Previously, JFreegman wrote…
This saves some bandwidth but at the expense of using more CPU, doing ~15 additional calls to
pk_equal
eachtox_iterate()
. Is the bandwidth saved worth the trade off, considering thatpk_equal
uses an expensive secure memory comparison function?
Changed it to memeq
. There's no need for this to be secure comparison.
toxcore/pk_set.c
line 66 at r4 (raw file):
Previously, JFreegman wrote…
Why not use integer error codes to distinguish between types of failure?
Deleted.
toxcore/pk_set.c
line 94 at r4 (raw file):
Previously, JFreegman wrote…
If this function were moved somewhere else this entire module could be generalized for any data type with just some name changes. Is there a reason we don't want that?
Deleted.
24a0dff
to
fd7b3d4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 11 of 11 files at r5, 6 of 6 files at r6, all commit messages.
Reviewable status: complete! 1 of 1 approvals obtained
fd7b3d4
to
7dba867
Compare
This mainly saves spam in test logs, but may save some packets here and there, if nodes are randomly selected twice for GET_NODES and onion routing packets.
7dba867
to
028b017
Compare
This mainly saves spam in test logs, but may save some packets here and there, if nodes are randomly selected twice for onion routing packets.
More importantly (and somewhat concerningly), toxcore on esp32 never connects to the onion without this.
This change is