-
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
feat: Implement Tox network profiler #1885
base: master
Are you sure you want to change the base?
Conversation
b93009f
to
75fd324
Compare
84ab794
to
687d5b5
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1885 +/- ##
==========================================
- Coverage 73.08% 72.99% -0.09%
==========================================
Files 149 150 +1
Lines 30531 30714 +183
==========================================
+ Hits 22313 22420 +107
- Misses 8218 8294 +76
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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 10 of 19 files at r1, 8 of 9 files at r2, all commit messages.
Reviewable status: complete! 1 of 1 approvals obtained (waiting on @JFreegman)
toxcore/tox_private.h, line 60 at r1 (raw file):
Previously, JFreegman wrote…
The reason I named it ZERO is because it has a different purpose depending on the packet type (see the above comment). Any suggestions?
Ok, that's fine then.
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 1 of 19 files at r1.
Reviewable status: complete! 1 of 1 approvals obtained (waiting on @JFreegman)
5c80003
to
5d3e91a
Compare
7852d0b
to
a53b5b7
Compare
39a7571
to
f1bc5a4
Compare
5700751
to
53d50e4
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.
For testing, we should be able to inject a custom struct Network
and compare total packet numbers there.
TOX_NETPROF_DIRECTION_RECV); | ||
} | ||
|
||
const unsigned long long total_packets = total_sent_count + total_recv_count; |
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.
generally prefer size named types like uint64_t
over unsigned long long
.
@@ -18,6 +18,7 @@ | |||
#include "DHT.h" | |||
#include "Messenger.h" | |||
#include "TCP_client.h" | |||
#include "TCP_server.h" |
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.
is this right?
@@ -20,6 +20,7 @@ | |||
#include "logger.h" | |||
#include "mem.h" | |||
#include "mono_time.h" | |||
#include "net_profile.h" |
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.
Some places, like here, don't need to know the full type and a forward declaration instead would suffice.
@@ -15,6 +15,7 @@ | |||
#include "logger.h" | |||
#include "mem.h" | |||
#include "mono_time.h" | |||
#include "net_profile.h" |
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.
here too.
@@ -10,6 +10,7 @@ | |||
#include "crypto_core.h" | |||
#include "logger.h" | |||
#include "mem.h" | |||
#include "net_profile.h" |
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.
and here. (we only store a pointer)
@@ -15,6 +15,7 @@ | |||
#include "logger.h" | |||
#include "mem.h" | |||
#include "mono_time.h" | |||
#include "net_profile.h" |
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.
or here.
@@ -20,6 +20,7 @@ | |||
#include "logger.h" | |||
#include "mem.h" | |||
#include "mono_time.h" | |||
#include "net_profile.h" |
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.
here too ... i feel like we should forward declare it in some public places.
@@ -999,6 +1008,11 @@ int send_packet(const Networking_Core *net, const IP_Port *ip_port, Packet packe | |||
loglogdata(net->log, "O=>", packet.data, packet.length, ip_port, res); | |||
|
|||
assert(res <= INT_MAX); | |||
|
|||
if (res == packet.length) { |
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.
i saw a data != nullptr
earlier, should it be put everywhere, like here too?
* Bootstrap info packet. | ||
*/ | ||
TOX_NETPROF_PACKET_ID_BOOTSTRAP_INFO = 0xf0, | ||
} Tox_Netprof_Packet_Id; |
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.
all public facing enums in toxcore now have a *_to_string()
function. Since there are alot of values here, it would be very valuable.
Maybe it can also take in the type (tcp/udp), to print a sensible string? or maybe I am just dreaming here...
* @param direction The packet direction. | ||
*/ | ||
uint64_t tox_netprof_get_packet_total_count(const Tox *tox, Tox_Netprof_Packet_Type type, | ||
Tox_Netprof_Direction direction); |
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.
missing new line here and the 2 decls below.
I get a lot of
supposed to be |
The beating heath of a toxcore: tomato_netprof_tableheat2.mp4 |
This change is