Skip to content
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

Implement synchronization scheme for incr. comp. directory #35718

Merged
merged 11 commits into from
Sep 1, 2016

Conversation

michaelwoerister
Copy link
Member

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

@rust-highfive
Copy link
Collaborator

r? @nrc

(rust_highfive has picked a reviewer for you, use r? to override)

@michaelwoerister
Copy link
Member Author

cc @nikomatsakis @alexcrichton @brson @rust-lang/compiler

bug!("Trying initialize already active IncrCompSession.")
}
IncrCompSession::Finalized { .. } => {
bug!("Trying initialize already finalized IncrCompSession.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Both this bug! and the one before it should be "Trying to initialize.."

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@nrc
Copy link
Member

nrc commented Aug 17, 2016

r? @nikomatsakis

@michaelwoerister
Copy link
Member Author

OK, I've implemented the read-write-lock approach. That seems like a clear improvement. I did not, however, move the lock file out of the directory. It made cleanup code more complicated in a few places and having it in the directory should be just as correct. I think, I also addressed all the nits.


// Like std::fs::create_dir_all, except handles concurrent calls among multiple
// threads or processes.
pub fn create_dir_racy(path: &Path) -> io::Result<()> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this just copied from compiletest?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's moved here from rustc_incremental::persist::util which doesn't exist anymore.

@nikomatsakis
Copy link
Contributor

ok, r=me modulo nits

@michaelwoerister michaelwoerister force-pushed the incr-comp-dir-locking branch 2 times, most recently from 14b9dc8 to d1d8258 Compare August 19, 2016 16:39
@michaelwoerister
Copy link
Member Author

@bors r=nikomatsakis

@bors
Copy link
Contributor

bors commented Aug 19, 2016

📌 Commit d1d8258 has been approved by nikomatsakis

@michaelwoerister
Copy link
Member Author

@alexcrichton @eddyb This seems to be a restriction purely in the Windows API (i.e. DeleteFileW) and not in the underlying file system. Would it be too much of a performance hit to always prepend that magic prefix?

@eddyb
Copy link
Member

eddyb commented Aug 26, 2016

@michaelwoerister You could do it conditionally, since you already know the length.

@michaelwoerister
Copy link
Member Author

@eddyb yep.

@Manishearth
Copy link
Member

Manishearth commented Aug 27, 2016

@bors r-

Tidy fails. Feel free to re-r+ when fixed.

/build/src/librustc_incremental/persist/fs.rs:415: trailing whitespace

/build/src/librustc_incremental/persist/fs.rs:1008: trailing whitespace

thread 'main' panicked at 'some tidy checks failed', /build/src/tools/tidy/src/main.rs:53

@bors
Copy link
Contributor

bors commented Aug 28, 2016

☔ The latest upstream changes (presumably #35984) made this pull request unmergeable. Please resolve the merge conflicts.

@michaelwoerister
Copy link
Member Author

@alexcrichton Care to take a look at those last two commits and r+ if they look good to you?

@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Contributor

bors commented Aug 29, 2016

📌 Commit bcd2f90 has been approved by alexcrichton

@bors
Copy link
Contributor

bors commented Aug 30, 2016

⌛ Testing commit bcd2f90 with merge 5a8ca4b...

@alexcrichton
Copy link
Member

@bors: retry force clean

  • restarted buildbot

@bors
Copy link
Contributor

bors commented Aug 31, 2016

⌛ Testing commit bcd2f90 with merge 2c01bb8...

bors added a commit that referenced this pull request Aug 31, 2016
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants