Russ Allbery: > [...] >> I wouldn't have expected that either, but it appeared to be 4-5 times >> slower than the equivalent code with fork a decompressor, which is why I >> swapped it out. [I didn't bother to benchmark them, because the >> differences between them was so stark.] > > I've done extensive benchmarking of this in Perl for a different project > and yes, fork and exec of an external compresser is *way* faster than > using a library. I suspect the Perl compress libraries are making > extraneous data copies or doing something else suboptimal. >
An exception in my experience: In process is cheaper when the (de)compressor is available in the PerlIO Layer as native C code. Notable example being libperlio-gzip-perl where you use "open(my $fd, '<:gzip', $file)". At least that was the case when I benchmarked on Lintian in 2.5.10 (2 releases ago). Thanks, ~Niels