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 sample PPS report with longer poll intervals #475

Merged
merged 5 commits into from
Feb 11, 2025
Merged

Conversation

tohojo
Copy link
Member

@tohojo tohojo commented Feb 11, 2025

The PPS values in xdp_sample output were calculated incorrectly if the reporting
interval is longer than one second. Fix this by reworking the accounting to
calculate packet and PPS values separately and printing the right values as
appropriate.

The xdp_sample library functions were counting the total number of
packets by adding the pps number regardless of the sample interval. If
the interval is larger than one second, this leads to a miscount. Add a
collection of functions that count packets instead of pps and use those
for totals. Using an extra set of (trivial) helpers this way makes the
call sites nicely symmetrical between pps and packet calculations.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
The sample_round() function does the same as the math lib round()
function, so just use the library function instead.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
The interval is implied to be unsigned, but the variable is a regular
int; change it to unsigned int to better reflect the semantics.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Instead of counting the number of rounds in the polling loop, actually
calculate the total runtime in seconds and compute the average PPS from
that. Also print the duration as part of the end-of-run statistics.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
The Summary line output was printing the total values instead of the PPS
values, which led to wrong values being printed now that we account the
total values correctly. Fix the output to print the PPS values instead
of the totals.

Add a new err_pps variable to stats_output.totals to record accumulated
errors from the various count sources.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
@marcomole00
Copy link

I just did a quick test and the numbers are correct. Thanks @tohojo

@tohojo
Copy link
Member Author

tohojo commented Feb 11, 2025

Great, thanks for testing! :)

@tohojo tohojo merged commit 7b3bbe2 into main Feb 11, 2025
29 checks passed
@tohojo tohojo deleted the sample-count-fixes branch February 11, 2025 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

xdp-bench: "Packets received " field shows half the number of actual received packets
2 participants