Andrew Piskorski wrote:

To reduce your RAM usage, you would definitely want to investigate
ttrace, included in the Tcl Threads Extension.  However, you don't
seem to be running out memory, so this is unlikely to be that big a
help in your case.

I have had very little success in getting ttrace to work.

However, I was looking at the memory stats on mempools.adp and I noticed that the overhead was in the neighborhood of 50%-60%. After a small amount of looking, I realized this is entirely expected: the USE_THREAD_ALLOC version of Tcl_Alloc is a power-of-2 allocator, meaning that it rounds up all requests that it handles to the next higher power of 2. So for example, a request to allocate 600 bytes will really allocate 1024 bytes and the difference is wasted space. On average, you would expect this wasted space to be about 50% more than you requested.

So, inspired by the description of google's tcmalloc which uses a large number of buckets, I added a whole lot more buckets spaced closely together (from 8 bytes for the smaller sizes to 512 bytes for larger sizes) in tclThreadAlloc.c and the results were as I hoped; the memory overhead went down to around 10%.

Adding all these extra buckets will impose some overhead of its own and a small (probably unnoticable) performance impact, but the amount of memory allocated seems to dwarf this overhead and real impact on memory size is noticable. My server that would be around 90M a few minutes after starting is now only 65-70M. On a memory-tight environment like a unixshell.org setup, this can be quite significant.

On a larger server with more memory this can still matter: if trying to keep the overall memory footprint small isn't really your issue then you could think of it as being able to run 40% more threads.

-J


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]> 
with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: 
field of your email blank.

Reply via email to