-
Notifications
You must be signed in to change notification settings - Fork 187
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
transceivers
: convert to counted_ringbuf
s
#1780
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a couple suggestions. At some point we may also want to add #[count(children)]
to some of the errors, so that we can generate a separate counter for each error variant, but it's up to you whether we ought to do that now, and which errors are worth counting individually.
f719f20
to
757b3cf
Compare
@hawkw I did add it in a few places, but some of the other places I'd like to add it are blocked by |
757b3cf
to
f8c344b
Compare
Yeah, I think that if you want to count events per impl Count for LogicalPort {
type Counters = [AtomicU32; NUM_PORTS],;
#[allow(clippy::declare_interior_mutable_const)]
const NEW_COUNTERS: Self::Counters = {
const COUNTER_INIT: AtomicU32 = AtomicU32::new(0);
[COUNTER_INIT; NUM_PORTS]
};
fn count(&self, counters: &Self::Counters) {
let Some(ctr) = counters.get(self.0 as usize) else {
// `LogicalPort`s should never index the counters array out of
// bounds, but if that does ever happen, let's just bail instead of
// panicking...
return;
}
armv6m_atomic_hack::AtomicU32Ext::fetch_add(ctr, 1, Ordering::Relaxed);
}
} Although, OTTOMH, I'm not sure how well the |
@hawkw should we do the |
My preference would be to go ahead and merge this as-is, and add something like that later --- I can think of a few other places where it would be nice to be able to use arrays for generating counters from a numeric index (e.g. |
That works for me. I've opened oxidecomputer/humility#487 so we remember where we talked about this. If you give this a +1 I'll get it merged! |
I'm going to use a
counted_ringbuf
in thetransceivers
task because there is a lot of activity that happens, specifically in the UDP handler. I also bumped up the size from 16 -> 32 of that one because there's nearly constant activity and each UDP message involves at least three entries.Fixes #1778