Skip to content
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(iroh-net): Magic sock recv_data_ipv4 and recv_data_ipv6 metrics numbers #2667

Merged
merged 1 commit into from
Aug 26, 2024

Conversation

matheus23
Copy link
Contributor

@matheus23 matheus23 commented Aug 26, 2024

Description

Previously, when I edited the iroh-net benchmark to print metrics, it'd show (on a 1GB transfer):

// ...
    send_ipv4: 1104880201,
// ...
    recv_data_ipv4: 88912756736,

Clearly, the 89GB received data is wrong. The reason is that we record the buffer size when we record metrics instead of recording the received packet size.
The buffer tends to be around ~90kB for me, while the received packets are around 1-2kB. This explains the 90x factor.

With this fix, I now get:

// ...
    send_ipv4: 1104885110,
// ...
    recv_data_ipv4: 1104882621,

Breaking Changes

None.

Notes & open questions

Change checklist

  • Self-review.
  • [ ] Documentation updates following the style guide, if relevant.
  • [ ] Tests if relevant.
  • All breaking changes documented.

@matheus23 matheus23 self-assigned this Aug 26, 2024
Copy link

Documentation for this PR has been generated and is available at: https://n0-computer.github.io/iroh/pr/2667/docs/iroh/

Last updated: 2024-08-26T08:29:34Z

@matheus23 matheus23 added this pull request to the merge queue Aug 26, 2024
Merged via the queue into main with commit cb1650a Aug 26, 2024
29 checks passed
@matheus23 matheus23 deleted the matheus23/fix-msock-metrics branch August 26, 2024 14:52
github-merge-queue bot pushed a commit that referenced this pull request Aug 26, 2024
…#2668)

## Description

<!-- A summary of what this pull request achieves and a rough list of
changes. -->
Used these changes to test #2667.

I think this is a decent tool. Output looks like this:

<details>
<summary><code>$ cd iroh-net/bench && cargo run --release -- iroh
--metrics --with-relay</code></summary>

```
   Compiling iroh-net-bench v0.23.0 (/home/philipp/program/work/iroh/iroh-net/bench)
    Finished `release` profile [optimized + debuginfo] target(s) in 28.47s
     Running `/home/philipp/program/work/iroh/target/release/bulk iroh --metrics --with-relay`

Client 0 stats:
Connect time: 1008.829553ms
Overall download stats:

Transferred 1073741824 bytes on 1 streams in 1.70s (603.46 MiB/s)

Time to first byte (TTFB): 105.312ms

Total chunks: 36445

Average chunk time: 46.544ms

Average chunk size: 28.77KiB

Stream download metrics:

      │  Throughput   │ Duration 
──────┼───────────────┼──────────
 AVG  │  603.75 MiB/s │     1.70s
 P0   │  603.50 MiB/s │     1.70s
 P10  │  604.00 MiB/s │     1.70s
 P50  │  604.00 MiB/s │     1.70s
 P90  │  604.00 MiB/s │     1.70s
 P100 │  604.00 MiB/s │     1.70s

Metrics:
MagicsockMetrics: {
    "actor_link_change": 0,
    "actor_tick_direct_addr_heartbeat": 0,
    "actor_tick_direct_addr_update_receiver": 6,
    "actor_tick_main": 22,
    "actor_tick_msg": 13,
    "actor_tick_other": 0,
    "actor_tick_portmap_changed": 0,
    "actor_tick_re_stun": 2,
    "num_direct_conns_added": 3,
    "num_direct_conns_removed": 1,
    "num_relay_conns_added": 5,
    "num_relay_conns_removed": 3,
    "re_stun_calls": 3,
    "recv_data_ipv4": 88975499264,
    "recv_data_ipv6": 0,
    "recv_data_relay": 49200,
    "recv_datagrams": 944499,
    "recv_disco_bad_key": 0,
    "recv_disco_bad_parse": 0,
    "recv_disco_call_me_maybe": 2,
    "recv_disco_call_me_maybe_bad_disco": 0,
    "recv_disco_ping": 14,
    "recv_disco_pong": 14,
    "recv_disco_relay": 6,
    "recv_disco_udp": 24,
    "relay_home_change": 2,
    "send_data": 1104903421,
    "send_data_network_down": 0,
    "send_disco_relay": 6,
    "send_disco_udp": 24,
    "send_ipv4": 1104905771,
    "send_ipv6": 470,
    "send_relay": 49988,
    "send_relay_error": 0,
    "sent_disco_call_me_maybe": 2,
    "sent_disco_ping": 14,
    "sent_disco_pong": 14,
    "sent_disco_relay": 6,
    "sent_disco_udp": 24,
    "update_direct_addrs": 3,
}
NetcheckMetrics: {
    "reports": 3,
    "reports_full": 0,
    "stun_packets_dropped": 0,
    "stun_packets_recv_ipv4": 0,
    "stun_packets_recv_ipv6": 0,
    "stun_packets_sent_ipv4": 10,
    "stun_packets_sent_ipv6": 10,
}
PortmapMetrics: {
    "external_address_updated": 0,
    "local_port_updates": 3,
    "mapping_attempts": 5,
    "mapping_failures": 3,
    "pcp_available": 0,
    "pcp_probes": 3,
    "probes_started": 3,
    "upnp_available": 0,
    "upnp_gateway_updated": 0,
    "upnp_probes": 6,
    "upnp_probes_failed": 3,
}
RelayMetrics: {
    "accepts": 2,
    "bytes_recv": 50082,
    "bytes_sent": 50082,
    "derp_accepts": 2,
    "disco_packets_dropped": 0,
    "disco_packets_recv": 0,
    "disco_packets_sent": 0,
    "disconnects": 0,
    "got_ping": 0,
    "other_packets_dropped": 0,
    "other_packets_recv": 2,
    "other_packets_sent": 0,
    "send_packets_dropped": 0,
    "send_packets_recv": 9,
    "send_packets_sent": 9,
    "sent_pong": 0,
    "unique_client_keys": 2,
    "unknown_frames": 0,
    "websocket_accepts": 0,
}
```

</details>

## Breaking Changes

<!-- Optional, if there are any breaking changes document them,
including how to migrate older code. -->
None. The semver check also checks for the "public API" of
`iroh-net/bench`, and there's been another `Opt` addition.

## Notes & open questions

<!-- Any notes, remarks or open questions you have to make about the PR.
-->
This PR is based on #2664 at the moment, let's merge that first.

## Change checklist

- [x] Self-review.
- ~~[ ] Documentation updates following the [style
guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text),
if relevant.~~
- ~~[ ] Tests if relevant.~~
- [x] All breaking changes documented.
matheus23 added a commit that referenced this pull request Nov 14, 2024
…#2668)

## Description

<!-- A summary of what this pull request achieves and a rough list of
changes. -->
Used these changes to test #2667.

I think this is a decent tool. Output looks like this:

<details>
<summary><code>$ cd iroh-net/bench && cargo run --release -- iroh
--metrics --with-relay</code></summary>

```
   Compiling iroh-net-bench v0.23.0 (/home/philipp/program/work/iroh/iroh-net/bench)
    Finished `release` profile [optimized + debuginfo] target(s) in 28.47s
     Running `/home/philipp/program/work/iroh/target/release/bulk iroh --metrics --with-relay`

Client 0 stats:
Connect time: 1008.829553ms
Overall download stats:

Transferred 1073741824 bytes on 1 streams in 1.70s (603.46 MiB/s)

Time to first byte (TTFB): 105.312ms

Total chunks: 36445

Average chunk time: 46.544ms

Average chunk size: 28.77KiB

Stream download metrics:

      │  Throughput   │ Duration 
──────┼───────────────┼──────────
 AVG  │  603.75 MiB/s │     1.70s
 P0   │  603.50 MiB/s │     1.70s
 P10  │  604.00 MiB/s │     1.70s
 P50  │  604.00 MiB/s │     1.70s
 P90  │  604.00 MiB/s │     1.70s
 P100 │  604.00 MiB/s │     1.70s

Metrics:
MagicsockMetrics: {
    "actor_link_change": 0,
    "actor_tick_direct_addr_heartbeat": 0,
    "actor_tick_direct_addr_update_receiver": 6,
    "actor_tick_main": 22,
    "actor_tick_msg": 13,
    "actor_tick_other": 0,
    "actor_tick_portmap_changed": 0,
    "actor_tick_re_stun": 2,
    "num_direct_conns_added": 3,
    "num_direct_conns_removed": 1,
    "num_relay_conns_added": 5,
    "num_relay_conns_removed": 3,
    "re_stun_calls": 3,
    "recv_data_ipv4": 88975499264,
    "recv_data_ipv6": 0,
    "recv_data_relay": 49200,
    "recv_datagrams": 944499,
    "recv_disco_bad_key": 0,
    "recv_disco_bad_parse": 0,
    "recv_disco_call_me_maybe": 2,
    "recv_disco_call_me_maybe_bad_disco": 0,
    "recv_disco_ping": 14,
    "recv_disco_pong": 14,
    "recv_disco_relay": 6,
    "recv_disco_udp": 24,
    "relay_home_change": 2,
    "send_data": 1104903421,
    "send_data_network_down": 0,
    "send_disco_relay": 6,
    "send_disco_udp": 24,
    "send_ipv4": 1104905771,
    "send_ipv6": 470,
    "send_relay": 49988,
    "send_relay_error": 0,
    "sent_disco_call_me_maybe": 2,
    "sent_disco_ping": 14,
    "sent_disco_pong": 14,
    "sent_disco_relay": 6,
    "sent_disco_udp": 24,
    "update_direct_addrs": 3,
}
NetcheckMetrics: {
    "reports": 3,
    "reports_full": 0,
    "stun_packets_dropped": 0,
    "stun_packets_recv_ipv4": 0,
    "stun_packets_recv_ipv6": 0,
    "stun_packets_sent_ipv4": 10,
    "stun_packets_sent_ipv6": 10,
}
PortmapMetrics: {
    "external_address_updated": 0,
    "local_port_updates": 3,
    "mapping_attempts": 5,
    "mapping_failures": 3,
    "pcp_available": 0,
    "pcp_probes": 3,
    "probes_started": 3,
    "upnp_available": 0,
    "upnp_gateway_updated": 0,
    "upnp_probes": 6,
    "upnp_probes_failed": 3,
}
RelayMetrics: {
    "accepts": 2,
    "bytes_recv": 50082,
    "bytes_sent": 50082,
    "derp_accepts": 2,
    "disco_packets_dropped": 0,
    "disco_packets_recv": 0,
    "disco_packets_sent": 0,
    "disconnects": 0,
    "got_ping": 0,
    "other_packets_dropped": 0,
    "other_packets_recv": 2,
    "other_packets_sent": 0,
    "send_packets_dropped": 0,
    "send_packets_recv": 9,
    "send_packets_sent": 9,
    "sent_pong": 0,
    "unique_client_keys": 2,
    "unknown_frames": 0,
    "websocket_accepts": 0,
}
```

</details>

## Breaking Changes

<!-- Optional, if there are any breaking changes document them,
including how to migrate older code. -->
None. The semver check also checks for the "public API" of
`iroh-net/bench`, and there's been another `Opt` addition.

## Notes & open questions

<!-- Any notes, remarks or open questions you have to make about the PR.
-->
This PR is based on #2664 at the moment, let's merge that first.

## Change checklist

- [x] Self-review.
- ~~[ ] Documentation updates following the [style
guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text),
if relevant.~~
- ~~[ ] Tests if relevant.~~
- [x] All breaking changes documented.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants