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: reduce NewCarReader allocations #420

Merged
merged 1 commit into from
May 9, 2023

Conversation

bradfitz
Copy link
Contributor

@bradfitz bradfitz commented May 4, 2023

This accounted for almost 10% of the garbage on one of Bluesky's server daemons (go tool pprof --alloc_space), leading to high GC CPU.

benchstat:

                     │   before    │                after                │
                     │   sec/op    │   sec/op     vs base                │
NewCarReader_small-8   2.005µ ± 1%   1.451µ ± 5%  -27.61% (p=0.000 n=10)

                     │    before    │                after                 │
                     │     B/op     │     B/op      vs base                │
NewCarReader_small-8   5.268Ki ± 0%   1.135Ki ± 0%  -78.46% (p=0.000 n=10)

                     │   before   │               after               │
                     │ allocs/op  │ allocs/op   vs base               │
NewCarReader_small-8   29.00 ± 0%   27.00 ± 0%  -6.90% (p=0.000 n=10)

This accounted for almost 10% of the garbage on one of Bluesky's
server daemons (go tool pprof --alloc_space), leading to high GC CPU.

benchstat:

                         │   before    │                after                │
                         │   sec/op    │   sec/op     vs base                │
    NewCarReader_small-8   2.005µ ± 1%   1.451µ ± 5%  -27.61% (p=0.000 n=10)

                         │    before    │                after                 │
                         │     B/op     │     B/op      vs base                │
    NewCarReader_small-8   5.268Ki ± 0%   1.135Ki ± 0%  -78.46% (p=0.000 n=10)

                         │   before   │               after               │
                         │ allocs/op  │ allocs/op   vs base               │
    NewCarReader_small-8   29.00 ± 0%   27.00 ± 0%  -6.90% (p=0.000 n=10)
@bradfitz
Copy link
Contributor Author

bradfitz commented May 4, 2023

cc @rvagg @whyrusleeping @bnewbold

Copy link
Member

@willscott willscott left a comment

Choose a reason for hiding this comment

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

Bluesky is probably one of the first users with lots of small car shards where this matters.

@rvagg - your eyes are probably useful here to keep tabs of what's going on in the v1 read path.

@rvagg rvagg merged commit 92d28eb into ipld:master May 9, 2023
bradfitz added a commit to bradfitz/indigo that referenced this pull request May 10, 2023
Updates github.com/ipld/go-car to the latest commit to bring in
ipld/go-car#420 which should drop allocated
bytes (garbage that triggers the GC to spend CPU) by about 9%.
bnewbold pushed a commit to bluesky-social/indigo that referenced this pull request May 10, 2023
Updates github.com/ipld/go-car to the latest commit to bring in
ipld/go-car#420 which should drop allocated
bytes (garbage that triggers the GC to spend CPU) by about 9%.
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