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!"

19 of 416 comments (clear)

  1. Personally by Nikron · · Score: 5, Interesting

    After I mounted my system with nodiratime and noatime, I did not 'feel' any actual speed increase. I didn't did any hard testing of course.

    --
    Disclaimer: Disregard the above post.
  2. 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.

    1. Re:Linus did not say that! by Anonymous Coward · · Score: 5, Funny

      My name is Ingo Molnar and you mis-attributed my quote. Prepare to die!

  3. atime vs ctime by Intron · · Score: 5, Insightful

    Amazingly, standard Unix filesystems keep time of last access (atime), change of status (ctime), and file modification (mtime) but do not remember when the file was first created, which is something I have frequently wished for.

    --
    Intron: the portion of DNA which expresses nothing useful.
    1. Re:atime vs ctime by EvanED · · Score: 5, Interesting

      There is a technical reason for this.

      A lot of the time, modification of a file... isn't a modification of a file. Instead, the program will delete the existing file and create a new one in its place. (There is sometimes other operations in there, like saving to a temp file, deleting the original, then renaming the temp file to the original file name.)

      This means that storing the real creation time of a file means that it won't be what you expect, because the file that you think is the same file actually isn't.

      (MS-DOS/Windows have something called filesystem tunneling to attempt to get around this problem. If a file is deleted and a new one created in its place (see the MSDN article linked to from there for details) within a default 15 seconds, the creation time of the old file is carried over. This technique exchanges purity and absolute correctness (not that metadata times are reliable against tamper anyway) for utility.)

    2. Re:atime vs ctime by EvanED · · Score: 5, Interesting

      I know self-replies are stupid, but I should have mentioned something else. The metadata tunneling that Windows does is much more important than it is on Unix because the filename may need to be tunneled as well. If you open a file called "somefile with a long name.txt" in an old DOS program by opening SOMEFI~1.TXT (or even in a recent program) and it does this delete/create thing, you don't want the OS to say "oh, you're making a new file called SOMEFI~1.TXT. Spiffy"; you need the original "somefile with a long name.txt" name to carry over.

      The linked site explains all this, but I know the propensity of /. readers (myself included) to RTFA. ;-)

  4. 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.
  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. You fell victim to one of the classic blunders! by stefanlasiewski · · Score: 5, Funny

    "You fell victim to one of the classic blunders! The most famous is never get involved in a flame war on Kerneltrap..."

    --
    "Can of worms? The can is open... the worms are everywhere."
    1. Re:You fell victim to one of the classic blunders! by dcapel · · Score: 5, Funny

      A Slashdot summary wrong? Inconceivable!

      --
      DYWYPI?
  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 Anonymous Coward · · Score: 5, Funny

      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.

    2. 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:Ummm.. by vidarh · · Score: 5, Insightful
    People are using Mutt because it works and has the features lots of people needs. I have to question why people keep upgrading just for the sake of it. As for an event system, Linux has had that too for ages - search for dnotify and inotify.

    However Mutt's use of atime simply is cheap enough that there's simply never been a reason to change it all the time most people have had atime updates on anyway. If it ain't broke, don't fix it.

  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 nschubach · · Score: 5, Funny

    $ man mount

    How can anyone write that with a straight face?
    --
    Every time I start to have faith in humanity, I ruin it by driving to work between 7 and 8 am.
  13. Re:Ummm.. by misleb · · Score: 5, Funny

    How can anyone write that with a straight face?


    I'm sure it was written with a gay face.

    --
    "THERE IS NO JUSTICE, THERE IS ONLY ME." -Death