Slashdot Mirror


Replacing Atime With Relatime in the Kernel

eldavojohn writes "Our friend Jeremy at the Kernal Trap has dug up some interesting criticism of atime from Linus Torvalds. As Linus submitted patches to improve relatime he noted: 'I cannot over-emphasize how much of a deal it is in practice. Atime updates are by far the biggest IO performance deficiency that Linux has today. Getting rid of atime updates would give us more everyday Linux performance than all the pagecache speedups of the past 10 years, _combined_.' And later severely beat atime about the head with a pointed stick: 'It's also perhaps the most stupid Unix design idea of all times. Unix is really nice and well done, but think about this a bit: 'For every file that is read from the disk, lets do a ... write to the disk! And, for every file that is already cached and which we read from the cache ... do a write to the disk!'" Well, I guess I can expect my Linux machine to become a little bit faster!"

20 of 416 comments (clear)

  1. Linus did not say that! by JbirdUAH · · Score: 5, Informative

    if the poster had read the article they would have noticed that Linus did not say those things that are quoted - Ingo Molnar did.

  2. Re:Ummm.. by AKAImBatman · · Score: 3, Informative

    This is talking about the Last Access Time feature of most Unix systems. The OS will write a timestamp to disk each time the file is opened, closed, changed, or just looked at funny. Most professional Unixes (Solaris springs to mind) have the option of disabling the access timestamps. I haven't read the article yet, so I'm not quite sure why Linux hasn't followed suit by now. It's a security feature that's not all that useful on most systems.

  3. Re:Ummm.. by ArcherB · · Score: 5, Informative
    In your /etc/fstab, add noatime to your options portion of you drive line. For example:

    /media/sda1 ext3 defaults,noatime 1 1 atime logs when a file has been written or read. So every time a file is used, it has to write an entry on the HDD, slowing performance, but it can have uses, like in forensics, security or backups (if a file has not been read in three years, it's probably safe to archive and move off the drive). I don't care for it, so I have the noatime line in my fstab.

    --
    There is no "I disagree" mod for a reason. Flamebait, Troll, and Overrated are not substitutes.
  4. Re:mount noatime? by bugnuts · · Score: 3, Informative

    Is there something I'm missing? Nope, it's something everyone else has been missing and apparently what's obvious to sysadmins is not obvious to the world. I do like the relatime option, though.

    atime updates actually help a LOT in some circumstances. I use it to help with security checks (even though you can hack the atime record), to help debug (what input file caused it to hang?), and all sorts of things where it's useful to know when a file was read.

    I could cope with not having them, but in many cases I love the extra information atime gives.
  5. Re:Summary please? by mpeg4codec · · Score: 5, Informative

    File access timestamps, by default, are updated each time a file is read, and this occurs a write to the disk. Even if a file resides in cache, a write must be performed every time it is opened [even though the cache prevents a read from the disk]. A few people found that by disabling this, performance increases dramatically. The long and short of it: use noatime when you're mounting a file system [or in the fstab] if you want to try for yourself.

  6. Re:Ummm.. by Compholio · · Score: 5, Informative

    Most professional Unixes (Solaris springs to mind) have the option of disabling the access timestamps. I haven't read the article yet, so I'm not quite sure why Linux hasn't followed suit by now.
    Linux has had the capability to turn off access timestamps for a long time. "man mount" has details, but all you really have to do is edit /etc/fstab:
    /dev/hda3 / ext3 defaults 0 1
    becomes
    /dev/hda3 / ext3 defaults,noatime,nodiratime 0 1
  7. Re:Probably overblown by tepples · · Score: 3, Informative

    If atime isn't so hot, and everything works better without it, then it sounds like it's time for the kernel developers to discuss turning it off by default and letting people turn it on if they need to know the atime. Isn't that the distro's job?
  8. latest relatime patch by Ingo+Molnar · · Score: 5, Informative

    Hey, Slashdot posted an article about me! [ They also renamed me to Linus - what more can a geek ask for? ;-) ]

    In any case, the latest version of the better-relatime patch can be picked up from:

    http://redhat.com/~mingo/relatime-patches/

    Apply it, build it, reboot into the new kernel and enjoy a faster (and lower latency) desktop. (no fstab twiddling needed)

    1. Re:latest relatime patch by Ingo+Molnar · · Score: 5, Informative

      I agree - modifying a text file is a messy complicated business only suitable for the elite super hackers out there. It's much simpler for me to apply the patch and recompile the kernel.

      I kid, I kid.

      ok, you are kidding, but i'll still bite :-)

      Firstly, the patch is mainly about modifying relatime behavior to make it more compatible and more usable.

      The fact that you dont have to change fstab is no big deal, provided you have the right util-linux package installed, with the relatime user-space patch applied which not even the latest distro devel repositories have included.

      If you dont have that then adding "relatime" to your fstab might leave you with a read-only mounted root filesystem and some commandline (or rescue-image) tinkering to do.

      People prefer all-in-one kernel patches that just turns on the feature they are interested in. You'd be surprised how many people are willing to try almost arbitrary kernel patches but loathe to touch their user-space environment in any way.

      And ... it's also kind of ironic that this relatively small patch often brings more practical benefits to the desktop than all the "big" desktop interactivity/latency features (cfs, swap-prefetch, -rt kernel) combined.

      Ingo^H^H^H^H Linus

  9. Re:Laptop power issue. by GoRK · · Score: 5, Informative

    Just a handy tip for you (if you don't already use it) or others who are looking at disabling atime more for the power savings than the IO -- on laptops you should also be using noflushd (non-journaling filesystems only) or (ideally) Laptop Mode Tools. Also do not forget to configure syslog so that it doesn't constantly sync writes.

    It's also worth mentioning that you *can* have atime enabled with properly configured laptop-mode and laptop-mode-tools and still see almost as much power savings -- The atime writes will still happen, but at least they will be buffered for when the HDD actually needs to spin up and do a lot of other more pressing IO.

  10. Re:Personally by ciroknight · · Score: 4, Informative

    I can't "feel" a difference on my desktop with 2GB of RAM, but on my laptop which only has 1, and a much slower disk, the improvement is pretty noticeable (as in from "nearly unusable for lots of access applications [trackerd]" to "smooth as silk").

    It's funny the kernel devs are just now talking about this, I discovered this almost 6 months ago on the Ubuntu forums while glancing around for a fix for my laptop's ridiculous sound issues.

    --
    "Victory means exit strategy, and it's important for the President to explain to us what the exit strategy is." G.W.Bush
  11. As a flash fs writer... by EmbeddedJanitor · · Score: 5, Informative
    atime really hurts some file systems, particularly flash file systems. Many/most flash file systems don't support atime for that reason. So, even if you're running atime in the kernel you will often not be getting atime in the fs.

    If you're using a desktop system with a hard disk you'll hardly notice any difference unless you hammer the system really hard.

    Remember though that most Linux systems are either embedded (using mainly flash) or servers. In both these cases atime updates can be very damaging to performance and should be avoided unless there's a very good reason to turn it on.

    --
    Engineering is the art of compromise.
  12. Re:Ummm.. by Anonymous Coward · · Score: 3, Informative

    "/dev/hda3 / ext3 defaults,noatime,nodiratime 0 1"
    Actually, noatime is a superset of nodiratime, so there is no need to specify both.

  13. Re:Is this reason why we cant spin down disks? by rahvin112 · · Score: 4, Informative

    Stopping and Starting a disk causes the most wear on the disk. When in an idle state the spinning disk has fully lubricated bearings and is using just a tiny amount of energy. Strap in a stop and start and you have bearings on start that don't have their lubrication optimally spread (gravity and lack of motion cause the metal to get closer together and depending on the manufacturer may have some of the bearings without lubrication), and the spinup of the disks themselves is on average a 6W draw (idle is like .3W). Plus, when the disks are fully spinning wobble is going to be constrained a bit by the speed, whereas on startup and stopping the minor imperfections in the disk can let the minor wobbles show which strains the bearings and causes wear and tear. See if the bearings start to fail and are say 20% shot, the motor on the drive can just use a little more energy to drive them, but the startup cost might exceed what the motor is capable of outputing. Using the example above, the .3W draw on idle might climb to .6W, but on startup that could translate in moving from 6W to 12W (and exceeding what the motor can physically provide).

    And if you don't believe any of that you shouldn't have any trouble using google to find Admins who tell horror stories about having to reboot a drive and losing the entire drive because the bearings were shot to the point that once the disks stopped the motor couldn't generate enough force to restart them. But the disk could have lasted years more as long as it wasn't stopped. In fact in companies where a lot of data is stored the disks are put on their own power source at least partially because the disks don't have to be stopped if a server needs to be rebooted because of failure or updates. This is also one of the reasons to be wary of purchasing used storage arrays. Might have worked great when they shut it off, but you might be able to restart the array.

  14. Re:Personally by Burz · · Score: 4, Informative

    I discovered noatime about 5 years ago, right about the same time I learned that DMA was turned off by default. I was horrified to hear that Linus' opinion of DMA at the time was 'no performance gain'.

    I'm surprised Linus is just cluing in now about atime updates: The noatime workaround is listed in all kinds of performance-tuning guides.

  15. Re:Laptop power issue. by Eideewt · · Score: 4, Informative

    I'm not sure your link is correct.

  16. Re:Personally by Trepalium · · Score: 4, Informative

    For a laptop, there is a more important reason to use noatime. Without that option the hard drives may never get the chance to spin down and save power because /bin/sync always has something to write to the disk (it's own atime update).

    --
    I used up all my sick days, so I'm calling in dead.
  17. Re:Personally by sortius_nod · · Score: 3, Informative

    I just enabled it on my little file server at home.

    Specs:
    AMD 3000+, 512MB ram, 1x 80GB IDE, 2x 500GB SATA (Raid)

    MASSIVE difference in performance, even just doing an ls on a directory with a lot of files/directories in it.

  18. Re:Personally by Suicyco · · Score: 3, Informative

    Try it on a multi terabyte high speed raid0 for scratch data on a big box like a 64 cpu altix. noatime can give massive, and by massive I mean MASSIVE speed increases. atime is retarded, I totally agree with Linus.

  19. Re:Ummm.. by hab136 · · Score: 3, Informative

    The old Netscape 4.x software also used Unix mailbox (mbox) files; it just also had index files. I'm not sure about current versions. mbox plus index was/is a popular storage format - mbox because it was simple, with added indexes for speed.

    Maildir is my preferred format - each message is a separate plain text file, which means no locking issues, and simultaneous access from multiple machines. You can just tar the directory up if you want to move it, or cat all the files together if you want mbox back. You can use maildir with mutt (and lots of other software).