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

ringbuf: reduce allocations and syscalls #667

Merged
merged 2 commits into from
May 11, 2022
Merged

Conversation

lmb
Copy link
Collaborator

@lmb lmb commented May 10, 2022

ringbuf: reduce allocations on the discard and busy paths

There is no need to wrap internal sentinel errors, since they are
never returned to the user. Not wrapping saves us some allocations.

ringbuf: reduce the number of epoll_wait calls

We don't have to call back into epoll_wait until we've read the
full contents of the ring buffer. This reduces the number of syscalls
made during busy periods.

@lmb lmb requested a review from mythi May 10, 2022 09:26
if err == errBusy || err == errDiscard {
continue
}
if err == errEOR {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a left over from previous experiments? readRecord() does not return errEOR afaict.

Other than that, the changes work fine here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching that! Modified one of the tests to exercise this behavior.

There is no need to wrap internal sentinel errors, since they are
never returned to the user. Not wrapping saves us some allocations.
We don't have to call back into epoll_wait until we've read the
full contents of the ring buffer. This reduces the number of syscalls
made during busy periods.
@lmb lmb merged commit 86d3074 into cilium:master May 11, 2022
@mythi
Copy link
Contributor

mythi commented May 11, 2022

@lmb thanks! I was just about to submit my github approval. It looks nice to me. AFAICS with this users can also start controlling samples submission better with linux.BPF_RB_NO_WAKEUP and linux.BPF_RB_FORCE_WAKEUP.

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.

3 participants