WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: "This saves some write cycles, because it skips most file access time updates?"  (Read 5318 times)

Offline tobiaus

  • Suspended
  • Hero Member
  • *****
  • Posts: 599
curaga's request in tcb news. i'm all for reducing write cycles on usb mounts, but what about syncs on other devices that mean you're more likely to have a file you've already clicked "save" on (say in leafpad or gimp) when something happens to the battery in a laptop?

i'm not implying this has anything to do with syncing, by the way. i have no idea what it is, that's why i'm asking.

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11041
Lesswatts.org has a pretty good explanation of it:
Quote
Filesystem atime

The POSIX standard requires operating systems to: keep track of the last time each file was accessed by an application or the user, and to store this timestamp as part of the filesystem data. This timestamp, called atime. atime, can be useful in finding out which files are never used (to clean up the /tmp directory for example) or to find out if a file has been looked at after it changed (this is sometimes used by email applications to warn about newly received email).


A significant downside to atime, is that every time a file is accessed, the kernel has to write a new timestamp to the disk, at least after a few seconds of activity. These disk writes will keep the disk and the link to the disk busy, and that costs both performance (the disk is prevented from doing something else) and power (with ALPM, the link to the disk needs to be powered back on, and if the disk was in low power mode, it would need to go to full power as well).

Filesystem relatime
Because few programs use atime, disabling it always and for everyone is not very practical. The Linux kernel has a feature called relatime, which is an effective compromise between having some of the information that atime provides, without having the disk time updated every single time.


relatime works by updating the atime field on disk only if the file hasn't been accessed since the last time it was accessed, (to provide the new email detection capability) or when the last access was more than 1 day ago (to help programs and users clean up unused files in the /tmp directory).
In short, it only improves stuff on ext2/3 when running kernel 2.6.20 or later.

I'm not sure I understand what you mean with the battery; but the default behavior of the kernel is to sync every 5 seconds, so that's the most of work you can lose when the battery drains out.
The only barriers that can stop you are the ones you create yourself.

Offline tobiaus

  • Suspended
  • Hero Member
  • *****
  • Posts: 599
the default behavior of the kernel is to sync every 5 seconds, so that's the most of work you can lose when the battery drains out.

thanks! that answers my question, plus other things i may want to know. mainly i wanted to know if your suggestion would make syncs more uncommon. from this, obviously not. some batteries are so old they barely act as a ups, by the way, that's what i was referring to.