Rethinking multi-grain timestamps
Rethinking multi-grain timestamps
Posted Oct 9, 2023 21:37 UTC (Mon) by iabervon (subscriber, #722)Parent article: Rethinking multi-grain timestamps
mtime1 = mtime
content1 = content
mtime2 = mtime
and see that mtime1 == mtime2, then later, if mtime == mtime1, content was still content1 when you last looked at mtime. This doesn't work at millisecond granularity, because there could be another modification in the same millisecond after the one that led to mtime2, and there could have been a modification leading to mtime1 in the same millisecond before a second one between reading the content and mtime2. Of course, the additional precision beyond a millisecond doesn't have to reflect when in the millisecond the modifications happened; it just has to increase with each different content. The excessive precision is really just ensuring that multiple modifications can't happen without getting a different mtime, but you also need to deal with still having this property if the file gets evicted from the cache at various points, which is the tricky part.