commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stefan Bodewig (JIRA)" <>
Subject [jira] [Commented] (COMPRESS-333) bz2 stream decompressor is 10x slower than it could be
Date Fri, 05 Feb 2016 17:17:40 GMT


Stefan Bodewig commented on COMPRESS-333:

Great, thanks. Let us know when you are done so we can close this issue.

WRT to the Hadoop code, we've had some bad experience with (an early version of?) it in Ant
land, where the current bz2 code originates from. Ant used the then-current Hadoop code for
a few releases but had to revert to Keiron's original code since the Hadoop code failed to
decompress certain files - and we didn't understand it well enough to fix it ourselves. If
you are still interested in going that route, I can try to dig our an example file just to
ensure the problem has been fixed by now.

> bz2 stream decompressor is 10x slower than it could be
> ------------------------------------------------------
>                 Key: COMPRESS-333
>                 URL:
>             Project: Commons Compress
>          Issue Type: Improvement
>            Reporter: Dawid Weiss
> This is related to COMPRESS-291. In short: decompressing 7z archives was an order of
magnitude slower in Java than with native tooling.
> My investigation showed that the problematic archive used bz2 streams inside. I then
did a quick hack-experiment which took bz2 decompressor from the Apache Hadoop project (the
Java version, not the native one) and replaced the default one used for bz2 stream decompression
of the 7z archiver in commons.
> I then ran a quick benchmark on this file:
> {code}
> {code}
> The decompression speeds are (SSD, the file was essentially fully cached in memory, so
everything is CPU bound):
> {code}
> native {{7za}}: 13 seconds
> Commons (original): 222 seconds
> Commons (patched w/Hadoop bz2): 30 seconds
> Commons (patched w/BufferedInputStream): 28 seconds
> {code}
> Yes, it's still 3 times slower than native code, but it's no longer glacially slow...

> My patch is a quick and dirty proof of concept (not committable, see [1]), but it passes
the tests. Some notes:
> - Hadoop's stream isn't suited for handling concatenated bz2 streams, it'd have to be
either patched in the code or (better) decorated at a level above the low-level decoder,
> - I only substituted the decompressor in 7z, but obviously this could benefit in other
places (zip, etc.); essentially, I'd remove BZip2CompressorInputStream entirely.
> - while I toyed around with the above idea I noticed a really annoying thing -- all streams
are required to extend {{CompressorInputStream}}, which only adds one method to count the
number of consumed bytes. This complicates the code and makes plugging in other implementations
of InputStreams more cumbersome. I could get rid of CompressorInputStream entirely with a
few minor changes to the code, but obviously this would be backward incompatible (see [2]).
> References:
> [1] GitHub fork, {{bzip2}} branch:
> [2] Removal and cleanup of CompressorInputStream:

This message was sent by Atlassian JIRA

View raw message