#19 HTTPPacket.set method very slow

open
Stefano Lenzi
5
2007-12-29
2005-05-19
Rembo
No

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)
{
<snip>
long conLen = getContentLength();
if (0 < conLen) {
int chunkSize = HTTP.getChunkSize();
<ALLOCATE ARRAY OF 1024*512 bytes!!>
char readBuf[] = new char[chunkSize];
long readCnt = 0;
}

Discussion

  • Stefano Lenzi
    Stefano Lenzi
    2007-12-29

    Logged In: YES
    user_id=901512
    Originator: NO

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

     
  • Stefano Lenzi
    Stefano Lenzi
    2007-12-29

    • assigned_to: nobody --> kismet-sl