From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 4EF4EBB83 for ; Tue, 4 Jul 2006 22:00:22 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id k64K0NtH025050 for ; Tue, 4 Jul 2006 22:00:23 +0200 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id WAA17595 for ; Tue, 4 Jul 2006 22:00:22 +0200 (MET DST) Received: from mz3.forethought.net (mzpi5.forethought.net [216.241.36.14]) by nez-perce.inria.fr (8.13.6/8.13.6) with ESMTP id k64K0Ka9015043 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Tue, 4 Jul 2006 22:00:22 +0200 Received: from [216.241.35.41] (helo=[10.0.0.2]) by mz3.forethought.net with esmtp (Exim 4.51) id 1Fxr49-0002mu-Mh for caml-list@inria.fr; Tue, 04 Jul 2006 14:00:15 -0600 Message-ID: <44AAC8EE.1060805@gushee.net> Date: Tue, 04 Jul 2006 14:00:46 -0600 From: Matt Gushee User-Agent: Thunderbird 1.5.0.4 (X11/20060615) MIME-Version: 1.0 To: caml-list@inria.fr Subject: Re: [Caml-list] LablGTK app maxes out CPU References: <44AAB3B3.6000807@gushee.net> <20060704191216.GA15888@localhost> In-Reply-To: <20060704191216.GA15888@localhost> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 44AAC8D7.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 44AAC8D4.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; lablgtk:01 unix:01 nonblock:01 unix:01 nonblock:01 gtk:01 lablgtk:01 posix:01 non-blocking:01 2006:98 wrote:01 wrote:01 caml-list:01 exceptions:01 btw:02 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 Eric Cooper wrote: > On Tue, Jul 04, 2006 at 12:30:11PM -0600, Matt Gushee wrote: >> [...] >> When the app is started but before the >> GUI is displayed for the first time, CPU usage is negligible, but as >> soon as the GUI is displayed, the app starts using all available CPU >> time, and it continues to do so as long as it runs, whether the GUI is >> displayed or not. So I wonder if there's something more I need to do to >> keep the app well-behaved (BTW, it should never require much CPU time. >> It's a lightweight file manager, and is graphical only in the sense that >> it is a GUI app--it uses no icons or other images). > > Try making the fd nonblocking before you create the glib channel: > Unix.set_nonblock msg_fd; That's how it was originally. But if you look again at my code, you can see that the version with Unix.O_NONBLOCK is commented out. That's because on one of my machines (the one with a newer version of GTK and LablGTK, I believe), I got exceptions every time the program tried to read the input. I don't fully understand why, but making the channel non-non-blocking eliminated the errors. It doesn't make sense to me--based on my limited knowledge of how POSIX I/O works, the channel really *should* be non-blocking. But I have no idea what kind of magic Glib is doing behind the scenes. -- Matt Gushee : Bantam - lightweight file manager : matt.gushee.net/software/bantam/ : : RASCL's A Simple Configuration Language : matt.gushee.net/rascl/ :