From Fedora Project Wiki
(accepted by FESCo on 2009-02-06)
m (internal link cleaning)
 
(61 intermediate revisions by 9 users not shown)
Line 2: Line 2:


== Summary ==
== Summary ==
Improve the current state of power management, especially in regard to userland.  
Our goal is the improvement of power management especially in regard to userland. This project is based on ''measurement'' and ''statistic'' of power consumption mainly on laptops. We are trying to locate the main power greedy applications by measuring with new tools, which have been introduced in our project. Our measurements led to ''tuned daemon'' which can automatically set the power saving levels.


== Owner ==
== Owner ==
* Phil Knirsch <pknirsch@redhat.com> (Lead, tuned, monitoring, documentation)
* Phil Knirsch <pknirsch@redhat.com> (Lead, tuned, monitoring, documentation)
* Jiri Skala <jskala@redhat.com>(BLTK packager)
* Jiri Skala <jskala@redhat.com>(BLTK packager)
* Marcela Maslanova <mmaslano@redhat.com> (initscript/udev service start/stop automation)
* Marcela Maslanova <mmaslano@redhat.com> (initscript/udev service start/stop review)
* Petr Lautrbach <plautrba@redhat.com> (initscript/udev service start/stop automation)
* Jan Scotka <jscotka@redhat.com> (QA coverage)
* Karel Volny <kvolny@redhat.com> (QA coverage)


== Current status ==
== Current status ==
* Targeted release: [Fedora 11]  
* Targeted release: [[Releases/11|Fedora 11]]  
* Last updated: (02/05/09)
* Last updated: 04/17/09
* Percentage of completion: 15%
* Percentage of completion: 100%


== Detailed Description ==
== Detailed Description ==
Power management and power saving in Fedora has been a topic is special areas over the last few releases. Using powertop especially for Fedora 9 quite a few improvements were already done, but there is still lots of things that haven't been touched in regard to power saving.
Power management and power saving in Fedora have been a topic in special areas over the last few releases. Using powertop especially for [[Releases/9|Fedora 9]] quite a few improvements were already done, but there is still lots of things that haven't been touched in regard to power saving.
 
New packages, which can be used to measure the power consumption of a system, have been introduced:
* bltk with various user cases
* tuned-utils - diskdevstat & netdevstat for more enhanced statistic inspired by powertop
 
Also a new package will be able to set the power saving levels:
* tuned: The tuned daemon will be setting disk and network power saving levels for Fedora. Tuned can be enhanced by new plugins, which could be goals for next Fedora releases.


== Benefit to Fedora ==
== Benefit to Fedora ==
Line 21: Line 31:


== Scope ==
== Scope ==
* Review and fix behaviour of typical applications in a full installed Fedora in regard to:
* Review and fix behaviour of typical applications in a full installed Fedora in regard to: [DONE] -> for F-12 it could be reviewed again
** CPU wakeups
** CPU wakeups
** Disk IO
** Disk IO
** Network IO
** Network IO
* Add a workload measurement package to Fedora (BLTK adapted to Fedora use case)
* Add a workload measurement package to Fedora (BLTK adapted to Fedora use case) [DONE]
* Enable relatime for filesystem by default during installation
* Enable relatime for filesystem by default during installation [DONE]
* Write a monitoring and tuning daemon that adapts system settings to the current use
* Write a monitoring and tuning daemon that adapts system settings to the current use [DONE]
** http://fedorapeople.org/gitweb?p=pknirsch/public_git/tuned.git;a=summary
** git://fedorapeople.org/~pknirsch/tuned.git/
* Review services and make a framework that will allow services to start depending on installed hardware or software
* Review services and make a framework that will allow services to start depending on installed hardware or software [DONE]
* Provide scripts and documentation to perform an individual review of a system and tips & tricks on how to improve it
* Provide scripts and documentation to perform an individual review of a system and tips & tricks on how to improve it [DONE]
** http://fedorapeople.org/gitweb?p=pknirsch/public_git/tuned.git;a=summary
** git://fedorapeople.org/~pknirsch/tuned.git/
* Review all [[Features/PowerManagement/initscripts | init scripts]], whether some of services could be switch off in case they are not needed [DONE]
** hardware is not available and service is running without reason <strike>rhbz#[https://bugzilla.redhat.com/show_bug.cgi?id=484345 484345]</strike> [POSTPONED to F-12]


== Test Plan ==
== Test Plan ==
The test plan for Test Day could be find here: [[QA/Test_Days/2009-04-02|Test Days]]
=== For power measurement ===
=== For power measurement ===
# Default installation of a specific release to test
# Default installation of a specific release to test
Line 57: Line 70:
(1) In order to be able to see the actual power usage of the test machine you need to have some form of power measurement equipment. This can be either an external wattmeter or you can use a laptop as testmachine and run the tests on battery power.
(1) In order to be able to see the actual power usage of the test machine you need to have some form of power measurement equipment. This can be either an external wattmeter or you can use a laptop as testmachine and run the tests on battery power.


(2) Both can be found in the contrib/ directory of the tuned git repo: http://fedorapeople.org/gitweb?p=pknirsch/public_git/tuned.git;a=summary which can be cloned using git clone git://fedorapeople.org/~pknirsch/tuned.git
(2) Both can be found in the contrib/ directory of the tuned git repo: http://fedorapeople.org/~pknirsch/git/tuned.git/ which can be cloned using git clone git://fedorapeople.org/~pknirsch/tuned.git
 
=== Fedora Test Day scheduled for 04/02/2009 ===
 
In order to allow a larger audience to actively participate we will be holding a Fedora Test Day [1]. We will update the information about the Test Day here: https://fedoraproject.org/wiki/QA/Test_Days/2009-04-02
 
[1] https://fedoraproject.org/wiki/QA/Test_Days/F11
 
=== Functionality test ===
 
* For "Review and fix behaviour of typical applications in a full installed Fedora in regard to":
** yum install powertop tuned-utils kernel-devel kernel-debuginfo
** run
*** diskdevstat
*** netdevstat
*** powertop
* For "Add a workload measurement package to Fedora (BLTK adapted to Fedora use case)"
** yum install bltk
** run
*** bltk -O
*** bltk -R
*** bltk -P
*** bltk -i
* For "Enable relatime for filesystem by default during installation"
** Check if relatime is enabled for / with
*** cat /proc/mounts | grep relatime
* For "Write a monitoring and tuning daemon that adapts system settings to the current use"
** yum install tuned
** service tuned start
** disk and net devices should adapt to usage
* For "Provide scripts and documentation to perform an individual review of a system and tips & tricks on how to improve it"
** See documentation in tuned package and on the feature page itself under Documentation section.
* Test [http://plautrba.fedorapeople.org/bluez/how-to-test.txt bluez ] with patch for running service on demand.


== User Experience ==
== User Experience ==
Line 63: Line 108:


== Dependencies ==
== Dependencies ==
* Anaconda changes (for relatime)
* Anaconda/kernel changes (for relatime)
* Fixes need to get included to have an effect (really ;)).
* Fixes need to get included to have an effect (really ;))
* New packages need to get accepted to Fedora


== Contingency Plan ==
== Contingency Plan ==
Make sure none of the more aggressive power saving features breaks on common hardware and back it out it case it does.
Make sure none of the more aggressive power saving features breaks on common hardware and back it out in case it does.


== Documentation ==
== Documentation ==
Line 107: Line 153:
* Don't use [f]sync() if not necessary
* Don't use [f]sync() if not necessary
* Group timers across applications if possible (even systems)
* Group timers across applications if possible (even systems)
* After using lots of malloc() and free() calls run malloc_trim(0) once (unportable)


=== Bugzillas ===
=== Bugzillas ===


* [https://bugzilla.redhat.com/show_bug.cgi?id=454582 Tracker bug for over-eager apps that won't let disks spin down]
* [https://bugzilla.redhat.com/show_bug.cgi?id=484668 Tracker bug for power management efforts]
** [https://bugzilla.redhat.com/show_bug.cgi?id=454574 mono writing to filesystem far too frequently]
** [https://bugzilla.redhat.com/show_bug.cgi?id=229639 gnome-screensaver blank screensaver could tell g-p-m to power off monitor right away to save power]
** [https://bugzilla.redhat.com/show_bug.cgi?id=457155 Tomboy wakes up hard disk frecuently]
** [https://bugzilla.redhat.com/show_bug.cgi?id=464104 hal shouldn't poll for non existent CD drives]
** [https://bugzilla.redhat.com/show_bug.cgi?id=466601 wpa_supplicant writing pointless(?) messages to log every 60s]
**<strike> [https://bugzilla.redhat.com/show_bug.cgi?id=488256 Add improve-relatime.patch to rawhide]</strike>
** [https://bugzilla.redhat.com/show_bug.cgi?id=479192 audit log written whenever cron wakes up, keeps disks spun up]
**<strike> [https://bugzilla.redhat.com/show_bug.cgi?id=487312 Review Request: tuned - A dynamic adaptive system tuning daemon]</strike>
** <strike>[https://bugzilla.redhat.com/show_bug.cgi?id=484345 start the bluetooth service via udev]</strike>
** [https://bugzilla.redhat.com/show_bug.cgi?id=454582 Tracker bug for over-eager apps that won't let disks spin down]
*** [https://bugzilla.redhat.com/show_bug.cgi?id=454574 mono writing to filesystem far too frequently]
*** [https://bugzilla.redhat.com/show_bug.cgi?id=457155 Tomboy wakes up hard disk frecuently]
*** <strike>[https://bugzilla.redhat.com/show_bug.cgi?id=466601 wpa_supplicant writing pointless(?) messages to log every 60s]</strike>
*** [https://bugzilla.redhat.com/show_bug.cgi?id=479192 audit log written whenever cron wakes up, keeps disks spun up]
*** [https://bugzilla.redhat.com/show_bug.cgi?id=488268  Plasma needlessly opening and writing to disk every minute]
** [https://bugzilla.redhat.com/show_bug.cgi?id=204948 Tracker bug for applications waking up a lot]
*** [https://bugzilla.redhat.com/show_bug.cgi?id=204908 Xorg XDPMS extension doesn't seen change events, which forces gnome-power-manager to poll]
*** [https://bugzilla.redhat.com/show_bug.cgi?id=204969 hal polls storage devices]
*** <strike>[https://bugzilla.redhat.com/show_bug.cgi?id=205182 pcsc daemon wakes up once per second for NO REASON]</strike>
*** [https://bugzilla.redhat.com/show_bug.cgi?id=205910 gnome-settings-daemon wakes up for every keypress]
*** [https://bugzilla.redhat.com/show_bug.cgi?id=210019 n-c-b wakes up every 2.5 seconds]
*** [https://bugzilla.redhat.com/show_bug.cgi?id=213042 gnome-terminal cursor defaults to blinking]
*** [https://bugzilla.redhat.com/show_bug.cgi?id=214760 pcsc-lite library causes gdm-daemon to wake up 5+ times per second in the default install]
*** [https://bugzilla.redhat.com/show_bug.cgi?id=227504 nautilus doesn't use gam]
*** [https://bugzilla.redhat.com/show_bug.cgi?id=252129 postgres logger and writer frequent wakeups]
*** [https://bugzilla.redhat.com/show_bug.cgi?id=252140 dovecot processes wake up once a second (each)]
*** [https://bugzilla.redhat.com/show_bug.cgi?id=281001 thunderbird is the process that wakes the cpu up most often on my system]
*** [https://bugzilla.redhat.com/show_bug.cgi?id=335551 abiword wakes up the CPU while doing nothing]
*** [https://bugzilla.redhat.com/show_bug.cgi?id=335591 openoffice.org wakes up the CPU while doing nothing]
*** [https://bugzilla.redhat.com/show_bug.cgi?id=408131 libusb wakes up 1000 times/sec while transfer outstanding]
*** [https://bugzilla.redhat.com/show_bug.cgi?id=426968 nspluginwrapper wakes up too much]
*** [https://bugzilla.redhat.com/show_bug.cgi?id=486111 Transmission causes wakeups by unnecessary polling.]


== Release Notes ==
== Release Notes ==
In order to allow user to monitor the behaviour of their systems and to improve power consumption in general several improvements were done for Fedora 11:
In order to allow users to monitor the behaviour of their systems and to improve power consumption in general, several improvements were done for Fedora 11:


* Provide 2 new systemtap scripts to monitor disk and network activity of running applications
* Provide 2 new systemtap scripts to monitor disk and network activity of running applications
* Add a workload framework package called BLTK to offer reproducible tests
* Add a workload framework package called BLTK to offer reproducible tests
* Improved applications to reduce unecessary disk and/or network activity
* Improved applications to reduce unnecessary disk and/or network activity
* Enabled several new features to save power:
* Enabled several new features to save power:
** relatime option for /
** relatime option for root filesystem /
** Automated start/stop of services related to hardware
** Enable USB autosuspend for known working devices
** Enable USB autosuspend for know working devices
** Add optional ''tuned'' service to dynamically adapt system settings to the current use
** Add optional tuned service to dynamically adapt system settings to the current use


User of Fedora 11 should therefore see a reduction in power usage of their system.
Users of Fedora 11 should therefore see a reduction in power usage of their system.


== Comments and Discussion ==
== Comments and Discussion ==

Latest revision as of 14:04, 18 September 2016

Power Management improvements

Summary

Our goal is the improvement of power management especially in regard to userland. This project is based on measurement and statistic of power consumption mainly on laptops. We are trying to locate the main power greedy applications by measuring with new tools, which have been introduced in our project. Our measurements led to tuned daemon which can automatically set the power saving levels.

Owner

  • Phil Knirsch <pknirsch@redhat.com> (Lead, tuned, monitoring, documentation)
  • Jiri Skala <jskala@redhat.com>(BLTK packager)
  • Marcela Maslanova <mmaslano@redhat.com> (initscript/udev service start/stop review)
  • Petr Lautrbach <plautrba@redhat.com> (initscript/udev service start/stop automation)
  • Jan Scotka <jscotka@redhat.com> (QA coverage)
  • Karel Volny <kvolny@redhat.com> (QA coverage)

Current status

  • Targeted release: Fedora 11
  • Last updated: 04/17/09
  • Percentage of completion: 100%

Detailed Description

Power management and power saving in Fedora have been a topic in special areas over the last few releases. Using powertop especially for Fedora 9 quite a few improvements were already done, but there is still lots of things that haven't been touched in regard to power saving.

New packages, which can be used to measure the power consumption of a system, have been introduced:

  • bltk with various user cases
  • tuned-utils - diskdevstat & netdevstat for more enhanced statistic inspired by powertop

Also a new package will be able to set the power saving levels:

  • tuned: The tuned daemon will be setting disk and network power saving levels for Fedora. Tuned can be enhanced by new plugins, which could be goals for next Fedora releases.

Benefit to Fedora

Simple: On average use less power for turned on machines while not affecting user experience (a lot ;)).

Scope

  • Review and fix behaviour of typical applications in a full installed Fedora in regard to: [DONE] -> for F-12 it could be reviewed again
    • CPU wakeups
    • Disk IO
    • Network IO
  • Add a workload measurement package to Fedora (BLTK adapted to Fedora use case) [DONE]
  • Enable relatime for filesystem by default during installation [DONE]
  • Write a monitoring and tuning daemon that adapts system settings to the current use [DONE]
  • Review services and make a framework that will allow services to start depending on installed hardware or software [DONE]
  • Provide scripts and documentation to perform an individual review of a system and tips & tricks on how to improve it [DONE]
  • Review all init scripts, whether some of services could be switch off in case they are not needed [DONE]
    • hardware is not available and service is running without reason rhbz#484345 [POSTPONED to F-12]

Test Plan

The test plan for Test Day could be find here: Test Days

For power measurement

  1. Default installation of a specific release to test
  2. Run several workload tests:
    1. Not logged in, gdm
    2. Logged in, start Firefox, Thunderbird and Openoffice
    3. Run a httpd server on it with a fixed index.html (http://pknirsch.fedorapeople.org/PM/index.html) and run the following script from a separate machine:
for i in seq 59 -2 0; do ab -t $((60-$i)) -c 32 http://myhost/index.html; sleep $i; done > result.txt
  1. For each workload run the following script on the test machine (1):
for i in seq 31; do date; powertop -d -t 60; done > restult.txt
  1. Alternatively you can use the latest version of DeviceKit-power and run the following:
for i in seq 31; do date; devkit-power --wakeups; done > restult.txt

For monitoring application behaviour

  1. Default installation of a specific release to test
  2. Run on of the following tools/scripts:
    1. Powertop or the latest gnome-power-manager to identify application wakeups
    2. netdevstat.stp to identify applications network behaviour (2)
    3. diskdevstat.stp to identify applications disk behaviour (2)

(1) In order to be able to see the actual power usage of the test machine you need to have some form of power measurement equipment. This can be either an external wattmeter or you can use a laptop as testmachine and run the tests on battery power.

(2) Both can be found in the contrib/ directory of the tuned git repo: http://fedorapeople.org/~pknirsch/git/tuned.git/ which can be cloned using git clone git://fedorapeople.org/~pknirsch/tuned.git

Fedora Test Day scheduled for 04/02/2009

In order to allow a larger audience to actively participate we will be holding a Fedora Test Day [1]. We will update the information about the Test Day here: https://fedoraproject.org/wiki/QA/Test_Days/2009-04-02

[1] https://fedoraproject.org/wiki/QA/Test_Days/F11

Functionality test

  • For "Review and fix behaviour of typical applications in a full installed Fedora in regard to":
    • yum install powertop tuned-utils kernel-devel kernel-debuginfo
    • run
      • diskdevstat
      • netdevstat
      • powertop
  • For "Add a workload measurement package to Fedora (BLTK adapted to Fedora use case)"
    • yum install bltk
    • run
      • bltk -O
      • bltk -R
      • bltk -P
      • bltk -i
  • For "Enable relatime for filesystem by default during installation"
    • Check if relatime is enabled for / with
      • cat /proc/mounts | grep relatime
  • For "Write a monitoring and tuning daemon that adapts system settings to the current use"
    • yum install tuned
    • service tuned start
    • disk and net devices should adapt to usage
  • For "Provide scripts and documentation to perform an individual review of a system and tips & tricks on how to improve it"
    • See documentation in tuned package and on the feature page itself under Documentation section.
  • Test bluez with patch for running service on demand.

User Experience

As power saving is not really visible without a measuring it the effects will not be directly visible. So in order to really see the effect you'll either need a laptop and run that on battery power or a wattmeter that is hooked between your system and the power line.

Dependencies

  • Anaconda/kernel changes (for relatime)
  • Fixes need to get included to have an effect (really ;))
  • New packages need to get accepted to Fedora

Contingency Plan

Make sure none of the more aggressive power saving features breaks on common hardware and back it out in case it does.

Documentation

Simple user tips for improving power usage

  • Use a properly dimensioned system for the job (no need for overpowered systems for simple Desktop use e.g.)
  • For servers consolidate services on fewer systems to maximize efficiency of each system
  • Enforce turning of systems that are not used (e.g. company policy)
  • Unplug and/or turn of peripherals that aren't used (e.g. external USB devices, monitors, printers, scanners)
  • Turn of unused hardware already in BIOS.
  • Disable power hungry features.
  • Enable CPU scaling if supported for ondemand CPU governor. DONT use powersave governor, typically uses more power than ondemand (race to idle).
  • Put network card to 100 mbit/10 mbit:
    • 10 mbit: ethtool -s eth0 advertise 0x002
    • 100 mbit: ethtool -s eth0 advertise 0x008
    • Doesn't work for every card
  • Put harddisk to spindown fast and full power saving:
    • hdparm -S240 /dev/sda (20m idle to spindown)
    • hdparm -B1 /dev/sda (Max powersave mode)
  • Make sure writes to hd don't wake it up too quickly:
    • Set flushing to once every 5 minutes
    • echo "30000" > /proc/sys/vm/dirty_writeback_centisecs
    • Enable laptop mode
    • echo "5" > /proc/sys/vm/laptop_mode
  • Use relatime for your / partition
    • mount -o remount,relatime /
  • Disable CD-ROM polling from HAL (prevents popups when a CD is inserted):
    • hal-disable-polling --device /dev/scd0
  • Enable USB autosuspend by adding the following to the kernel boot commandline:
    • usbcore.autosuspend=5
  • Screensaver needs to dpms off the screen, not just make colors black. To turn of monitor after 120s when X is running:
    • xset dpms 0 0 120

Simple programmer tips for improving power usage

  • Wake up only when necessary
  • Do not poll in programs or use short regular timeouts, rather react to events
  • If you wake up, do everything at once (race to idle)
  • Use large buffers to avoid frequent disk access. Write one large block at a time
  • Don't use [f]sync() if not necessary
  • Group timers across applications if possible (even systems)
  • After using lots of malloc() and free() calls run malloc_trim(0) once (unportable)

Bugzillas

Release Notes

In order to allow users to monitor the behaviour of their systems and to improve power consumption in general, several improvements were done for Fedora 11:

  • Provide 2 new systemtap scripts to monitor disk and network activity of running applications
  • Add a workload framework package called BLTK to offer reproducible tests
  • Improved applications to reduce unnecessary disk and/or network activity
  • Enabled several new features to save power:
    • relatime option for root filesystem /
    • Enable USB autosuspend for known working devices
    • Add optional tuned service to dynamically adapt system settings to the current use

Users of Fedora 11 should therefore see a reduction in power usage of their system.

Comments and Discussion