[self-interest] Self CPU usage and file handling
Chris Double
chris.double at double.co.nz
Tue Apr 22 14:18:47 UTC 2014
On Tue, Apr 22, 2014 at 9:07 PM, Russell Allen <mail at russell-allen.com> wrote:
>
> To reproduce: look at top(1) when ./vm/Self is running in another terminal.
> It always hovers at 5-10% CPU usage on my machine.
I did some investigation in a Linux Self system. If I run 'vm/Self'
with no snapshot so it's just in the interactive scanner I see it
floating between 0 and 1% CPU on Linux (3-5% running under strace). I
see the jumping in and out of the 'read' system call. The cpu usage
matches the following C program which was written to imitate what the
Self VM is doing at this point:
<http://pastebin.com/NGxgLZy1>
While low it would be good to remove this if possible. Can the
interactive scanner read loop be exited when it's no longer used? I
assume the SIGALRM usage is used for the Self scheduler. Perhaps that
could be optimized such that it's turned off if all processes are
blocked in i/o.
If I create a snapshot using 'worldBuilder.self' and run that without
entering the desktop (ie. staying in the REPL) I still see only 0-1%
CPU. Now it's entering/existing the 'select' system call though.
If I start the desktop (via 'desktop open), Self CPU usage jumps to
3-5%. The desktop overhead seems high. Here strace shows that
'gettimeofday' is called a lot, followed by 'select'. This is what I
get with about 60 seconds of idle in the desktop:
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
84.32 0.024001 7 3312 3263 select
6.95 0.001979 0 6342 rt_sigprocmask
5.46 0.001555 0 3590 3269 rt_sigreturn
2.70 0.000768 0 15455 gettimeofday
0.37 0.000104 0 3504 3469 recv
0.13 0.000036 0 196 getrusage
0.07 0.000020 0 64 mmap2
0.00 0.000000 0 179 6 read
0.00 0.000000 0 45 2 write
0.00 0.000000 0 30 1 open
0.00 0.000000 0 28 close
The 'gettimeofday' calls appear to come from real_time_prim in
miscPrims.cpp. This is the _TimeReal primitive and only used in
'currentTime' in 'traits time'. It's hard to test with that stubbed
out since it's used a lot all over the place (via 'current' in 'traits
time').
--
http://www.bluishcoder.co.nz
More information about the Self-interest
mailing list