Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo


#19 HTTPPacket.set method very slow

Stefano Lenzi

I have been measuring the time it takes to complete one
entire Action.postControlAction(), so essentialy
completing an action request. I noticed this takes much
longer with CyberLink than for example with the intel
UPnP toolkit.

I could trace the cause to the HTTPPacket.set method,
it creates an array (readBuf) of length
HTTP.getChunkSize(). The chunk size however defaults to
512*1024 bytes. So for every HTTPPacket which is
received an array of half a megabyte is created. By
setting the chunk size to a few kilobytes I could
reduce the time it takes to complete an entire action
request with a factor 10.

I don't no if there is a good reason for setting the
chunk size this big, however if there is not it might
be advisable to reduce the default chunk size
signifcantly (of course a fix in my case is setting the
cunk size with HTTP.setChunkSize(), but if you don't
know this things can get pretty slow) .

protected boolean set(InputStream in, boolean onlyHeaders)
long conLen = getContentLength();
if (0 < conLen) {
int chunkSize = HTTP.getChunkSize();
<ALLOCATE ARRAY OF 1024*512 bytes!!>
char readBuf[] = new char[chunkSize];
long readCnt = 0;


  • Stefano Lenzi
    Stefano Lenzi

    Logged In: YES
    Originator: NO

    I will look into your patch and I'll probably apply it. Thank you!

  • Stefano Lenzi
    Stefano Lenzi

    • assigned_to: nobody --> kismet-sl