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

11 nov 2010 kl. 00:08 skrev Matthias Sohn:

> 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].

Unfortunately Java truncates the timestamp on Linux [5]. I've
noticed it with XFS, so I think the problem is file system agnostic.

> On Windows ntfs provides 100 nsec resolution.

GitIndex had some rounding, that assumed that if a timestamp has 0 in the millisecond
part, it would truncate the timestamp it compared with to whole seconds. 

> Combining this information I am not yet sure what's the right approach here.
> [1]
> [2],
> [3]
> [4]


-- robin

Back to the top