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

perf, ringbuf: add ReadBuffer mehods #663

Merged
merged 3 commits into from May 10, 2022
Merged

Conversation

lmb
Copy link
Collaborator

@lmb lmb commented May 6, 2022

perf: add Reader.ReadBuffer

Allow reading from a Reader without allocations, once a steady state
has been reached.

    name      old time/op    new time/op    delta
    Reader-4    8.98µs ± 2%    8.91µs ± 3%     ~     (p=0.686 n=4+4)

    name      old alloc/op   new alloc/op   delta
    Reader-4      424B ± 0%      288B ± 0%  -32.08%  (p=0.029 n=4+4)

    name      old allocs/op  new allocs/op  delta
    Reader-4      8.00 ± 0%      1.00 ± 0%  -87.50%  (p=0.029 n=4+4)

ringbuf: fix BenchmarkReader

Move calls to ResetTimer and ReportAllocs and avoid allocating a
temporary buffer.

ringbuf: add ReadBuffer method

Add a ReadBuffer method to ringbuf.Reader, analogous to perf.Reader.

    name                                   old time/op    new time/op    delta
    Reader/normal_epoll_with_timeout_-1-4    8.58µs ± 3%    9.07µs ± 4%     ~     (p=0.057 n=4+4)

    name                                   old alloc/op   new alloc/op   delta
    Reader/normal_epoll_with_timeout_-1-4      384B ± 0%      288B ± 0%  -25.00%  (p=0.029 n=4+4)

    name                                   old allocs/op  new allocs/op  delta
    Reader/normal_epoll_with_timeout_-1-4      4.00 ± 0%      1.00 ± 0%  -75.00%  (p=0.029 n=4+4)

@lmb
Copy link
Collaborator Author

lmb commented May 6, 2022

Joint work with @brycekahle.

@lmb
Copy link
Collaborator Author

lmb commented May 10, 2022

I've changed the signature to ReadRecord(*Record) error based on feedback from Timo. Maybe ReadInto(*Record) would be better?

lmb added 3 commits May 10, 2022 16:02
Allow reading from a Reader without allocations, once a steady state
has been reached.

    name          time/op
    Reader-4      8.84µs ± 3%
    ReadInto-4    8.83µs ± 4%

    name          alloc/op
    Reader-4        384B ± 0%
    ReadInto-4      288B ± 0%

    name          allocs/op
    Reader-4        2.00 ± 0%
    ReadInto-4      1.00 ± 0%
Move calls to ResetTimer and ReportAllocs and avoid allocating a
temporary buffer.
Add a ReadInto method to ringbuf.Reader, analogous to perf.Reader.

    name                                   time/op
    Reader/normal_epoll_with_timeout_-1-4  8.87µs ± 1%
    ReadInto-4                             8.90µs ± 3%

    name                                   alloc/op
    Reader/normal_epoll_with_timeout_-1-4    368B ± 0%
    ReadInto-4                               288B ± 0%

    name                                   allocs/op
    Reader/normal_epoll_with_timeout_-1-4    2.00 ± 0%
    ReadInto-4                               1.00 ± 0%
@lmb lmb merged commit 265306f into cilium:master May 10, 2022
@lmb lmb deleted the reader-read-buffer branch May 10, 2022 16:08
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.

None yet

2 participants