Threads, do_nanosleep and battery life

M

Mark Somerville

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
 
K

Kouhei Sutou

Hi,

In <[email protected]>
"Threads, do_nanosleep and battery life" on Thu, 13 Mar 2008 22:21:58 +0900,
Mark Somerville said:
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,
 
D

Dmitry Borodaenko

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/...amizdat/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 ]
 
R

Roger Pack

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/...amizdat/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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,831
Latest member
RusselWill

Latest Threads

Top