Slashdot Mirror


Spotlight's Impact on PowerBook Battery Life?

Viltvodlian Deoderan asks: "So, Spotlight for Mac OS X Tiger is very cool. I can now let my innate ability to disorganize things shine through. However, when using my PowerBook unplugged, it seems that my battery lasts a noticeably less time. A close reading of Ars Technica's description of how spotlight works suggests that this is due to keeping the index file up-to-date on disk. Has anyone else noticed the same thing? Does someone have a better explanation for why my battery seems to drain out, prematurely? Is there some way real-time indexing can be turned off to conserve power?"

36 of 161 comments (clear)

  1. What do you consider an average load? by andrewski · · Score: 2, Informative

    Depending on the time of day and what you are doing with your computer, power consumption varies a lot. It'd be difficult to even establish a reliable baseline usage time per charge.

    After you install, files are indexed as they are written. It really takes very cpu time or other resources to do this. If you don't believe me do some performance profiling.

    If you did an upgrade install, you are already working with a sorely fragmented disk. Additionally, batteries age. Maybe it's these two factors that are causing your batteries to seem like they are giving out early.

    1. Re:What do you consider an average load? by Jord · · Score: 4, Informative

      1. Open spotlight preferences, select privacy tab
      2. Open finder window
      3. Select go to folder in the finder menu
      4. Type /tmp
      5. Drag tmp folder to privacy list in spotlight preferences tab.
      6. profit!

  2. Too bad my battery blows by MyDixieWrecked · · Score: 2, Informative

    I actually noticed that my battery is lasting much, much less time, lately, but I've been attributing that to the fact that it's almost 3 years old and hasn't had the life that it used to when it was young.

    I wish there was a way of disabling spotlight during certain times. especially when I'm running a script that's creating dozens of files only to trash them again later. I think it's taking a bit of a performance hit from spotlight.

    --



    ...spike
    Ewwwwww, coconut...
    1. Re:Too bad my battery blows by Anonymous Coward · · Score: 1, Informative

      if you're using carbon, set the kioFCBTemporaryFileBit bit in the ioFCBFlags parameter. That will prevent indexing.

    2. Re:Too bad my battery blows by justMichael · · Score: 2, Informative
      I wish there was a way of disabling spotlight during certain times. especially when I'm running a script that's creating dozens of files only to trash them again later. I think it's taking a bit of a performance hit from spotlight.
      Assuming your script always creates it's files in the same location, add that location to the privacy tab in Spotlight prefs. It should then ignore that directory.

      Here's some more info
    3. Re:Too bad my battery blows by Mikey-San · · Score: 3, Informative

      What if his script is deployed on machines he has no direct control over? (Say, he's writing the script for people to download.)

      Original poster: I'm not sure what the purpose of your script is, but if you can, create a temporary folder called "MyScriptFiles.noindex" and write your temp files to that instead. Folders with a ".noindex" suffix don't get indexed by SpotDark.

      --
      Mikey-San
      Karma: +Eleventy billion (mostly affected by watching Celebrity Jeopardy)
  3. Spotlight? Could be anything by topham · · Score: 1, Informative


    Spotlight doesn't do that much work that I would honestly expect it to significantly impact battery life.

    Perhaps if you used spotlight to find all your files, as it would take some effort to search the index and list all the files. But I doubt you search for that many files in a session.

    It is far more likely there is another process which is effecting battery life, or your battery is starting to show some wear and tear.

    1. Re:Spotlight? Could be anything by ActionGaz · · Score: 4, Informative
      I believe it's correctly attributed to Spotlight, as every now and again, even when the machine is sitting plugged in and resting on my kitchen counter, I can hear it whirl it's harddisk as if it's indexing.
      That's not how Spotlight works. When you first installed Tiger it needed to go through all the existing files and index them, but that process is surely done by now.

      All it does now is respond to new files being created or files being changed. It doesn't need to scan for these as it is told directly by the operating system when the changes take place.

      The constant disk access must be some other process.

  4. To answer your question by amichalo · · Score: 4, Informative

    From here:
    To turn indexing on or off for a volume, run sudo mdutil -i on volume name or sudo mdutil -i off volume name, respectively. For example, if you want to turn off indexing for a volume called Backup, the command would be sudo mdutil -i off /Volumes/Backup .

    Now to give you some grief about it:
    This is pretty basic stuff - the less the hardware is used, the less power it will consume. If Spotlight, or any other app, is accessing the disk, then it will need power to do so. Likewise, if Spotlight is doing a bunch of searching through it's index that has to be loaded into RAM from the disk and those queries must be computed by the OS, then the disk and OS and RAM are all getting a workout.

    What I recommend is that you check out what it is you are doing. If you are copy and moving files all over the place, or mounting and unmounting CDs, those processes would cause HD/CD usage as well as Spotlight indexing on top of that. Likewise, if you are doing a lot of Spotlight searching, there will be more usage because you are querying a DBMS.

    Perhaps your battery is just coincidentally needed a replacement and/or non-spotlight related OS tweeks are changing power consumption.

    --
    I only came here to do two things; kick some ass, and drink some beer...looks like we're almost out of beer.
    1. Re:To answer your question by Anonymous Coward · · Score: 2, Informative
      This is pretty basic stuff - the less the hardware is used, the less power it will consume. If Spotlight, or any other app, is accessing the disk, then it will need power to do so. Likewise, if Spotlight is doing a bunch of searching through it's index that has to be loaded into RAM from the disk and those queries must be computed by the OS, then the disk and OS and RAM are all getting a workout.

      What I recommend is that you check out what it is you are doing

      What I recommend is that you read the Ars Technica article that the original poster linked to. The Spotlight indexer component is part of the kernel, and automatically maintains the search index database with all disk activity. Implicitly, this means that everything that used to involve one disk write operation will now involve at least an extra write and probably another seek & read, so you're at least doubling the amount of traffic going out to the disk.

      It stands to reason that this would have a negative impact on battery life.

      On the other hand, if this incrementally increased work is offset by not having to go searching across the whole disk every time you try to find something, then maybe you come out ahead anyway. And if the index is small enough to live in RAM -- probably not, but it seems possible -- then simple lookups may involve no disk access at all, if you're lucky. I have no idea if this is how it is implemented or how likely this is to work on the average laptop (512mb ram, how big is the index?), but it seems like a potentially big win for anyone that was already in the habit of doing a lot of searching.

    2. Re:To answer your question by Goo.cc · · Score: 4, Informative

      One time I noticed was Spotlight causing me trouble was when compiling applications in my home directory. (I guess it was trying to keep up with the compiler as it created files.) I didn't want to turn off indexing on the whole volume, so I created a folder called "Src.noindex", as any folder with a .noindex extension is not indexed by Spotlight. This solved my problem.

      It should be noted that although you can turn off the Spotlight service itself, using the above mentioned "sudo mdutil -i off /volname" is much better, as you will still be able to find things by filename. Turning off the Spotlight service disables finding completely, by content or filename.

    3. Re:To answer your question by TheRaven64 · · Score: 2, Informative

      You can disable indexing for a particular folder in System Preferences (the privacy tab in Spotlight settings). I have done this with ~/tmp for compiling etc.

      --
      I am TheRaven on Soylent News
  5. I've had a lot of problems with my PB since 10.4 by porkchop_d_clown · · Score: 4, Informative

    I've got half a gig, but I'm swapping constantly and apps like Safari regularly swell to consume all available RAM.

    Widgets that access the internet regularly consume a hundred megs of swap and mdimport will start eating processor at random moments. Mail.app regularly tries to index the hundreds of thousands of files on my company's Exchange server and comes to a screeching halt.

    Frankly, Tiger's been a major disappointment.

  6. Easy by neurotypical · · Score: 5, Informative

    Drag the volume you don't want indexed into the Privacy pane in Spotlight preferences.

  7. Have you confirmed it? by jhealy1024 · · Score: 4, Informative

    I'm not saying that it *isn't* Spotlight, but just about anything could be chewing up your battery. Widgets, indexing, screen savers, or even poor Engergy Saver settings. Have you checked to make sure that Spotlight is what's killing your battery?

    Several people have been complaining about a bug in Tiger and the 2005 Powerbooks that has to do with the trackpad:

    http://www.macosxhints.com/article.php?story=20050 808165343661

    It seems that the new tracking features eat up a lot of processor time (and thus, a lot of battery as well).

    Again, I'm not dissing the Spotlight issue: it's definitely something to look at. But if you're still having trouble, you might check on other factors that can kill your battery life.

  8. Here's a script to print out battery info... by porkchop_d_clown · · Score: 4, Informative

    #!/bin/bash

    [ -x /usr/sbin/ioreg ] && \ /usr/sbin/ioreg -p IODeviceTree -n "battery" -w 0 | \
            sed -ne '/| *{/,/| *}/ {
                    s/^[ |]*//g /^[{}]/!p
            }' | \
            awk '/IOBatteryInfo/ {
                    A=$3 $4
                    gsub("[{}()\"]","", A)
                    gsub(","," ",A)
                    print($1, $2, A)
            }'
    # EOF

    Save that as a shell script, when you run it from terminal it will produce info like this:

    "IOBatteryInfo" = Capacity=4046 Amperage=1157 CycleCount=483 Current=2837 Voltage=12187 Flags=838860807 AbsoluteMaxCapacity=4400

    The difference between AbsoluteMaxCapacity and Capacity gives you an idea of how much my battery has faded since it was new...

    1. Re:Here's a script to print out battery info... by hattig · · Score: 5, Informative

      sed: 2: "/| *{/,/| *}/ {
              ...": bad flag in substitute command: '/'

      Maybe I should have bought that sed and awk book ...

      #!/usr/bin/perl

      my $info = `/usr/sbin/ioreg -p IODeviceTree -n "battery" -w 0`;
      my $batteryinfo = $info;
      $batteryinfo =~ s/\n//g;
      $batteryinfo =~ s/^.*\"(IOBatteryInfo)\" = \(\{(.*)\}\).*$/$1\n$2/g;
      $batteryinfo =~ s/\"([\w ]*)\"=/\t$1: /g;
      $batteryinfo =~ s/,/\n/g;
      print $batteryinfo . "\n\n";

      Does the trick too though, and is easily modifiable to log the fields too. It outputs in the format:

      IOBatteryInfo
              Capacity: 4400
              Amperage: 18446744073709550638
              Cycle Count: 9
              Current: 3262
              Voltage: 11655
              Flags: 4
              AbsoluteMaxCapacity: 4400

      God, do I have to type in loads of standard english text here to get it to submit? Bah! Well, here I am, stuck at home waiting for a delivery of a hard drive and drive enclosure. I'm sitting on my iBook wondering when it will turn up. I should be at work, but I can get away with not turning up as I can work from home. Foo foo foo foo. Is that a van I can hear? It appears not, no, wait, yes it is! Hurrah, a parcel! Fun fun fun fun. Gosh, I wonder if this is enough text.

      No, it is not enough text. Sheesh, how frustrating. For a site for geeks, it is remarkably frustrating to post geeky stuff.

      I'm just going to add logging to the script above, and then I can do what I said I'd do above.

    2. Re:Here's a script to print out battery info... by pi_rules · · Score: 4, Informative

      Or... you could open up the System Profiler and look at it.

    3. Re:Here's a script to print out battery info... by hattig · · Score: 2, Informative

      Thanks.

      You've had 226 recharge cycles on the battery, and the capacity is under 3000mAh now, instead of the original 4200. You've lost around 1250mAh @ 12V over the 18 months.

      Did you run that with the external power in though? I only get 12.4V when it is plugged in.

      Whether you want another battery is up to you though. Is the battery life getting to be an issue?

    4. Re:Here's a script to print out battery info... by porkchop_d_clown · · Score: 3, Informative
      /. mangled the end-of-lines causing issues. Here's the correct version:
      #!/bin/bash
       
      [ -x /usr/sbin/ioreg ] && \
      /usr/sbin/ioreg -p IODeviceTree -n "battery" -w 0 | \
              sed -ne '/| *{/,/| *}/ {
                      s/^[ |]*//g
      /^[{}]/!p
              }' | \
              awk '/IOBatteryInfo/ {
                      A=$3 $4
                      gsub("[{}()\"]","", A)
                      gsub(","," ",A)
                      print($1, $2, A)
              }'
      # EOF
    5. Re:Here's a script to print out battery info... by fiftyfly · · Score: 2, Informative
      not quite as nice to read, but one hell of a lot easier to type/debug ;):
      ioreg -p IODeviceTree -n "battery" | grep IOBatteryInfo | sed 's/[ |{}()]//g' | cut -d"=" -f2-
      --
      "Sanity is not statistical", George Orwell, "1984"
  9. If you just got 10.4, ... by daviddennis · · Score: 2, Informative

    it's possible that it's still indexing your entire volume, which might take a long time if you have a PowerBook with a high capacity drive.

    I know that performance on my dual 2ghz G5 with 5gb RAM took a huge hit for about the first 24 hours after I installed Tiger. I have a lot of disk space (almost 2TB) hung off my machine, thus the long indexing time.

    Once that's over, the other replies are right - Spotlight doesn't take up much in the way of resources. But during the initial index, the hit's pretty big and it would not surprise me if it hurt battery life too.

    D

  10. Re:Swapping and slow disk. by BigZaphod · · Score: 2, Informative

    Nope. And I don't use an encrypted disk image or anything like that, either.

  11. What about Dashboard? by blamanj · · Score: 2, Informative

    Don't some of the widgets run more or less all the time? I also recall seeing that some of the first versions had serious memory leaks, in which case you'd be swapping more frequently as well.

  12. not Spotlight's fault, it's a problem with OS X by wilton · · Score: 5, Informative

    Read this:

    http://www.macosxhints.com/article.php?story=20050 808165343661

    It is actually a bug with the driver for the new USB scrolling trackpad. This has been noted in various forums and Apple are aware of this problem.

    If you plug in an external mouse and disable the trackpad, or replace the driver with SideTrack, the problem goes away.

    This only effects the 2005 Powerbooks, and causes much higher CPU and memory load.

    Will

    --
    per mere, per terras
  13. Could be Dashboard - Try This Command by Jackdaw+Rookery · · Score: 4, Informative

    Open Terminal and type this command, followed by return:

    defaults write com.apple.dashboard mcx-disabled -boolean YES

    Restart the dock, dashboard is dead.

    To get dashboard back type:

    defaults write com.apple.dashboard mcx-disabled -boolean NO

  14. It's not spotlight by kataflok · · Score: 4, Informative

    Spotlight put the machine through hell for a few days while it indexed everything it could find -- then it went to sleep.

    Dashboard was eating battery life by 20% and increasing wait times on certain apps significantly -- that is until I killed it. Battery life instantly jumped right back up.

    Spotlight is a one off issue that lasts about a day -- Dashboard is the ongoing PITA.

    --
    Mod me up, mod me down, flame me, praise me -- whatever you do, you help prove I exist...
  15. Re:Kill unused processes by Mikey-San · · Score: 3, Informative

    Use /sbin/kextunload to remove kernel extensions (what drivers in OS X tend to be) that are in memory, not kill.

    you$ man kextunload

    --
    Mikey-San
    Karma: +Eleventy billion (mostly affected by watching Celebrity Jeopardy)
  16. Re:I've had a lot of problems with my PB since 10. by hattig · · Score: 3, Informative

    I have 512MB in my iBook, and I never noticed issues when running Dashboard, Mail, Safari, Terminal, etc, at the same time. Hell even running Eclipse it wasn't too bad, except waking up from sleep.

    What I have done though is turn off Dashboard, and I'm going to write an application to log the battery power using ioreg (from a post above) from a full charge, then compare it to running with Dashboard from a full charge.

  17. Re:Turning off spotlight? by TheRaven64 · · Score: 3, Informative
    Turning off Spotlight is easy. Edit /etc/hostconfig (the equivalent of a BSD /etc/rc.conf) and find the line that says
    SPOTLIGHT=-YES-
    Changing this to
    SPOTLIGHT=-NO-
    will disable spotlight. Unfortunately, this will disable it everywhere - no more searching in Address Book, Mail.app, or any other app whose search relies on Spotlight.
    --
    I am TheRaven on Soylent News
  18. To turn Spotlight off... by MrPerfekt · · Score: 4, Informative

    Add this to /etc/hostconfig:

    SPOTLIGHT=-NO-

    Reboot, and you're done. The indexing service won't even load at boot. The spotlight icon will still be in the corner but will do absolutely nothing when you type in a string.

    And by the way, a watched pot also never boils. I think you're just imagining that it's sucking up all your battery. But hey, it may use a few extra cycles and use up your battery a little quicker.

    --
    I just wasted your mod points! HA!
  19. Re:I've had a lot of problems with my PB since 10. by Jord · · Score: 2, Informative
    X-Charge probably does exactly what you are planning on writing.

    Unless you really want to write it... then nevermind.

  20. Re:Dude, ACPI is your friend by hattig · · Score: 2, Informative

    ACPI is part of IOKit on Mac OS X, so you have to use ioreg to access the data as far as I am aware.

  21. battery usage by chivo243 · · Score: 2, Informative

    try lowering the brightness level of the screen, and having your screen go to sleep quickly... power management

    --
    Sig Hansen?
  22. Re:Umm.. by steven.hasty · · Score: 2, Informative

    Safeguarding your porn collection using encrypted disk images: "Hiding such things from Spotlight is a good idea. To do that, you can create an encrypted disk image that is password protected to keep nosy users out, and the contents of the image don't appear in Spotlight unless the image is mounted...."

  23. Exclude the Entourage database file from Spotlight by mgh02114 · · Score: 2, Informative

    Spotlight sees the Entourage database as one large file. Everytime you download a single piece of email spam, the entire database file changes and Spotlight tries to reindex the whole thing, over and over again. If you have Entourage open and set to check your mail every 20 minutes, you force Spotlight to reindex a ~1GB file containing every email message on your computer every 20 min.

    Spotlight can't see into Entourage anyway, so you aren't loosing any functionality by telling Spotlight to ignore that file.