-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SYSINFRA-1501] base/digest: Use buffered writer for computing digests
Summary: Using a buffered writer for computing digests reduces the amount of memory used and allocations made while computing digests. Since digest computation is used widely, we introduce `NewWriterShort` for computing digests of relatively short inputs and use it where appropriate. Performance improvement is mainly due to addition of `WriteString`. Various benchmarks show modest CPU improvements but significant memory/alloc reduction (reduced by **90%** in some cases) Test Plan: Unit and Integration tests. Benchmarking some digest computations (fileset assertions in particular shown below): - before ``` BenchmarkDigest BenchmarkDigest/writeDigestOld_N100 BenchmarkDigest/writeDigestOld_N100-8 2750 401574 ns/op 177809 B/op 1232 allocs/op BenchmarkDigest/writeDigestNew_N100 BenchmarkDigest/writeDigestNew_N100-8 3904 269149 ns/op 51968 B/op 1310 allocs/op BenchmarkDigest/writeDigestOld_N1000 BenchmarkDigest/writeDigestOld_N1000-8 183 6039835 ns/op 1770788 B/op 12113 allocs/op BenchmarkDigest/writeDigestNew_N1000 BenchmarkDigest/writeDigestNew_N1000-8 352 3031291 ns/op 515594 B/op 13010 allocs/op BenchmarkDigest/writeDigestOld_N10000 BenchmarkDigest/writeDigestOld_N10000-8 16 70172874 ns/op 22929233 B/op 121179 allocs/op BenchmarkDigest/writeDigestNew_N10000 BenchmarkDigest/writeDigestNew_N10000-8 31 37214169 ns/op 5153214 B/op 130010 allocs/op BenchmarkDigest/writeDigestOld_N100000 BenchmarkDigest/writeDigestOld_N100000-8 2 960212048 ns/op 207093356 B/op 1209659 allocs/op BenchmarkDigest/writeDigestNew_N100000 BenchmarkDigest/writeDigestNew_N100000-8 2 561615654 ns/op 51450236 B/op 1300010 allocs/op PASS ``` - after ``` BenchmarkDigest BenchmarkDigest/writeDigestOld_N100 BenchmarkDigest/writeDigestOld_N100-8 3322 339663 ns/op 136214 B/op 34 allocs/op BenchmarkDigest/writeDigestNew_N100 BenchmarkDigest/writeDigestNew_N100-8 5930 191718 ns/op 10168 B/op 112 allocs/op BenchmarkDigest/writeDigestOld_N1000 BenchmarkDigest/writeDigestOld_N1000-8 294 4650456 ns/op 1316342 B/op 115 allocs/op BenchmarkDigest/writeDigestNew_N1000 BenchmarkDigest/writeDigestNew_N1000-8 483 2245917 ns/op 61336 B/op 1012 allocs/op BenchmarkDigest/writeDigestOld_N10000 BenchmarkDigest/writeDigestOld_N10000-8 21 63469161 ns/op 18344572 B/op 1176 allocs/op BenchmarkDigest/writeDigestNew_N10000 BenchmarkDigest/writeDigestNew_N10000-8 43 27897608 ns/op 572248 B/op 10012 allocs/op BenchmarkDigest/writeDigestOld_N100000 BenchmarkDigest/writeDigestOld_N100000-8 2 753470408 ns/op 161193760 B/op 9590 allocs/op BenchmarkDigest/writeDigestNew_N100000 BenchmarkDigest/writeDigestNew_N100000-8 3 359851338 ns/op 5607640 B/op 100012 allocs/op PASS ``` Reviewers: pboyapalli, ghorrell Reviewed By: pboyapalli Subscribers: dnicolaou Differential Revision: https://phabricator.grailbio.com/D73250 fbshipit-source-id: 39208f6
- Loading branch information
Showing
11 changed files
with
16 additions
and
16 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
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
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
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