On 04. 01. 2011 04:25, [email protected] wrote:
> "Philippe Marschall"<[email protected]> wrote:
>>>     preallocation OrderedCollection new: instead of relying on its growing 
>>> behavior. 
>>
>> Right, but you never know how big the response is going to before
>> actually rendering. Otherwise you could just do Array/String new:
>> beforehand.
> 
> I'm not quite clear about the context here so this may not be relevant, but 
> one technique that paid of for us in terms of managing socket buffers was to 
> start recycling them. The idea is that if you generally allocate let's say 
> 32K buffer for every socket you open, rather then throwing the buffer away 
> when you're done with the socket, just put it aside and let the next socket 
> pick up and reuse the same instance. 

Yep, this is a technique used in Swazoo too. When you nextPutAll: to
Swazoo's HTTPResponse, you actually write directly to the SwazooBuffer,
which has such recyclable collection.

Main reason to introduce those buffers was exactly to reduce garbage
collection activity to minimum, which is very important when serving (or
uploading) large content.

Second reason is that network packets must be packaged for network
performance into a reasonably big packets and not into a lot of small
ones after each nextPutAll:.

Best regards
Janko


-- 
Janko Mivšek
AIDA/Web
Smalltalk Web Application Server
http://www.aidaweb.si

Reply via email to