Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
LablGTK app maxes out CPU
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2006-07-06 (07:17)
From: Matt Gushee <matt@g...>
Subject: Re: [Caml-list] LablGTK app maxes out CPU
Matt Gushee wrote:

> Nothing seems to make any difference. It's true that my app does allow 
> other programs to grab a significant amount of CPU time when they need 
> it. But when my app is idle and not much else is running, 'top' shows it 
> using over 90% of the CPU. That's certainly not normal, and I would 
> think very undesirable.
> A 'sleep' call might help, but the standard Unix.sleep only accepts 
> 1-second increments, which is undesirable. But I can try a wrapper for 
> usleep() ... unless someone has a better idea.

Argh! This is getting really frustrating ...

I added a custom sleep function, and called it to sleep for 0.3 seconds 
whenever there is no input to read. That should hugely reduce the 
frequency of attempts to read the FIFO, while not introducing much of a 
delay in response to commands. I tried both implementations, by the way: 
both the usleep wrapper and the hack.

It doesn't make any difference.

BTW, I did check the app in non-daemon mode, and CPU usage is quite 
modest, as I would expect. And the only real difference between normal 
and daemon mode is this Io watching thing.

Matt Gushee
: Bantam - lightweight file manager : :
: RASCL's A Simple Configuration Language : :