Threads, do_nanosleep and battery life

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

Hi,

In [email protected]
“Threads, do_nanosleep and battery life” on Thu, 13 Mar 2008 22:21:58
+0900,
Mark S. [email protected] 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,

On Sat, Mar 15, 2008 at 4:06 AM, Kouhei S. [email protected] 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.org/viewvc/*checkout*/samizdat/samizdat/lib/samizdat/cache.rb?revision=1.99
http://cvs.savannah.gnu.org/viewvc/*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 ]

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.org/viewvc/*checkout*/samizdat/samizdat/lib/samizdat/cache.rb?revision=1.99
http://cvs.savannah.gnu.org/viewvc/*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/b806a8443ffb5f45?hl=en
explains a little on how Ruby does threading.
GL!
-=R