-
Notifications
You must be signed in to change notification settings - Fork 7
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
Pool decode buffers when encoding messages using compression #854
Conversation
8bb9fd7
to
767eeae
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not seeing the "more performant" part except a slight perf bump on decode, but using the same library makes sense.
I'm surprised we saved an allocation on encode and nothing on decode (where we added the pool). What happens if we remove the pool? Does the datadog version just have an additional allocation internally?
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #854 +/- ##
==========================================
- Coverage 67.21% 67.14% -0.07%
==========================================
Files 83 83
Lines 9055 9064 +9
==========================================
Hits 6086 6086
- Misses 2430 2434 +4
- Partials 539 544 +5
|
Not really. filecoin-project/lotus#12015 kind of relevant, there's some pressure to not introduce more cgo lock-in if we can help it, particularly for downstream dependents of those components. I'd say unless the perf improvement here is really dramatic maybe let's just stuck with klauspost/compress. |
Consistent dependency to the same libraries for the same functionality IMO is a desirable. Maybe the answer here is to move Lotus off the DataDog dependency. I know that |
pooling makes no difference to the encoding part. The difference in allocation comes from the internals of the dependency libraries. Here are the numbers for
|
To unblock work I am going to separate pooling from dependency change in this PR until we figure out filecoin-project/lotus#12852. |
767eeae
to
f28d5b4
Compare
Pool the decode buffers and set strict max cap allocation for zstd decompressor. See Benchamark results below. Before: ``` BenchmarkCborEncoding BenchmarkCborEncoding-12 467352 2376 ns/op 14680 B/op 10 allocs/op BenchmarkCborDecoding BenchmarkCborDecoding-12 104410 11347 ns/op 14944 B/op 27 allocs/op BenchmarkZstdEncoding BenchmarkZstdEncoding-12 286735 3897 ns/op 46748 B/op 12 allocs/op BenchmarkZstdDecoding BenchmarkZstdDecoding-12 110794 10783 ns/op 28512 B/op 28 allocs/op ``` After: ``` BenchmarkCborEncoding BenchmarkCborEncoding-12 436754 2383 ns/op 14680 B/op 10 allocs/op BenchmarkCborDecoding BenchmarkCborDecoding-12 106809 11280 ns/op 14944 B/op 27 allocs/op BenchmarkZstdEncoding BenchmarkZstdEncoding-12 294043 3918 ns/op 46746 B/op 12 allocs/op BenchmarkZstdDecoding BenchmarkZstdDecoding-12 114854 10747 ns/op 18314 B/op 27 allocs/op ``` Fixes: #849
f28d5b4
to
6194fee
Compare
Pool the decode buffers and set strict max cap allocation for zstd decompressor.
See Benchamark results below.
Before:
After:
Fixes: #849