-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Use lockfile on incr. comp. directory #32754
Comments
FWIW Cargo recently forayed into lock files, and it basically just ended up using the fs2 crate's locking methods (namely |
I've been thinking about a different synchronization mechanism lately, one that takes more of a persistent data structure than a mutex approach. It goes roughly like this:
The most important advantage of this strategy is that we are never left with a corrupt cache. If the The disadvantages are that:
Thoughts? |
In the last step the old cache directory is deleted, but concurrent rustc invocations means that the old cache may be in use, right? Basically step (3) needs to be resilient to the cache disappearing, but that seems reasonable? I'm somewhat wary about spawning a cleanup process, the behavior on Unix at least for a ctrl-c is to typically kill the entire process group, which in this case includes the cleanup process. In that sense if the compiler abnormally terminates so will the child. On Windows the behavior is somewhat similar with what we do today where the parent and child process are both in the same "job object", which when closed will kill both. I don't really have a great suggestion though, but perhaps we could just leave around these directories or maybe cleanup > 24hr old ones automatically? |
Regarding the concurrent access: we should be fine with missing files. If the file is actually copied and there is any chance of a halfway copied file, we'd also need to store some kind of checksum to prevent those from being used. Regarding cleanup: I was thinking about the 'delete unreasonably old working dirs' approach too, as an additional backup. It would probably also be OK to do only that. Is there no way to spawn an independent process (i.e. one that can outlive its spawner)? On July 21, 2016 7:56:45 PM GMT+02:00, Alex Crichton notifications@github.com wrote:
|
We can emulate spawning an independent process on Unix by changing process groups at least, but it does seem like a surprising thing for a compiler to do, so I'd be somewhat wary of doing that. On Windows with job objects at least I believe it's impossible to spawn an independent process. |
@michaelwoerister sounds pretty related to #34957 |
Yes, it is a bit surprising. On the other hand, I personally would be OK with the compiler starting a daemon process to support incremental compilation. Especially if it's just an enhancement that keeps my disk from filling up. For example, the way Sublime Text build systems work, I have to manually kill long-running rustc processes all the time. I'd probably end up with a few hundred unused working directories at any point in time if they only get cleaned up after 24 hours @nikomatsakis Yes, definitely related. |
Maybe a |
File locks work pretty well minus NFS, but we could have a scheme like:
This doesn't help for NFS, but I'm not sure there's really much we can do there? |
That sounds like a pretty promising approach. NFS we won't be able to support, I'm afraid, but that seems OK to me. |
On Windows we actually can't delete a file if someone's opened it, and on Unix if you delete a file I believe all open references still have the same underlying data, so in theory that should be roughly ok if hard linking isn't supported? I'd also be fine saying that we don't work great on things like FAT32. Or at least not to start out |
Since not addressing this issue might lead to a lot of unreproducible bug reports because of a corrupted cache directory, we decided to add it to the alpha milestone. |
@alexcrichton How far, do think, are we away from being able to use dependencies from |
@michaelwoerister still pretty far unfortunately, I'd plan on vendoring for now. |
…ing, r=nikomatsakis Implement synchronization scheme for incr. comp. directory This PR implements a copy-on-write-based synchronization scheme for the incremental compilation cache directory. For technical details, see the documentation at the beginning of `rustc_incremental/persist/fs.rs`. The PR contains unit tests for some functions but for testing whether the scheme properly handles races, a more elaborate test setup would be needed. It would probably involve a small tool that allows to manipulate the incremental compilation directory in a controlled way and then letting a compiler instance run against directories in different states. I don't know if it's worth the trouble of adding another test category to `compiletest`, but I'd be happy to do so. Fixes rust-lang#32754 Fixes rust-lang#34957
…ing, r=nikomatsakis Implement synchronization scheme for incr. comp. directory This PR implements a copy-on-write-based synchronization scheme for the incremental compilation cache directory. For technical details, see the documentation at the beginning of `rustc_incremental/persist/fs.rs`. The PR contains unit tests for some functions but for testing whether the scheme properly handles races, a more elaborate test setup would be needed. It would probably involve a small tool that allows to manipulate the incremental compilation directory in a controlled way and then letting a compiler instance run against directories in different states. I don't know if it's worth the trouble of adding another test category to `compiletest`, but I'd be happy to do so. Fixes rust-lang#32754 Fixes rust-lang#34957
…crichton Implement synchronization scheme for incr. comp. directory This PR implements a copy-on-write-based synchronization scheme for the incremental compilation cache directory. For technical details, see the documentation at the beginning of `rustc_incremental/persist/fs.rs`. The PR contains unit tests for some functions but for testing whether the scheme properly handles races, a more elaborate test setup would be needed. It would probably involve a small tool that allows to manipulate the incremental compilation directory in a controlled way and then letting a compiler instance run against directories in different states. I don't know if it's worth the trouble of adding another test category to `compiletest`, but I'd be happy to do so. Fixes #32754 Fixes #34957
Currently we are not detecting the case where multiple rustc processes are using the same incr. comp directory. That is not good.
The text was updated successfully, but these errors were encountered: