hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sebastiano Vigna <vi...@di.unimi.it>
Subject Re: Incredibly slow gzip downloads
Date Sat, 15 Feb 2014 16:06:50 GMT
On 15 Feb 2014, at 12:47 PM, Oleg Kalnichevski <olegk@apache.org> wrote:

> The problem mostly likely has been introduced by HTTPCLIENT-1432 [1]. I
> reviewed the patch once more and could not find anything obviously wrong
> with it. Try reverting the changes introduced by HTTPCLIENT-1432 and see

Subclassing InputStream without overriding the multi-byte read() method is a recipe for disaster...
the inherited method does a byte-by-byte read. You can see what's happening in this hprof

        java.util.zip.Inflater.inflateBytes(Inflater.java:Unknown line)

copyContent() would love to read(byte[],int,int) in a buffer, but since LazyDecompressingInputStream
doesn't override it it invokes instead the read-byte-by-byte inherited method in InputStream,
which in turn now calls for each byte the one-byte read() method from LazyDecompressingInputStream,
which invokes the one-byte read method from InflaterInputStream, which does a multi-byte,
length-one read from GZIPInputStream, which unleashes a similar call on InflaterInputStream,
which unfortunately makes a similar read using the native inflateBytes() method. 

The result is a 10-50x decrease in speed, but I think that a trivial override of read(byte[],int,int)
in LazyDecompressingInputStream will solve the problem.



To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org

View raw message