-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Files modified in the past should not trigger a fingerprint change #2880
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
let should_rebuild = match (*on_disk_mtime, *previously_built_mtime) { | ||
(None, None) => false, | ||
(Some(_), None) | (None, Some(_)) => true, | ||
(Some(on_disk), Some(previously_built)) => on_disk > previously_built, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please double and triple check this logic; my brain got a bit mushy while thinking through it. Having names other than a
and b
helped a lot, but I'm not sure if they are the best they could be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yeah this all looks good to me, helpful names are indeed helpful!
Thanks! I think this will take effect, but just to be sure could you add a test for this as well? |
@alexcrichton yes, that makes sense. However, I'm having some trouble reproducing in a smaller case. As far as I can determine, the |
I think that the new hash has the mtime internally, which should in theory short-circuit that hash check. You should also be able to just edit |
Yeah, that's the avenue I'm exploring now, but now I'm getting even more confused:
So, cargo already ignores when things go backwards in time, except when it doesn't... |
Looking back at my original issue, It appears that it's the "output" file (e.g.
This file contains the result of running the build script. |
Hm ok, I think if you have path dependencies though you should only need to touch all the files in the crate back in time. (note specifically every file needs to go back in time) |
ping @shepmaster, any update on this? (I can certainly help out if needed) |
Previously, we would bail from the fingerprint computation if the old and new mtimes had changed in *any* way. This caused some issues of rebuilding with filesystems that do not preserve nanosecond granularity (#2874).
That might be very useful. Basically, I got stuck and then distracted. 😊 I've pushed my latest branch with the tests that I think should fail before and pass after the change. As you can see, that's not the case. Even just another set of eyes looking at the path that the code is taking and commenting on it would probably prove fruitful. |
Awesome, thanks for the update! Of the two tests that are failing:
So today the "fingerprint" of a package not only counts the files for that package itself but also the fingerprint of all transitive dependencies. That way if anything changes the updates are pushed upwards through the DAG and we recompile everything. I think the problem here is that the fingerprint of a crate is changing in a way that it decides it shouldn't rebuilt, but the value itself is getting modified. This I believe is because the mtime is considered part of the fingerprint. So today the mtime considered is actually the mtime of the fingerprint file itself, which I think is fair to say shouldn't be tampered with if you want to not recompile things. Put another way, this patch against your branch should fix the tests in question. This does raise an interesting question in my mind though! Does this still suffice for the use case you were seeing on Docker? This means that if the mtime of the fingerprint files are changing we're still causing rebuilds, which may not be desirable. Specifically, if a project has two "path crates" (those defined through An alternative solution, to perhaps fix this entirely, is to just store the mtime in the file rather than relying on the file's mtime itself. That way we can guarantee we never lose precision! wdyt? |
ping @shepmaster curious about your thoughts on my last comment |
I've pushed the test fixes to #3246 and I r+'d that, I figure we can handle the "real" problem if comes up, which it's not clear if it does yet! |
Continuation of #2880 Just applied a patch to help fix the tests.
Previously, we would bail from the fingerprint computation if the old
and new mtimes had changed in any way. This caused some issues of
rebuilding with filesystems that do not preserve nanosecond
granularity (#2874).