-
Notifications
You must be signed in to change notification settings - Fork 44
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
blockstore: fast path for AllKeysChan using the index #372
Conversation
ed5a822
to
e8fe22c
Compare
e8fe22c
to
8dee4f6
Compare
@rvagg I did what you suggested, the performance boost is even more significant: Before:
After
19.1X faster, allocate 735X less memory. |
Removing the
|
Answering my own question, that doesn't fix that test. Yet the previous code with the multihash was passing that test ‽ I'll need someone more versed in that code to figure out if that test makes sense, and if so what should be done about it. |
close ipld#242 Crude benchmark: ``` func BenchmarkAllKeysChan(b *testing.B) { path := filepath.Join(b.TempDir(), "bench-large-v2.car") generateRandomCarV2File(b, path, 10<<20) // 10 MiB defer os.Remove(path) bs, err := blockstore.OpenReadWrite(path, nil) if err != nil { b.Fatal(err) } b.ReportAllocs() b.ResetTimer() for i := 0; i < b.N; i++ { c, err := bs.AllKeysChan(context.Background()) if err != nil { b.Fatal(err) } for range c { } } } func BenchmarkAllKeysChanUseWholeCIDs(b *testing.B) { path := filepath.Join(b.TempDir(), "bench-large-v2.car") generateRandomCarV2File(b, path, 10<<20) // 10 MiB defer os.Remove(path) bs, err := blockstore.OpenReadWrite(path, nil, carv2.UseWholeCIDs(true)) if err != nil { b.Fatal(err) } b.ReportAllocs() b.ResetTimer() for i := 0; i < b.N; i++ { c, err := bs.AllKeysChan(context.Background()) if err != nil { b.Fatal(err) } for range c { } } } ``` Before: > BenchmarkAllKeysChan-12 885 1256865 ns/op 88911 B/op 1617 allocs/op > BenchmarkAllKeysChanUseWholeCIDs-12 1010 1253543 ns/op 57861 B/op 976 allocs/op After > BenchmarkAllKeysChan-12 8971 135906 ns/op 30864 B/op 642 allocs/op > BenchmarkAllKeysChanUseWholeCIDs-12 13904 86140 ns/op 144 B/op 2 allocs/op BenchmarkAllKeysChan --- 9.25X faster, allocate 2.9X less memory BenchmarkAllKeysChanUseWholeCID --- 14.5X faster, allocate 401X less memory.
8dee4f6
to
3ae33c5
Compare
@rvagg I applied your changes. Final result:
|
Note: I'm not entirely sure I didn't break some assumption.
close #242
Crude benchmark:
Before:
After
10.3X faster, allocate 2.5X less memory.