[self-interest] Self CPU usage and file handling

Chris Double chris.double at double.co.nz
Tue Apr 22 14:59:17 UTC 2014

On Wed, Apr 23, 2014 at 2:18 AM, Chris Double <chris.double at double.co.nz> wrote:
> 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').

On 64bit linux calls to gettimeofday aren't a syscall so it is faster.
Because we compile self as a 32 bit app this optimisation isn't used
unfortunately. As a quick test I did this hacky patch to drop
gettimeofday usage to 10 times/second by calling it in a thread:


This dropped the CPU usage down to 2% on linux with the desktop open
so it does seem to have some effect. It also slows down the Self
system though. Does the scheduler use gettimeofday in some way?


More information about the Self-interest mailing list