sys/usb/cdc_acm, sys/tsrb: speedup usb_cdc ringbuffer handling #21788
sys/usb/cdc_acm, sys/tsrb: speedup usb_cdc ringbuffer handling #21788benpicco merged 4 commits intoRIOT-OS:masterfrom
Conversation
sys/tsrb/tsrb.c
Outdated
| size_t tmp = n; | ||
| int cnt = 0; | ||
| unsigned irq_state = irq_disable(); | ||
| while (tmp && !tsrb_empty(rb)) { | ||
| while (n-- && !tsrb_empty(rb)) { | ||
| *dst++ = _pop(rb); | ||
| tmp--; | ||
| cnt++; | ||
| } | ||
| irq_restore(irq_state); | ||
| return (n - tmp); | ||
| return (cnt); |
There was a problem hiding this comment.
why are you renaming and retyping variables and restructure their use?
-- this question goes for other function you do the same thing to as well
There was a problem hiding this comment.
rename to ease readbility
retyping to fit return type
slightly change their use for readability for humans and compilers godbolt
There was a problem hiding this comment.
Nit: You could go the extra mile and rename n to length/size/remaining_bytes and cnt to copied_bytes 😏
a9ea365 to
6ddd967
Compare
|
Do you have any benchmark numbers or so to show that it actually improves the speed? Also I'm not to keen on the |
i would not like to have them accessible through the same header ( could go for benchmarking the irq enable and disable -which this is mostly about- is very difficult we got the when i did |
| /* | ||
| * SPDX-FileCopyrightText: 2015 Kaspar Schleiser <[email protected]> | ||
| * SPDX-FileCopyrightText: 2025 Karl Fessel <[email protected]> ML!PA Consulting GmbH | ||
| * SPDX-License-Identifier: LGPL-2.1-only |
There was a problem hiding this comment.
i am a bit unsure about that only -- just a bit if its ok like this its fine for me
|
What is the motivation to have this in addition to https://doc.riot-os.org/cib_8h.html ? Wouldn't cib already solve all the non-thread-safe ringbuffer needs? |
cib seems to have a very strange usage pattern, does not do the buffer handling but just the index,
turb is created to provide access to tsrb without extra thread safety measures ( cause they are taken/ensured by the caller )
|
|
I suppose you could now implement |
done that sys/tsrb: use turb.h for c-file implemetation |
|
Thanks |
Contribution description
speedup usb_cdc_acm tsrb writing and reading by avoid jumps to tsrb and superfluous irq_disable calls.
Testing procedure
read
usb cdc acm still working
Issues/PRs references
#12402 fixed tsrb hadling for usb ( loss of chars for acm) by adding irq disable around tsrb access
#15218 added isr_guards thoughout tsrb