Hacker News new | past | comments | ask | show | jobs | submit login

He cites that his ext4 system only has 10ms granularity, which is most certainly not the default, but likely a result of upgrading from ext2/ext3 to ext4.

What is the granularity of your file system? Mine appears to be 3.33ms.




Nanosecond granularity on all the ones I use, which includes ZFS, ext4, and tmpfs.


Check the timestamps which are actually set on the files.

I was surprised and disappointed to find Linux sets mtime to the nearest clock tick (250Hz on my laptop) on filesystems whose documentation says they provide nanosecond timestamps.

It's not obvious because the numbers actually stored still have 9 random looking digits. But the chosen mtime values actually go up only on clock ticks. If you're running those filesystems on Linux, try it yourself:

    (n=1; while [[ $n -le 10000 ]]; do > test$n; n=$((n+1)); done)
    ls -ltr --full-time
You should see the timestamp nanoseconds increment every few files, in batches. If they were truly nanosecond accurate mtimes, they would be different for every file.

That's why some of my programs on Linux now set the mtime explicitly with a call to clock_gettime() followed by futimens(), after writing the file. To make sure the timestamps do change each times files are replaced, in case it's more than once inside a 250Hz tick.




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: