Skip to content

Commit

Permalink
fix(iroh-net): Magic sock recv_data_ipv4 and recv_data_ipv6 metri…
Browse files Browse the repository at this point in the history
…cs numbers (#2667)

## Description

<!-- A summary of what this pull request achieves and a rough list of
changes. -->
Previously, when I edited the iroh-net benchmark to print metrics, it'd
show (on a 1GB transfer):
```rs
// ...
    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:
```rs
// ...
    send_ipv4: 1104885110,
// ...
    recv_data_ipv4: 1104882621,
```

## Breaking Changes

None.
<!-- Optional, if there are any breaking changes document them,
including how to migrate older code. -->

## Notes & open questions

<!-- Any notes, remarks or open questions you have to make about the PR.
-->

## 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.
  • Loading branch information
matheus23 authored Aug 26, 2024
1 parent 5c09013 commit cb1650a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions iroh-net/src/magicsock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -725,9 +725,9 @@ impl MagicSock {
} else {
trace!(src = %meta.addr, len = %meta.stride, "UDP recv: quic packet");
if from_ipv4 {
inc_by!(MagicsockMetrics, recv_data_ipv4, buf.len() as _);
inc_by!(MagicsockMetrics, recv_data_ipv4, packet.len() as _);
} else {
inc_by!(MagicsockMetrics, recv_data_ipv6, buf.len() as _);
inc_by!(MagicsockMetrics, recv_data_ipv6, packet.len() as _);
}
true
};
Expand Down

0 comments on commit cb1650a

Please sign in to comment.