Delivered-To: garrigue at math.nagoya-u.ac.jp Authentication-Results: mailhost.math.nagoya-u.ac.jp sender=lablgtk-bounces at yquem.inria.fr; domainkey=neutral (no query protocol specified; no policy for yquem.inria.fr) Delivered-To: lablgtk at yquem.inria.fr DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=oXF1OyPy1bUzJ1mR+KKz+Dc5inrsy1ibnxXqlT1BYZs=; b=QkeIJD5TKK3jV3yHETAZYQ3kxLBmuaKu3XaUuKfSHjr1T+2BOwfH6kl9uNfaIScQx5 HVjWNGW0VVpog+kWyHpNhLMmoIFaV6BaMiGZAoIchQMdHyOOYQ+/4WR62aaeif0ot/3y sa8VQPgSZkf+Zm4YfO1kE+YpRIL/YU2d89k4Q= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=AoWBVUWpdwvL731C+PiDkCwsY8n/PKQFpFkhlPkcOZ7e5rDB0bVGobXjqaO9WUjo1t XgidgMh9Wvr043QYkKHJxX6JLoT0pdy8uDtuwbYBlx3mwgXmQ3tuFUoSj6pzLWCWDB5/ mTP0nOiRvA5JzrVBiCNz3BE06bx0bDvCCFV2U= MIME-Version: 1.0 In-Reply-To: <20101214084959.0c5ce2ef at alcazar> References: <20101214083626.59faf109 at alcazar> <20101214084959.0c5ce2ef at alcazar> Date: Tue, 14 Dec 2010 12:18:00 +0100 Message-ID: Subject: Re: [Lablgtk] CPU consumption with GtkThread From: Adrien To: Maxence Guesdon Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: lablgtk at yquem.inria.fr Status: U Hi, I actually made it adaptive later on[1]. The drawback was that animations could take more time to update. The adaptative version worked quite well but reducing the delay wasn't instantaneous. It was pretty dumb and experimental, I could probably put more thought in it if needed. One of my test was using the acid3 test[2]. Basically, each step of the animation required one iteration of the loop. So depending on your uses it might or might not be a good idea. Then, at the OCaml Hacking Day, J=E9r=E9mie Dimino told me to try Lwt's support[3]. Since you'll only be using lwt threads, you won't have to use GtkThread. IIRC it's only a matter of putting the following at the top of your code instead: let () =3D Lwt_glib.init () (and of course, link against lwt-glib) Haven't had issues with it and you don't have to use lwt everywhere, only sections that may take time. Hope this helps [1] http://git.ocamlcore.org/cgi-bin/gitweb.cgi?p=3Dcaravel/caravel.git;a= =3Dblob_plain;f=3Dgtk_thread_bis/gtkThreadBis.ml;hb=3D67e29bc6550603fa42857= 569eb6f878f180949f2 [2] http://acid3.acidtests.org/ [3] http://ocsigen.org/lwt/doc/api/Lwt_glib.html -- Adrien Nader On 14/12/2010, Maxence Guesdon wrote: > On Tue, 14 Dec 2010 08:36:26 +0100 > Maxence Guesdon wrote: > >> Hello, >> >> When I use GtkThread.main (), my process consumes a lot of CPU. Having a >> look at the code of GtkThread.ml, I see a never ending loop, and >> especially >> a never-delaying loop, which I think results in the consumption. >> >> Is it normal ? Isn't there a way to use threads without such a consumpti= on >> ? > > Well, I just saw that Adrien proposed a workaround/fix for this problem o= n > the list one year ago: > http://yquem.inria.fr/pipermail/lablgtk/2009-December/000335.html > > He changed > Thread.delay 0.0001; > into > Thread.delay 0.013; > > Could we integrate this ? And may be provide a function to change the del= ay > used in the fix ? > > Regards, > > Maxence > > > > _______________________________________________ > Lablgtk mailing list > Lablgtk@yquem.inria.fr > http://yquem.inria.fr/cgi-bin/mailman/listinfo/lablgtk > _______________________________________________ Lablgtk mailing list Lablgtk@yquem.inria.fr http://yquem.inria.fr/cgi-bin/mailman/listinfo/lablgtk