g-p-m should use less frequent disk writes

Bug #315970 reported by ThePhilips on 2009-01-11
42
This bug affects 6 people
Affects Status Importance Assigned to Milestone
gnome-power
In Progress
Medium
gnome-power-manager (Ubuntu)
Low
Unassigned

Bug Description

Binary package hint: gnome-power-manager

During investigations on what keeps waking up hard drive of my laptop, I have found (using "pidstat -d" + "strace") that gnome-power-manager writes what looks like actual state of battery to $HOME/.gnome2/gnome-power-manager about every 90 seconds.

That needs to be fixed. If system is on battery and is idle, then no intentional disk spinning should be happening.

Otherwise it is very silly: the modules which monitor battery charge cause the battery to discharge.

If information doesn't need to be persistent, then g-p-m should at least send the information to /tmp, which is often mounted using tmpfs.

That would eliminate at least one of the reasons why my hdd keeps spinning under Linux.

P.S. Ubuntu 8.04 with XFCE on PowerBook 12". Actually "pbbuttond" causes similar problem since on the platform it is the daemon which produces the battery status info into /var/lib/ibam/ directory.

Pedro Villavicencio (pedro) wrote :

Thanks for taking the time to report this bug and helping to make Ubuntu better. Could you please attach the resulting log file of: gnome-power-bugreport.sh &> gpm.log to the report? You might also want to take a look to the Debugging instructions located at https://wiki.ubuntu.com/DebuggingGNOMEPowerManager for submit any other logs related to your problem.Thanks in advance.

Changed in gnome-power-manager (Ubuntu):
importance: Undecided → Low
status: New → Incomplete
Pedro Villavicencio (pedro) wrote :

We are closing this bug report because it lacks the information we need to investigate the problem, as described in the previous comments. Please reopen it if you can give us the missing information, and don't hesitate to submit bug reports in the future. To reopen the bug report you can click on the current status, under the Status column, and change the Status back to New. Thanks again!.

Changed in gnome-power-manager (Ubuntu):
status: Incomplete → Invalid
m4cph1sto (dlreid) wrote :

This bug exists in Jaunty. On battery power, gnome-power-manager writes to disk approx. every 90 seconds, causing my hard drive to never remain spun down. I will post additional info in the comments.

Changed in gnome-power-manager (Ubuntu):
status: Invalid → New
m4cph1sto (dlreid) wrote :

Attached is a typical output of iotop, polling every 10 seconds, on battery power, showing that gnome-power-manager is writing to disk every minute or so. This is obviously detrimental to battery life and hard drive longevity, so gnome-power-manager should not behave in this way.

m4cph1sto (dlreid) wrote :

I can find no gnome-power-bugreport.sh on my system. Is this script still included with Ubuntu Jaunty? Attached is my output of "gconftool --recursive-list /apps/gnome-power-manager".

m4cph1sto (dlreid) wrote :

I found gnome-power-bugreport.sh in /usr/share/gnome-power-manager. I've attached the output.

m4cph1sto (dlreid) wrote :

I can confirm that, on my system, about every 90 seconds gnome-power-manager is writing to the file:

$/HOME/.gnome2/gnome-power-manager/profile-G71C0001W210-38880-0000000193-discharging.csv

While it may be nice for some people to have g-p-m provide a battery discharging graph, personally I think this is a bug because this behavior prevents the hard drive from spinning down and thus shortens battery life and may lead to early hard drive failure.

ThePhilips (thephilips) wrote :

m4cph1sto, thanks for the information. I - reporter - already have removed g-p-m from my system so couldn't provide the info.

> personally I think this is a bug because this behavior prevents the hard drive from spinning down and thus shortens battery life

Very true.

> and may lead to early hard drive failure.

Not true. HDD are made for constant spinning. They can spin for several many month constantly without problems.
In fact, spin-down & spin-up cycle is limited "resource" and does shorten life of HDDs. Negligibly, yet it does. (I heard laptop HDDs are tested for something like 100K spin-down-spin-up cycles.)

But of course in context of laptops, this is clear bug.

My personal problems are: battery life and heat. In fact, I'd say heat is bigger issue than battery life. As hard drive spins constantly, my notebook (namely the part where HDD is) heats up so much that I cannot keep it on my lap anymore.

m4cph1sto (dlreid) wrote :

>> and may lead to early hard drive failure.
> Not true. HDD are made for constant spinning. They can spin for several many month constantly without problems.

Actually I misspoke: in my case, g-p-m is causing excessive spin-down & spin-up cycles, not preventing it from spinning down. On battery, my HDD spins down after about 20 seconds of inactivity. Then 60 seconds later g-p-m writes to disk and causes it to spin up. Then 20 seconds later it spins down again... and repeat.

Therefore, for me the title of this bug should be "g-p-m causing excessive HDD spin cycles". The bug is the same as you observed, but the effect seems to be different depending on your HDPARM or other HDD settings while on battery.

Scott Howard (showard314) wrote :

Thanks for reporting this bug and helping make Ubuntu better. The bug you have mentioned has been debated by the developers, and they have decide to not fix the bug. There reasoning is explained below, and can be found at:
http://live.gnome.org/GnomePowerManager/FAQ#head-e6d48e4196eb363908fb71975a5311f11f8dd9e4
Please report any additional bugs that you find!

GNOME Power Manager doesn't spin down my hard-drive!

After numerous debates, the consensus was that is was not a good idea to add this functionality to HAL. It's was decided user-configurable powermanagement was not really required when modern hard disks have really intelligent powermanagment.

A disk on Low Power idle need less than 1 Watt per hour. For a normal battery with 50000mWh you could run the harddisk for over 50 hours. If you do not read/write from/to the harddisk the disk regulates power, but never shuts down the device. The reason is easy: you lost more power with each startup than to leave the harddisk online somewhere between 'Active idle' and 'Low power idle' (depends on the model/manufacturer). The other reason to leave this to the internal powermanagement of the disk is: the time needed to reactivate the device. You lose more performance than you lose power between 'Active idle' and 'Low power idle'. If you use a journaling file system you normally need to flush periodically. This could run in a race between shut down device and restart device by system to flush. This means more power consumption as you change nothing. You can't set powermanagement for exteral USB harddisks, because you can't send the needed commands over the USB link to the disk.

Changed in gnome-power-manager (Ubuntu):
status: New → Won't Fix
ThePhilips (thephilips) wrote :

Thanks for the /answer/, Scott. In the end, those two days I spent cleaning my system of the Gnome were not a waste of time. Design by committee rules.

m4cph1sto (dlreid) wrote :

Scott thanks for the info but I believe you have misidentified the problem. The bug I reported has nothing to do with G-P-M's ability to control hard drive power management, or lack thereof. The problem is that G-P-M is writing to the disk about once per minute, for the frivolous purpose of recording battery discharge history. This in itself prevents the hard drive from taking advantage of its internal power management capabilities.

The situation becomes much worse if users are following the common practice of enabling Laptop Mode, which tells the hard drive spin down after periods of inactivity. In this case G-P-M's frequent disk writes cause many spin-up/spin-down cycles, which can lead to premature hard drive failure.

The title of this bug "g-p-m keeps disk spinning" is a misnomer, because the actual bug has nothing to do with disk spinning, it is the frequent disk writes, which depending on other configuration settings can either just be annoying, or can cause serious problems for the laptop hard drive.

Forgive me if I'm wrong about this, but I think everything I wrote is correct.

Scott Howard (showard314) wrote :

Thanks for explaining this. The problem is the GPM relies on writing to the HD to keep track of power history, which causes a lot of disk writes. This isn't a bug in that it wastes energy, but that it causes disk activity. Marking as confirmed and wishlist since

This should be sent directly to the upstream authors at bugzilla.gnome.org, for forwarding instructions please have a look to http://wiki.ubuntu.com/Bugs/Upstream/GNOME. If you forward the bug, please post a link to the upstream bug report here. Also, mention how your bug is different than what is written in the FAQ I linked, so they don't dismiss it for that reason. Thanks in advance.

summary: - g-p-m keeps disk spinning
+ g-p-m should use less frequent disk writes
Changed in gnome-power-manager (Ubuntu):
status: Won't Fix → Confirmed

Hi Scott,

On Sun, Jul 12, 2009 at 01:31:57AM -0000, Scott Howard wrote:

> Thanks for explaining this. The problem is the GPM relies on writing to
> the HD to keep track of power history, which causes a lot of disk
> writes. This isn't a bug in that it wastes energy, but that it causes
> disk activity. Marking as confirmed and wishlist since
>
> This should be sent directly to the upstream authors at
> bugzilla.gnome.org, for forwarding instructions please have a look to
> http://wiki.ubuntu.com/Bugs/Upstream/GNOME. If you forward the bug,
> please post a link to the upstream bug report here. Also, mention how
> your bug is different than what is written in the FAQ I linked, so they
> don't dismiss it for that reason. Thanks in advance.
>
> ** Summary changed:
>
> - g-p-m keeps disk spinning
> + g-p-m should use less frequent disk writes

The problem is not that g-p-m is writing to disk often; the problem is
that it is writing to disk *and* calling fsync().

Take for instance the laptop-mode-tools suite -- it enables a feature
of the Linux kernel that will keep all recent disk writes in memory
and then write to disk all of them at once at fixed intervals. So,
if an application tries to write to disk, that write does not happen
immediately. This has the benefit that the hard disk can spindown for
several minutes and there is guarantee that it will not spinup before
the next scheduled batch write operation (unless of course something
needs to be read from the disk.)

Now, if the application or a library it uses calls the fsync() system
call then the disk will be woken up before the next scheduled batch
write operation. This is what is happening with g-p-m -- when writing to
these files that keep power history something is calling fsync(). This
is what should be looked into.

g-p-m is not the only application that has this problem; Firefox itself
has it (or had it; it is not clear to me whether they've fixed the
issue.) The following Firefox bug explains the issue in detail:

https://bugzilla.mozilla.org/show_bug.cgi?id=421482

And this blog entry from one of the Firefox developers has a lot of
great information about the issue in Firefox:

http://shaver.off.net/diary/2008/05/25/fsyncers-and-curveballs/

I searched upstream Bugzilla and didn't find any bug about this issue on
g-p-m so we definitely need to make sure upstream knows about the issue.

With regards to the FAQ you mentioned, it seems like upstream has
changed their mind with regards to support for hard disk spindown in
g-p-m. See this g-p-m bug:

http://bugzilla.gnome.org/show_bug.cgi?id=586582

Cheers,

Eloy Paris.-

Scott Howard (showard314) wrote :

Great, thanks for explaining it. I saw some gnome git commits talking about hard drive spinning down too - it seems like they are actively working on it. Great job finding the upstream report and for adding to their conversation!

Changed in gnome-power-manager (Ubuntu):
status: Confirmed → Triaged
Eloy Paris (peloy-chapus) wrote :

On Tue, Jul 14, 2009 at 02:24:58AM -0000, Scott Howard wrote:

> Great, thanks for explaining it. I saw some gnome git commits talking
> about hard drive spinning down too - it seems like they are actively
> working on it. Great job finding the upstream report and for adding to
> their conversation!

No problem; happy to help.

The g-p-m maintainer made a comment in Gnome's Bugzilla #586582. He said
that g-p-m should only be doing the fsync()'s when batter is low, but
since that is not what I am seeing I filed a new bug in their Bugzilla:

Bug 588596 – g-p-m calls fsync() after writing power history data

http://bugzilla.gnome.org/show_bug.cgi?id=588596

I attached an strace showing the fsync() every 150 seconds.

Guess we'll find out soon whether it's a bug or a "feature"...

Cheers,

Eloy Paris.-

Changed in gnome-power:
status: Unknown → In Progress
Changed in gnome-power:
importance: Unknown → Medium
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.