Skip to content

benchmark_udp: improve rtt record buffering#21712

Merged
crasbe merged 1 commit intoRIOT-OS:masterfrom
elenaf9:benchmark_udp/fix-rtt-record-buffer
Sep 12, 2025
Merged

benchmark_udp: improve rtt record buffering#21712
crasbe merged 1 commit intoRIOT-OS:masterfrom
elenaf9:benchmark_udp/fix-rtt-record-buffer

Conversation

@elenaf9
Copy link
Contributor

@elenaf9 elenaf9 commented Sep 11, 2025

Contribution description

Small improvement when accessing the buffer that stores the records for pending pings.

There is no need to iterate through the buffer to find the oldest entry. The ping sequence number is linear and for each ping we add a record entry:

while (running) {
_put_rtt(ping->seq_no);
if (sock_udp_send(&sock, ping, sizeof(*ping) + payload_size, &remote) < 0) {
puts("Error sending message");
continue;
} else {
unsigned state = irq_disable();
ping->seq_no++;
irq_restore(state);
}

So modulo calculation can be used to get the index of the oldest/ next entry.

Testing procedure

Can be tested by running dist/tools/benchmark_udp (server) on the host and sys/test_utils/benchmark_udp (client) on a connected node.

Issues/PRs references

The ping sequence number is linear, so modulo calculation can be use to
get the index of the oldest/ next entry in the record buffer.
@github-actions github-actions bot added the Area: sys Area: System label Sep 11, 2025
@crasbe crasbe added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Sep 11, 2025
@riot-ci
Copy link

riot-ci commented Sep 11, 2025

Murdock results

✔️ PASSED

1ce1834 benchmark_udp: improve rtt record buffering

Success Failures Total Runtime
10515 0 10516 09m:51s

Artifacts

@benpicco
Copy link
Contributor

The ping sequence number is linear

I'm not super familiar with the code anymore, but what if the receiver doesn't receive a ping message, wouldn't that cause a collision in the array when the next one arrives?

@elenaf9
Copy link
Contributor Author

elenaf9 commented Sep 11, 2025

The ping sequence number is linear

I'm not super familiar with the code anymore, but what if the receiver doesn't receive a ping message, wouldn't that cause a collision in the array when the next one arrives?

The code is on the client side, i.e. the side that sends the pings and does the linear increase of the sequence number. So I don't think it matters whether the receiver actually receives the ping. Or do you mean sth else?
The only thing that can happen is that we receive an old pong with a sequence number for which we've already re-used the index, but we still have a check to catch that case.

@crasbe crasbe added this pull request to the merge queue Sep 12, 2025
Merged via the queue into RIOT-OS:master with commit ec09828 Sep 12, 2025
28 checks passed
@elenaf9 elenaf9 deleted the benchmark_udp/fix-rtt-record-buffer branch September 13, 2025 06:23
@benpicco benpicco added this to the Release 2025.10 milestone Dec 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: sys Area: System CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants