[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Threads, do_nanosleep and battery life

Mark Somerville

3/13/2008 1:22:00 PM

I'm writing a Ruby GTK application that runs on a mobile device (Nokia N800).
It's starting to take shape now, but I have noticed that leaving it running for
long periods of time is particularly bad for my battery life.

I don't really understand Ruby threads under the hood or what alterations to
them ruby-gtk2 makes (but am keen to learn!). Powertop suggests that Ruby is
waking up around 100 times a second when there is an active thread, even
during a sleep state. Presumably this is to check for thread activity.

Is there a way around this in Ruby 1.8? Will the new threading model in 1.9
help this?

Any pointers are apprecited,

Mark

3 Answers

Kouhei Sutou

3/15/2008 1:07:00 AM

0

Hi,

In <20080313132049.GA15954@titan.pccl.info>
"Threads, do_nanosleep and battery life" on Thu, 13 Mar 2008 22:21:58 +0900,
Mark Somerville <ms@pccl.info> wrote:

> I'm writing a Ruby GTK application that runs on a mobile device (Nokia N800).
> It's starting to take shape now, but I have noticed that leaving it running for
> long periods of time is particularly bad for my battery life.
>
> I don't really understand Ruby threads under the hood or what alterations to
> them ruby-gtk2 makes (but am keen to learn!). Powertop suggests that Ruby is
> waking up around 100 times a second when there is an active thread, even
> during a sleep state. Presumably this is to check for thread activity.

This should be fixed in Ruby-GNOME2 trunk.

Thanks,
--
kou

Dmitry Borodaenko

9/23/2008 7:46:00 PM

0

On Sat, Mar 15, 2008 at 4:06 AM, Kouhei Sutou <kou@cozmixng.org> wrote:
>> I'm writing a Ruby GTK application that runs on a mobile device (Nokia N800).
>> It's starting to take shape now, but I have noticed that leaving it running for
>> long periods of time is particularly bad for my battery life.
>>
>> I don't really understand Ruby threads under the hood or what alterations to
>> them ruby-gtk2 makes (but am keen to learn!). Powertop suggests that Ruby is
>> waking up around 100 times a second when there is an active thread, even
>> during a sleep state. Presumably this is to check for thread activity.
>
> This should be fixed in Ruby-GNOME2 trunk.

Hi all,

Can you share some more details on how exactly it was addressed? I
have a multi-threaded Ruby daemon that has nothing to do with Gtk, and
it exhibits the same behaviour: 100 calls to do_nanosleep per second.
The deamon is a DRb based object cache, the whole source is these two
files, 191 lines total:

http://cvs.savannah.gnu.o...*checkout*/samizdat/samizdat/lib/samizdat/cache.rb?revision=1.99
http://cvs.savannah.gnu.o...*checkout*/samizdat/samizdat/bin/samizdat-drb-server?revision=1.99

This definitely looks like a generic Ruby issue to me, but if there is
a workaround, I don't mind applying it on the application level.

[ sorry for waking up this really old thread, but Google tells me that
is the only case where Ruby do_nanosleep issue was addressed ]

--
Dmitry Borodaenko

Roger Pack

9/24/2008 9:14:00 PM

0

> Hi all,
>
> Can you share some more details on how exactly it was addressed? I
> have a multi-threaded Ruby daemon that has nothing to do with Gtk, and
> it exhibits the same behaviour: 100 calls to do_nanosleep per second.
> The deamon is a DRb based object cache, the whole source is these two
> files, 191 lines total:
>
> http://cvs.savannah.gnu.o...*checkout*/samizdat/samizdat/lib/samizdat/cache.rb?revision=1.99
> http://cvs.savannah.gnu.o...*checkout*/samizdat/samizdat/bin/samizdat-drb-server?revision=1.99
>
> This definitely looks like a generic Ruby issue to me, but if there is
> a workaround, I don't mind applying it on the application level.
>
> [ sorry for waking up this really old thread, but Google tells me that
> is the only case where Ruby do_nanosleep issue was addressed ]

http://groups.google.com/group/never-block/browse_thread/thread/b806a8443ffb...
explains a little on how Ruby does threading.
GL!
-=R
--
Posted via http://www.ruby-....