You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unix file timestamps only have one-second granularity #18870
area-System.IOenhancementProduct code improvement that does NOT require public API changes/additionshelp wanted[up-for-grabs] Good issue for external contributors
Currently, method such as File.GetLastWriteTime and FileInfo.LastWriteTime return timestamps which are only accurate to the nearest second on Unix. On OSX, this seems to be a system-level limitation in HFS+. On most Linux filesystems, however, millisecond-level information does seem to be available, at least via stat. @stephentoub recommended that we could use utimes rather than utime in the native shim in order to retrieve this information.
This also seems to affect files copied by File.Copy, because we copy over some timestamp metadata from the source file (to match Windows).
@TicoDePano can you clarify? I think this original Issue is fixed : milliseconds are now returned on Unix and also on macOS if APFS partition. What change remains to make?
I repro this on Ubuntu 1604 -- when we copy the file the access and modify times both drop their millisec part. The change time does not, presumably because the file system sets it.
Certainly we should fix this. @TicoDePano do you have any interest in investigating?
@AndyGerlicher@cdmihai this means if someone copies a file on Linux (or macOS with the latest APFS) using .NET Core (any version) then reads the timestamp with .NET Core 2.1+, the "destination" will look older (have older modified time) than the "source". I would definitely expect that to be causing overbuilds in MSBuild. Have you had reports?
area-System.IOenhancementProduct code improvement that does NOT require public API changes/additionshelp wanted[up-for-grabs] Good issue for external contributors
Activity
TicoDePano commentedon Jul 4, 2018
On .NET Core 2.1 on Linux it gets worst, as it considers the milliseconds part when comparing files, but a copy doesn't set such a resolution.
danmoseley commentedon Jul 5, 2018
@TicoDePano can you clarify? I think this original Issue is fixed : milliseconds are now returned on Unix and also on macOS if APFS partition. What change remains to make?
TicoDePano commentedon Jul 5, 2018
.NET Core 2.0 results:
Runtime: .NET Core 4.6.00001.0
Input: 0 ms, 636662151720000000 ticks
Output: 0 ms, 504911120400000000 ticks
Copying images: directory $img created
Copying images: file banner1.svg copied
Input: 0 ms, 636662151720000000 ticks
Output: 0 ms, 636662151720000000 ticks
.NET Core 2.1 results:
Runtime: .NET Core 4.6.26606.02
Input: 205 ms, 636662151722054140 ticks
Output: 0 ms, 504911120400000000 ticks
Copying images: directory $img created
Copying images: file banner1.svg copied
Input: 205 ms, 636662151722054140 ticks
Output: 0 ms, 636662151720000000 ticks
Copying images: file banner1.svg copied
*** Output file doesn't exist initially.
danmoseley commentedon Jul 6, 2018
I repro this on Ubuntu 1604 -- when we copy the file the access and modify times both drop their millisec part. The change time does not, presumably because the file system sets it.
Certainly we should fix this. @TicoDePano do you have any interest in investigating?
danmoseley commentedon Jul 6, 2018
Fix is here https://github.com/dotnet/corefx/blob/master/src/Native/Unix/System.Native/pal_io.c#L1271-L1293 where it explicitly sets 0 for milliseconds
It needs to access milliseconds via the macros defined here https://github.com/dotnet/corefx/blob/master/src/Native/Unix/System.Native/pal_io.h#L40-L70
The pattern to test this is similar to https://github.com/dotnet/corefx/blob/master/src/System.IO.FileSystem/tests/Base/BaseGetSetTimes.cs#L76 .. the change should fix Macs with APFS as well
danmoseley commentedon Jul 6, 2018
This might be a servicing candidate actually since presumably it breaks up-to-date checks.
danmoseley commentedon Jul 10, 2018
@AndyGerlicher @cdmihai this means if someone copies a file on Linux (or macOS with the latest APFS) using .NET Core (any version) then reads the timestamp with .NET Core 2.1+, the "destination" will look older (have older modified time) than the "source". I would definitely expect that to be causing overbuilds in MSBuild. Have you had reports?
danmoseley commentedon Jul 10, 2018
@Anipik could you please fix this? It would be great to get a PR up today in case there is still runway for 2.1.3
Anipik commentedon Jul 10, 2018
I will make it my first priority.
danmoseley commentedon Jul 10, 2018
@Anipik I expect you would use the macro similar ot this
https://github.com/dotnet/corefx/blob/44e5bdafb8d989a220c9cf1b94f31a64a6e4f052/src/Native/Unix/System.Native/pal_io.c#L178
danmoseley commentedon Jul 13, 2018
@TicoDePano thank you for the report. This is now fixed in master and we will consider servicing 2.1
TicoDePano commentedon Jul 13, 2018
@danmosemsft thanks and sorry for not helping with the code. I'm not working with C/C++ a long time.
danmoseley commentedon Jul 13, 2018
@TicoDePano no problem, you are welcome to look at another issue if you like, most of our issues labeled up-for-grabs are c# changes.
3 remaining items
leecow commentedon Jul 17, 2018
Good for Master. Recheck CLI build performance.
danmoseley commentedon Jul 17, 2018
To take this in servicing we need evidence customers are actually being impacted.
danmoseley commentedon Jul 18, 2018
Shiproom -- I updated template with perf numbers from @Anipik .
vivmishra commentedon Jul 19, 2018
Approved for 2.1.5
danmoseley commentedon Jul 26, 2018
Leaving everything in 2.1.4 until we determine whether it will have generic fixes
joshfree commentedon Aug 9, 2018
Moving to 2.1.5 per shiproom today
Anipik commentedon Aug 9, 2018
So does that mean we can merge the Linked PR ?
joshfree commentedon Aug 10, 2018
@Anipik not yet. Likely next week - please wait for @vivmishra to let us know when the branch is open for 2.1.5 commits.
danmoseley commentedon Aug 14, 2018
Moving label to PR per new process
Anipik commentedon Aug 29, 2018
we have merged this change into release so closing this issue
karelz commentedon Sep 6, 2018
Fixed in release/2.1 branch in PR dotnet/corefx#31046. Will be part of 2.1.5 release.