maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Maemo 5 / Fremantle (https://talk.maemo.org/forumdisplay.php?f=40)
-   -   Serious power saving with dbus-scripts and pkill -STOP (https://talk.maemo.org/showthread.php?t=73038)

Xagoln 2011-05-13 17:27

Serious power saving with dbus-scripts and pkill -STOP
 
We all know that many processes run in the background constantly. Some of the worst offenders are:
  • scim-panel-gtk
  • browserd
  • tracker
  • image-viewer
  • ...

dbus-scripts (see the excellent Maemo Wiki page) is a nifty tool to listen to internal system events and respond accordingly.

Now, in catching the D-Bus messages for screen dimming and especially screen lock, we can 'pause' these processes using the standard Unix 'SIGSTOP' signal, meaning they shouldn't consume any CPU cycles/power until awoken.

Some of you might question putting browserd in there, firstly because of dsme/watchdog, and secondly because you might be downloading something and lock the screen. The good news is that I found that dsme/watchdog will not trigger a reboot if browserd is paused. As long as it is in the process list, no probs. Re downloading, I'd probably use Opera in that case.

Be sure you know what you're doing, or are prepared to reflash

How it's done:

As root:
Code:

$ root

# apt-get install dbus-scripts

Fīle: /etc/dbus-scripts.d/screen-lock
Code:

/usr/local/share/dbus-scripts/screen-lock  * * com.nokia.mce.signal tklock_mode_ind locked
/usr/local/share/dbus-scripts/screen-unlock * * com.nokia.mce.signal tklock_mode_ind unlocked

(The above should be two long lines, bear that in mind if it has word-wrapped into 4 or more)


Fīle: /usr/local/share/dbus-scripts/screen-lock
Code:

#!/bin/ash

for process in browserd scim-panel-gtk image-viewer
do
  /usr/bin/pkill -STOP $process
done


Fīle: /usr/local/share/dbus-scripts/screen-unlock
Code:

#!/bin/ash

for process in browserd scim-panel-gtk image-viewer
do
  /usr/bin/pkill -CONT $process
done

Make all of the above scripts executable!

Now restart dbus-scripts:
Code:

# killall dbus-scripts
You can do likewise for screen dimming, keyboard closing etc, to your preference. Just be sure to think through the consequences.

Xagoln 2011-05-13 17:45

Re: Serious power saving with dbus-scripts and pkill -STOP
 
I will leave my phone locked overnight to see how it fares.

Could be worth holding off on doing this until I confirm long periods of locking don't cause any issues.

hawaii 2011-05-13 18:25

Re: Serious power saving with dbus-scripts and pkill -STOP
 
FWIW, I use dbuscron as it seems to be more stable for me. With some intelligent scripting and fcron, it would be possible to grab the PID that's chewing unnecessary cycles and pause it when locked.

A lot of user spawned processes can be paused that aren't necessary; calendar, hildon-input-method, camera-ui are a few I've been doing with no issue.

Curiously, I wonder what happens if you try and issue STOP to hildon-desktop, hildon-home and hildon-status-menu...

hawaii 2011-05-13 19:17

Re: Serious power saving with dbus-scripts and pkill -STOP
 
Don't bother pausing hildon-desktop or home on lock trigger. Too many processes hook into them, namely phone calls don't work :P

I've shut off osso-xterm, calendar, camera-ui, browserd, image-viewer, hildon-input-method.

I want thumbnailer and tracker to run, so renice to +19 and call it a day.

vi_ 2011-05-13 21:20

Re: Serious power saving with dbus-scripts and pkill -STOP
 
Quote:

Originally Posted by hawaii (Post 1005727)
Don't bother pausing hildon-desktop or home on lock trigger. Too many processes hook into them, namely phone calls don't work :P

I've shut off osso-xterm, calendar, camera-ui, browserd, image-viewer, hildon-input-method.

I want thumbnailer and tracker to run, so renice to +19 and call it a day.

You have my attention, please tell me more about this hawaii...

FYI I have 2 scripts.

1. Under-clocks and under-volts the phone to THE MAX. This is tied into the n900 'device inactive' dbus signal. I am unsure what the trigger is but it seems to appear a short while after the screen goes off. This only happens if the keyboard is closed AND the back light is off. This means if the n900 is doing something that will take a while and i don't want it to under power I just leave the keyboard open.


2. A clock and voltage back up script, this is triggered when the device is unlocked.


This means that i have been able to get rid of the kernel-power-settings script (I have a local copy loading settings). For some reason it occasionally causes my n900 to spazz out with ~8000 wake ups per second keeping it in C0.

For a while I was experimenting with stopping bme when the device was asleep however it wasnt easy to detect the 'plugged in, bme not started' condition (there is no dbus signal when BME is stopped), further more BME would just stop working after a bunch of start/stops :/ Although stopping BME was saving me around 200~wakeups/30s...

vi_ 2011-05-13 21:22

Re: Serious power saving with dbus-scripts and pkill -STOP
 
Quote:

Originally Posted by hawaii (Post 1005727)
Don't bother pausing hildon-desktop or home on lock trigger. Too many processes hook into them, namely phone calls don't work :P

I've shut off osso-xterm, calendar, camera-ui, browserd, image-viewer, hildon-input-method.

I want thumbnailer and tracker to run, so renice to +19 and call it a day.

Also who do I have to renice to get a bl0w...the process that deals with teh phone, what is his nice and can I crank it to the max?

Also what is hawaii's opinion on the mlocker application?

Megaltariak 2011-05-13 21:31

Re: Serious power saving with dbus-scripts and pkill -STOP
 
Simpler, if you don't want default services to be running you can look in /usr/share/applications/hildon/ and open .desktop files (the modest one for example), then comment out with a # these kind of lines:
X-Maemo-Prestarted=always
X-Maemo-Prestarted-Priority=2000

hawaii 2011-05-13 21:52

Re: Serious power saving with dbus-scripts and pkill -STOP
 
Quote:

Originally Posted by vi_ (Post 1005789)
Also who do I have to renice to get a bl0w...the process that deals with teh phone, what is his nice and can I crank it to the max?

Also what is hawaii's opinion on the mlocker application?

omhd already takes care of setting priority for daemons and applications that handle incoming calls.

I use mlocker for the X server and I automatically set hildon-home, hildon-desktop and a few other core processes to FIFO or RR real time status when using the BFS scheduler.

I have no idea why you'd want to stop BME?

dimbert 2011-05-13 22:04

Re: Serious power saving with dbus-scripts and pkill -STOP
 
Any chance of making a script/app that you can choose witch process to stop and setup the trigger behavior!!!

I love my N900 and read all the TMO just for increase my batt life!

Good work you all!

Xagoln 2011-05-14 00:42

Re: Serious power saving with dbus-scripts and pkill -STOP
 
Quote:

Originally Posted by Megaltariak (Post 1005797)
Simpler, if you don't want default services to be running you can look in /usr/share/applications/hildon/ and open .desktop files (the modest one for example), then comment out with a # these kind of lines:
X-Maemo-Prestarted=always
X-Maemo-Prestarted-Priority=2000

Thanks for the tip.

Some of these services, like scim-panel-gtk, are very useful to have when using the phone interactively. And totally redundant when the device is locked.

Also, I'd be weary of dsme/watchdog. Out of ignorance, a few weeks ago I renamed the actual browserd executable, frustrated that it would always run and seemed to often keep my CPU busy even when I'd closed all my browser windows. The dsme rebooted the phone within 5 seconds, and I ended up with a reboot loop.

Would adjusting those values satisfy dsme and stop it rebooting?

hawaii 2011-05-14 01:58

Re: Serious power saving with dbus-scripts and pkill -STOP
 
As far as I know, the best option would be to setting R&D mode and disabling the watchdog lifeguards. There's no apparent side-effect for me, for the past few months.

Keep in mind, browserd renders rtcom-messaging windows among other things.

Xagoln 2011-05-17 03:59

Re: Serious power saving with dbus-scripts and pkill -STOP
 
I've been running for several days with dbus-scripts suspending SCIM, browserd and image-viewer.

Just thought of something for users of mscimswitcherstatus - if you have mscimswitcherstatus suspending SCIM when not needed, my dbus-scripts config above will wake it up each time the phone is unlocked. I think an updated script to check if MSCIM is enabled (by mscimswitcherstatus) before waking its process would be the best solution.

erendorn 2011-06-05 12:22

Re: Serious power saving with dbus-scripts and pkill -STOP
 
somehow related:
I tried to pause nokia maps, because "battery drain", but "forever to load".
Yet the GPS is still on. Is there a way to stop/start GPS tracking, so I can really stop consumption while having maps ready at hand?

kayamagan 2011-06-09 02:11

Re: Serious power saving with dbus-scripts and pkill -STOP
 
i thought why not made an app which gathering this script (power saving) and the script "Tweaks To Speed UP N900": http://talk.maemo.org/showthread.php?t=73315&page=27

one .deb will be better for many people.

thank

F2thaK 2011-06-09 03:16

Re: Serious power saving with dbus-scripts and pkill -STOP
 
how do you tell if this works?

I had to create the folder "/usr/local/share/dbus-scripts/"

and when doing step "killall dbus-scripts" I got error saying

Code:

$ killall dbus-scripts
killall: cannot kill pid 793: Operation not permitted
killall: cannot kill pid 1668: Operation not permitted
killall: cannot kill pid 1752: Operation not permitted
killall: cannot kill pid 1766: Operation not permitted
killall: cannot kill pid 1782: Operation not permitted
killall: cannot kill pid 1809: Operation not permitted
~ $


dtparikh 2011-06-09 04:29

Re: Serious power saving with dbus-scripts and pkill -STOP
 
Did anyone try out the dbus-script? please let us know the power saving improvements and if its worth installing.

I already have about 8-10 scripts/apps that save power, increase battery life and speed up N900 ! probably each and every thread that talks about these , have been implemented and now wonder if they are conflicting internally due to which i dont see a significant change !

F2thaK 2011-06-09 04:59

Re: Serious power saving with dbus-scripts and pkill -STOP
 
smart reflex is best method to save battery power, but I have all mods installed.

installed this one today, not sure it worked.. but will test

JorgeFX 2011-06-18 10:55

Re: Serious power saving with dbus-scripts and pkill -STOP
 
how many hours did you consider you gain with this script?

F2thaK 2011-06-18 11:02

Re: Serious power saving with dbus-scripts and pkill -STOP
 
since the 9th noticed no improvement. smart reflex is by far the best way to prolong battery

vi_ 2011-06-18 12:01

Re: Serious power saving with dbus-scripts and pkill -STOP
 
Quote:

Originally Posted by F2thaK (Post 1031357)
since the 9th noticed no improvement. smart reflex is by far the best way to prolong battery

Agreed, furthermore I suspect that using dbus-scripts to kill process to save power is a case of 2 steps forward, 3 steps back.

Most processes on the n900 are well behaved and 'sleep' while not doing anything. This means they have very little impact on system load. dbus-scripts however has to wake up every time there is a dbus event to check to see if it matches one of it's scripts. If you have ever looked at dbus-monitor you will see there are a quite a lot of them! especially when changing cell reception power.

tl;dr I suspect dbus-scripts cause more system load checking to see if it needs to run a script in response to an event than the processes you are trying to kill.

F2thaK 2011-06-19 02:18

Re: Serious power saving with dbus-scripts and pkill -STOP
 
yes, how do safely and full get rid of this? thx

edit: I just deleted all 3 files...

Xagoln 2011-07-11 04:23

Re: Serious power saving with dbus-scripts and pkill -STOP
 
Quote:

Originally Posted by vi_ (Post 1031376)
tl;dr I suspect dbus-scripts cause more system load checking to see if it needs to run a script in response to an event than the processes you are trying to kill.

Before even posting this thread I ran PowerTop, and my CPU wakeups were reduced over leaving MSCIM running. Here's an example powertop output:

Code:

Powertop 1.13.3
Sleeping for 11 seconds before sampling
Collecting data for 30 seconds
Sample interval was 00m 30s 28717us

C#      | Ratio  | Avg/dura | Frequency | Ratio
--------+--------+----------+-----------+--------+
    C0 |  1.5% |          |  1150 MHz |  nan% |
    C1 |  0.0% |    0.1ms |
    C2 |  0.4% |    1.0ms |
    C3 |  0.6% |  93.1ms |
    C4 |  97.5% | 1330.3ms |

IRQ#    | Activity  | Type          | Name
--------+------------+----------------+---------------------------
    56 |      2777 |          INTC | i2c_omap
    37 |        66 |          INTC | gp
    57 |        61 |          INTC | i2c_omap
    11 |        55 |          INTC | prcm

PID#    | Activity  | Name          | Function Entry (Expire)
--------+------------+----------------+---------------------------
    750 |        33 |      bme_RX-51 | sys_timer_settime (posix_timer_fn)
    38 |        23D|            awk | cpufreq_governor_dbs (delayed_work_timer_fn)
      0 |        18 |  <kernel core> | tick_nohz_restart_sched_tick (tick_sched_timer)
    750 |        18 |      bme_RX-51 | schedule_timeout (process_timeout)
      1 |          3 |  <kernel core> | queue_delayed_work (delayed_work_timer_fn)
    750 |          2 |      bme_RX-51 | do_nanosleep (hrtimer_wakeup)
    714 |          2 |          dsme | do_nanosleep (hrtimer_wakeup)
    714 |          2 |          dsme | __enqueue_rt_entity (sched_rt_period_timer)
  1086 |          2D|<kernel module> | queue_delayed_work (delayed_work_timer_fn)
      0 |          1 |  <kernel core> | hrtimer_start (tick_sched_timer)
  1338 |          1 |    hildon-home | schedule_hrtimeout_range (hrtimer_wakeup)
  1733 |          1 |      powertop | do_nanosleep (hrtimer_wakeup)

Power domain activity breakdown
Domain  | % of time spent in states
--------+---------+---------+---------+---------+----------
usbhost |OFF: 100%|RET:  0%|INA:  0%| ON:  0%| now:(OFF)
    sgx |OFF: 100%|RET:  0%|INA:  0%| ON:  0%| now:(OFF)
    per |OFF:  98%|RET:  0%|INA:  0%| ON:  1%| now:(ON)
    dss |OFF: 100%|RET:  0%|INA:  0%| ON:  0%| now:(OFF)
    cam |OFF: 100%|RET:  0%|INA:  0%| ON:  0%| now:(OFF)
  core |OFF:  97%|RET:  0%|INA:  0%| ON:  1%| now:(ON)
  neon |OFF:  97%|RET:  0%|INA:  0%| ON:  1%| now:(ON)
    mpu |OFF:  97%|RET:  0%|INA:  0%| ON:  1%| now:(ON)
  iva2 |OFF: 100%|RET:  0%|INA:  0%| ON:  0%| now:(OFF)

  iva2 |OFF: 100%|RET:  0%|INA:  0%| ON:  0%| now:(OFF)

Clock activity breakdown at end of period
Domain  | Active clocks
--------+---------------+---------------+------------------
  core |          SDRC | HSOTGUSB_IDLE |      OMAPCTRL
        |    MAILBOXES |
  wkup |          GPT1 |      32KSYNC |        GPIO1
        |
  ckgen |          CORE |          PERI |          96M
        |          48M |          12M |          54M
        |      EMU_CORE |
    per |        GPIO2 |        GPIO3 |        GPIO4
        |        GPIO5 |        GPIO6 |

Total wakeups  3065, 102.2/s | IRQ 2959,  98.6/s | Timers  106,  3.5/s
HW wakeups      55,  1.8/s |    Real gp_timers expired  66,  2.2/s

Now, obviously the overhead of dbus-scripts will exceed the resource usage of some, maybe most, processes/applications. That does not mean that there are no use cases for this idea.

karam 2011-09-04 17:57

Re: Serious power saving with dbus-scripts and pkill -STOP
 
i want your opinion guys
does this save power or not ? (at least a bit)


All times are GMT. The time now is 04:56.

vBulletin® Version 3.8.8