-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Rely on modification time and hash to determine modified sources #11080
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
Rely on modification time and hash to determine modified sources #11080
Conversation
@marcandre I propose we try a slightly different approach that does not require us to read all snapshots upfront. It can be made in two steps:
One thing to notice on step 2 is that we are comparing multiple mtimes. For example, imagine a Phoenix.View. It has several templates on the file system, so while the view is the same, we still need to recompile it if a template changes! So this check:
Should become something like this:
Where |
Btw, a future step would be to keep the size and digests for those external files too, such as phoenix templates, but it can be a separate PR! |
Great, thanks for these pointers 👍 |
lib/mix/lib/mix/compilers/elixir.ex
Outdated
defp digest(file) do | ||
case File.read(file) do | ||
{:ok, content} -> | ||
:crypto.hash(:md5, content) |
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.
:crypto.hash(:md5, content) | |
:erlang.md5(content) |
The difference is that :crypto
is a separate application, that we would need to start and depend on, but luckily MD5 is part of Erlang too.
And yes, clearly, the hashes have to be written to the manifest... |
I'll work on that tomorrow... |
There is absolutely no rush. I plan to do a new Elixir patch release this week with the faster app loading and so it would be too soon to include this (I typically like to run with those changes for a couple weeks). |
660bebf
to
96b2167
Compare
96b2167
to
3667606
Compare
This should be more like it |
Step 2 fails if filesystem mounted with nomtime or the filesystem does not support/properly set mtime. Possibly check if mtime is enabled on filesystem? |
The whole code today already assumes a file system with mtime and it has never been an issue, especially for development. If this is an issue for someone, then we are glad to discuss options, but it is not a concern for this PR. |
💚 💙 💜 💛 ❤️ |
Thank you @marcandre! As I mentioned, we don't run this check for external resources (for example, all templates in a Phoenix view are external resources), so this may be a necessary change in the future if you (or anyone else) is inclined. |
Awesome, thanks! |
Is there a timeline for this to be released?
|
@marcandre I found a bug in master about 10 days but it has been running smoothly since then. I will backport it to v1.12 branch and it should be out in one or two weeks. |
@marcandre btw, if you could run elixir from the v1.12 branch, then it would be super helpful too to help catch any regressions and you would have the benefits today. :) |
The website and readme have instructions to install/compile from source if needed. |
Perfect, will do 👍 |
I was disappointed to get the dreaded "Compiling 392 files (.ex)" when using it locally, only to realize that my branch was modifying Although this happens less frequently, it would be really nice to fix this too, so that only actual changes to files invalidate the project. A "quick" fix might be for |
@marcandre we already have a manifest where we store the elixir and otp versions, and we could store the config digests in there. It is currently kept in |
Thank you, I'll have a look when I get a bit of time. |
an example is sshfs has mtime issues |
@josevalim May not be related (directly or at all), but I'm getting some strange compiling errors today that resolve if I recompile the whole
I am not sure how to reproduce it, but it has happened 3 times today (and never before today, no notable to our codebase either 🤷) This is running elixir from 1.12 branch (at Any idea what could be happening? |
@marcandre next time it happens, please try passing the |
Oh, and please see if touching only the file that defines Bobby next fixes it. |
Yay, I was able to reproduce this and I figured out what I did. Opened #11176 |
As discussed on the mailing list, I think this adds the right check by hashing the content, but I'm lacking tests.
Does it look like I'm on the right track?