Reland "[zip] Final zero copy part - direct writer buffer"
This CL is unchanged, as the bug that cause the revert is in
the other CL from the topic
Original comment:
Direct writer buffer allows for the best possible performance:
- no copies for the compressed file extraction, calling
zlib's inflate() to directly decompress from the source mmap
into the destination array
- a single memcpy() when extracting uncompressed files, from
the mapped memory into the destination
- also optimized extraction from non-mmapped archives, where
reading happens directly into the destination buffer
Overall the speedup is about 10-50% depening on the size and
compression
before:
#ExtractEntry/2 1583 ns 1579 ns 446092
#ExtractEntry/16 9163 ns 9142 ns 76434
#ExtractEntry/64 31161 ns 31091 ns 22494
#ExtractEntry/1024 478250 ns 476750 ns 1468
#ExtractEntry/4096 2112883 ns 2106900 ns 334
#ExtractStored/2 134 ns 134 ns 5230346
#ExtractStored/16 671 ns 669 ns 1079782
#ExtractStored/64 2152 ns 2147 ns 327387
#ExtractStored/1024 70591 ns 70465 ns 9882
#ExtractStored/4096 329794 ns 327187 ns 2142
after:
#ExtractEntry/2 1392 ns 1389 ns 509855
#ExtractEntry/16 8429 ns 8410 ns 83200
#ExtractEntry/64 28511 ns 28445 ns 24616
#ExtractEntry/1024 424575 ns 422911 ns 1655
#ExtractEntry/4096 1709493 ns 1701380 ns 411
#ExtractStored/2 65 ns 65 ns 10695136
#ExtractStored/16 414 ns 413 ns 1692297
#ExtractStored/64 1659 ns 1655 ns 424105
#ExtractStored/1024 39244 ns 39155 ns 17952
#ExtractStored/4096 223887 ns 222836 ns 3147
Bug: 237583012
Test: UTs + atest MicrodroidHostTestCases ApexTestCases
Original Change Id: Ia683435772710531d823e0929bac5e414288d582
Change-Id: I508ef5bf3db9a2da6460495284176574853e2e47
2 files changed