[chuck-users] implementing a "wait for signal with timeout"

Hans Aberg haberg at math.su.se
Tue Jun 9 13:08:48 EDT 2009


On 9 Jun 2009, at 01:22, Robert Poor wrote:
>> Are you saying the threads themselves are leaking?
>
> Essentially, yes: sporking a shred eats up 88.3K of non-recovered  
> memory.  It's easy to show with this bit of code:
> =================================
...
> =================================
> which produces this output:
> =================================
> [poorbook15-9:~/Desktop] r% chuck --caution-to-the-wind alloc_test1.ck
> USER       PID %CPU %MEM      VSZ    RSS   TT  STAT STARTED       
> TIME COMMAND
> "on startup" : (string)
> r          207   2.5  0.5    82160   4928   p0  S+    3:58PM    
> 0:00.52 chuck --caution-to-the-wind alloc_test1.ck
> "round 1: spork ~ testShred(); me.yield();" : (string)
> r          207   0.1 82.8   966832 868412   p0  S+    3:58PM    
> 0:12.20 chuck --caution-to-the-wind alloc_test1.ck
> "round 2: spork ~ testShred(); me.yield();" : (string)
> r          207   0.0 81.8  1850480 857960   p0  S+    3:58PM    
> 0:52.08 chuck --caution-to-the-wind alloc_test1.ck
> =================================
>
> The thing to notice is the VSZ column -- that's "virtual size" in  
> kbytes.  It grows by (966832-82160)=884672 kbytes on round 1 and  
> (1850480-966832)=883648 kbytes on round 2.  Since there's 100000  
> sporks per round, that's a consistent 88.3 kBytes per spork, even  
> though the testShred is as simple as can be.

I think you may have not waited enough for the threads to clean up. I  
first ran your code verbatim, and got:
$ chuck --caution-to-the-wind thread_timing.ck
USER       PID %CPU %MEM      VSZ    RSS   TT  STAT STARTED      TIME  
COMMAND
"on startup" : (string)
haberg     673   9.2  0.5    84720   4920 s000  S+    6:32PM   0:00.37  
chuck --caution-to-the-wind thread_timing.ck
"round 1: spork ~ testShred(); me.yield();" : (string)
haberg     673   0.1 77.5   968368 812132 s000  S+    6:32PM   0:14.92  
chuck --caution-to-the-wind thread_timing.ck
"round 2: spork ~ testShred(); me.yield();" : (string)
haberg     673   0.2 81.3  1853040 852524 s000  S+    6:32PM   0:53.13  
chuck --caution-to-the-wind thread_timing.ck

The figures in the VSZ columen are almost identical to yours.

But the I added a 5 minute wait before writing the stuff out, to give  
time for any cleanups. Then I got
chuck --caution-to-the-wind thread_allocation.ck
USER       PID %CPU %MEM      VSZ    RSS   TT  STAT STARTED      TIME  
COMMAND
"on startup" : (string)
haberg     703   0.7  0.5    84720   4920 s000  S+    6:40PM   0:00.48  
chuck --caution-to-the-wind thread_allocation.ck
"round 1: spork ~ testShred(); me.yield();" : (string)
haberg     703   0.6  0.5    89416   4904 s000  S+    6:40PM   0:45.87  
chuck --caution-to-the-wind thread_allocation.ck
"round 2: spork ~ testShred(); me.yield();" : (string)
haberg     703   0.8  0.4    89416   4680 s000  S+    6:40PM   1:31.24  
chuck --caution-to-the-wind thread_allocation.ck

As you see, now the VSZ column stabilizes and does not grow at all.

   Hans

-------------- next part --------------
A non-text attachment was scrubbed...
Name: thread_allocation.ck
Type: application/octet-stream
Size: 1409 bytes
Desc: not available
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20090609/a760881b/attachment.obj>
-------------- next part --------------







More information about the chuck-users mailing list