-
Notifications
You must be signed in to change notification settings - Fork 195
Revert "Adopt utimensat for setting file modification dates (#1324)" #1379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I think the issue stems from losing 1 bit of precision when we go from a If we instead do 2
then add the Here's some sample code explaining the issue/solution:
In the failure cases, we fail ~50% of the time, which makes sense due to the 1 bit of precision lost. |
As a clarification, I think rounding to the nearest microsecond is actually only guaranteed to work for On the other hand, the double |
@swift-ci please test |
Discussed with Jonathan offline - the solution above is a more robust solution for |
@stephentyrone would be interested in this use case too :D |
While the
utimensat
has the ability to set nanosecond-precision dates on files (when supported by the file system), unfortunately the current call site of it loses precision for some input dates (represented asDouble
s). Unfortunately I haven't found a good way to convert theDouble
date representation to the second and nanosecond components without losing precision, and this precision causes issues with some clients expecting dates to roundtrip with full fidelity (even though values likeDate.now
may only support 1000ns-level precision, the imprecision when calculating nanosecond values can cause round tripping a date to return a different value than the one set).Resolves rdar://153731450