diff options
author | Timothy Flynn <trflynn89@pm.me> | 2023-04-01 16:19:21 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-04-02 10:54:37 +0200 |
commit | eed956b473e86b88da146b9f7356d4064736f626 (patch) | |
tree | 8b77b1de6cfe5cb68575e94ce49f18ab90655722 /AK/Array.h | |
parent | d74fa5e2832874dea5f721762c80dcae3a53c834 (diff) | |
download | serenity-eed956b473e86b88da146b9f7356d4064736f626.zip |
AK: Increase LittleEndianOutputBitStream's buffer size and remove loops
This is very similar to the LittleEndianInputBitStream bit buffer change
from 8e834d4bb2f8a217013142658fe7203c5a5c3170.
We currently buffer one byte of data for the underlying stream. And when
we put bits onto that buffer, we do so 1 bit at a time.
This replaces the u8 buffer with a u64. And instead of looping at all,
we perform bitwise operations to write the desired number of bits.
Using the "enwik8" file as a test (100MB uncompressed, commonly used in
benchmarks: https://www.mattmahoney.net/dc/enwik8.zip), compression time
decreases from:
13.62s to 10.9s on Serenity (cold)
13.62s to 9.22s on Serenity (warm)
2.93s to 2.32s on Linux
One caveat is that this requires explicitly flushing any leftover bits
when the caller is done with the stream. The byte buffer implementation
implicitly flushed its data every time the buffer was byte-aligned, as
doing so would always fill the byte. This is no longer the case. But for
now, this should be fine as the one user of this class, DEFLATE, already
has a "flush everything now that we're done" finalizer.
Diffstat (limited to 'AK/Array.h')
0 files changed, 0 insertions, 0 deletions