help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-smalltalk] OO languages are spoiling us...


From: Paolo Bonzini
Subject: [Help-smalltalk] OO languages are spoiling us...
Date: Sat, 25 Jul 2009 14:03:31 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1b3pre) Gecko/20090513 Fedora/3.0-2.3.beta2.fc11 Lightning/1.0pre Thunderbird/3.0b2

And we forget to close files. :-)

Stupid me for suggesting that Stefan tracked accept system calls, but not opens!

Index: Core/RequestHandlers/FileHandler.st
===================================================================
--- Core/RequestHandlers/FileHandler.st (revision 1408)
+++ Core/RequestHandlers/FileHandler.st (working copy)
@@ -526,8 +526,10 @@ RequestHandler subclass: FileHandler [

     produceResponse [
        <category: 'responding'>
-       self respond: [:response |
-           response nextPutAll: file readStream binary contentsStream.
+       self respond: [:response || stream |
+           stream := file readStream.
+           [response nextPutAll: stream binary contentsStream]
+               ensure: [stream close].
            response contentType: (self mimeTypeFor: file filename).
            self addAllowHeaderTo: response.
            self session useCookies ifTrue: [


With this in place, I have pretty cool results:

1) the number of sockets open while running Stefan's mechanize script is exactly "number of concurrent requests" * 2. No CLOSE_WAIT sockets.

2) the file descriptors are never higher than 20, which means that my connection thresholding system is working nicely (it did have a couple of bugs). Without the pool, Swazoo was using about twice as many file descriptors. The speed was more or less the same.

With the pool, the beginning of the strace (strace -e accept -e signal=none) is absolutely awesome:

accept(4, {sa_family=AF_INET, sin_port=htons(57504), ...) = 5
accept(4, {sa_family=AF_INET, sin_port=htons(57505), ...) = 6
accept(4, {sa_family=AF_INET, sin_port=htons(57506), ...) = 7
accept(4, {sa_family=AF_INET, sin_port=htons(57507), ...) = 8
accept(4, {sa_family=AF_INET, sin_port=htons(57508), ...) = 9
accept(4, {sa_family=AF_INET, sin_port=htons(57509), ...) = 10
accept(4, {sa_family=AF_INET, sin_port=htons(57510), ...) = 11
accept(4, {sa_family=AF_INET, sin_port=htons(57511), ...) = 12
accept(4, {sa_family=AF_INET, sin_port=htons(57512), ...) = 13
accept(4, {sa_family=AF_INET, sin_port=htons(57513), ...) = 14
accept(4, {sa_family=AF_INET, sin_port=htons(57514), ...) = 15
accept(4, {sa_family=AF_INET, sin_port=htons(57515), ...) = 16
accept(4, {sa_family=AF_INET, sin_port=htons(57516), ...) = 17
accept(4, {sa_family=AF_INET, sin_port=htons(57517), ...) = 18
accept(4, {sa_family=AF_INET, sin_port=htons(57518), ...) = 19
accept(4, {sa_family=AF_INET, sin_port=htons(57519), ...) = 20
accept(4, {sa_family=AF_INET, sin_port=htons(57520), ...) = 5
accept(4, {sa_family=AF_INET, sin_port=htons(57521), ...) = 6
accept(4, {sa_family=AF_INET, sin_port=htons(57522), ...) = 7
accept(4, {sa_family=AF_INET, sin_port=htons(57523), ...) = 8
accept(4, {sa_family=AF_INET, sin_port=htons(57524), ...) = 9
accept(4, {sa_family=AF_INET, sin_port=htons(57525), ...) = 10
accept(4, {sa_family=AF_INET, sin_port=htons(57526), ...) = 11
accept(4, {sa_family=AF_INET, sin_port=htons(57527), ...) = 12

:-)

3) forty clients consume 70 megabytes, eighty consume 110 megabytes. and this is on a 64-bit machine; a 32-bit machine would consume half approximately. The buffers for the files probably were consuming some memory; anyway remember that we were at 110 megabytes for 25 clients when we started.

Only negative point, garbage is not reclaimed well so running "ruby mech.rb 80" twice will take 174 megabytes. I didn't check whether compacting between the two runs would affect the memory consumption.

4) I had one exception that I'll look into:

Object: nil error: did not understand #goodness:
MessageNotUnderstood(Exception)>>signal (AnsiExcept.st:216)
UndefinedObject(Object)>>doesNotUnderstand: #goodness: (AnsiExcept.st:1556)
optimized [] in BlockClosure class>>exceptionHandlerSearchBlock (BlkClosure.st:13) [] in Kernel.CoreException>>instantiateNextHandler:from: (ExcHandling.st:344) MethodContext(ContextPart)>>scanBacktraceForAttribute:do: (ContextPart.st:424)
Kernel.CoreException>>instantiateNextHandler:from: (ExcHandling.st:345)
MessageNotUnderstood(Exception)>>signal (AnsiExcept.st:216)
UndefinedObject(Object)>>doesNotUnderstand: #key (AnsiExcept.st:1556)
Delay class>>unscheduleDelay: (Delay.st:142)
Delay class>>handleDelayEvent (Delay.st:91)
optimized [] in Delay class>>runDelayProcess (Delay.st:116)

but GNU Smalltalk, Swazoo, Iliad continued working like a charm!!!

I'm amazed.

Paolo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]