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

Fix ringbuffer ring size reporting #1492

Merged
merged 3 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ringbuf/reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func TestRingbufReader(t *testing.T) {
}
defer rd.Close()

if uint32(rd.BufferSize()) != 2*events.MaxEntries() {
if uint32(rd.BufferSize()) != events.MaxEntries() {
t.Errorf("expected %d BufferSize, got %d", events.MaxEntries(), rd.BufferSize())
}

Expand Down
4 changes: 3 additions & 1 deletion ringbuf/ring.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ func (rr *ringReader) isEmpty() bool {
return prod == cons
}

// The data pages in ring buffers are mapped twice in a single contiguous virtual region
// Therefore the true size is half the size of the mmaped region
florianl marked this conversation as resolved.
Show resolved Hide resolved
func (rr *ringReader) size() int {
return cap(rr.ring)
return cap(rr.ring) / 2
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you need to fix TestRingbufReader to accommodate this change.

}

// Read a record from an event ring.
Expand Down