-
Notifications
You must be signed in to change notification settings - Fork 799
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
blob: pass through reader/writer to
WriteTo
/ReadFrom
if available
The blob `Reader` and `Writer` implement `WriterTo` and `ReaderFrom`, respectively, which is meant to avoid intermediary allocations and copies (passing readers and readers through all the way down). Unfortunately, the current implementation falls short and implements those interfaces by making a local copy ala io.Copy. Instead, reproduce the strategy in newer versions of `io.Copy`: reflect on the reader/writer provided by the user, and if they implement these interface, too, then call into that. Local benchmarks show significant performance improvements: ``` │ /tmp/old │ /tmp/new │ │ sec/op │ sec/op vs base │ Memblob/BenchmarkRead-10 3.449µ ± 15% 1.919µ ± 2% -44.37% (p=0.000 n=10) ```
- Loading branch information
Showing
3 changed files
with
45 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters