feat(ringbuf): Add AvailableBytes()#1533
Conversation
|
Hi @dave-tucker, could you give an example of a practical use case? A test would be nice to have as well. Thanks! |
97e0587 to
63bc8f1
Compare
|
@ti-mo added some assertions to the tests to exercise this API. By periodically calling |
|
Does #1167 accomplish what you need? |
|
@brycekahle I can try it out and compare both. |
I tried it out.
You can see this on the graphs below - Top is The gap in the middle was when I restarted my process to only use The top graph is more useful for my purposes of evaluating what ☝️ does to the ring buffer. I find the bottom graph less useful for my purposes right now, but thinking it through that metric might be better suited to creating a histogram. TL;DR I think both are useful |
lmb
left a comment
There was a problem hiding this comment.
Thanks for checking, very informative, especially with the graphs! You're right that putting .Remaining in a gauge isn't going to be very helpful. Did you end up trying with a histogram?
What did you decide to change based on the metrics? Increase buffer size? Wake up less frequently?
The upside of AvailableData is that it's simple to export and graph. The downside is that we can't extend the concept to perf, since that wraps multiple buffers. So far we've always tried to keep the API of both packages very similar, but that is not a deal breaker.
Left some nits, overall I agree with Florian that this is fine to merge.
63bc8f1 to
4442937
Compare
I played around with it and it looked promising but I ended up bailing on it because I couldn't find a satisfactory size for the buckets.
All the above. I'm still working on it, but I plan to write up what I've learned soon and I'll share it on Slack when I'm done.
Addressed! Thanks! |
ti-mo
left a comment
There was a problem hiding this comment.
@dave-tucker Thanks for the context you've provided so far! Left one nit, it's common in our lib (and in Go in general) to name functions after the unit of data they return. 'Data' is redundant, since what else would a ring buffer contain? 🙂 'Bytes' would be more useful here. Thanks!
4442937 to
37f949d
Compare
|
Thanks for the review and suggestions @ti-mo. I've incorporated them and force-pushed an update. |
Adds AvailableBytes(), which is equivalent to ring__avail_data_size in libbpf. Signed-off-by: Dave Tucker <[email protected]> Signed-off-by: Timo Beckers <[email protected]>
37f949d to
0e809bb
Compare
|
Pushed a small fixup, will merge when CI is green. |

Adds AvailableBytes(), which is equivalent to ring__avail_data_size in libbpf.