Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] File timestamp precision on Linux

2010/11/10 Lluis Sanchez Gual <slluis.devel@xxxxxxxxx>
Hi,

In WorkingTreeIterator.isModified there is some code for rounding cached
timestamps to seconds, since Java on Windows gives times with a
precision of seconds. However, I'm noticing a similar issue on Linux.

Java on Linux is returning times rounded to seconds. The problem is that
the C git stores timestamps using millisecond precision. So for example,
if I run "git reset --hard" and then traverse the working tree using a
TreeWalk checking isModified for each item, the date comparison will
almost always fail (milliseconds won't match), leading to many full
content checks, which is much slower.

This issue can be solved in WorkingTreeIterator by rounding the cached
timestamp to seconds when the last write time of the file being checked
is also rounded to seconds. However, I'm wondering if this is a known
issue that it is handled in a different way in other places of the code.

AFAIK there are some filesystem rounding timestamps to seconds, according to 
[1] Java is returning timestamps with ms precision (though not nsec). 

E.g. ext3, hfs+ round timestamps to seconds [2], whereas ext4, xfs, jfs provide
nsec resolution [3].

On Windows ntfs provides 100 nsec resolution.

Combining this information I am not yet sure what's the right approach here.

[1] http://download.oracle.com/javase/6/docs/api/java/io/File.html#lastModified()
[2] http://en.wikipedia.org/wiki/Ext3http://en.wikipedia.org/wiki/HFS_Plus
[3] http://en.wikipedia.org/wiki/Ext4
[4] http://en.wikipedia.org/wiki/NTFS

--
Matthias

Back to the top