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

Spurious script rebuilds with shared target directory with build-cef #9794

Closed
larsbergstrom opened this issue Feb 28, 2016 · 14 comments · Fixed by #9880
Closed

Spurious script rebuilds with shared target directory with build-cef #9794

larsbergstrom opened this issue Feb 28, 2016 · 14 comments · Fixed by #9880
Labels
A-build Related to or part of the build process A-content/script Related to the script thread

Comments

@larsbergstrom
Copy link
Contributor

As seen in: http://build.servo.org/builders/mac-rel-wpt/builds/1966, despite sharing a target directory, runing ./mach build-cef -r after a ./mach build -r, it still takes 14 minutes and 43 seconds. This time is because the script crate believes that it has been changed and needs to re-run the build. Here's a sample fingerprint output:

INFO:cargo::ops::cargo_rustc::fingerprint: fingerprint error for script v0.0.1 (file:///Users/larsberg/servo/components/servo): precalculated components have changed: 1456675029.000000000s (/Users/larsberg/servo/components/script/parser.out) != 145644786\
6.000000000s (/Users/larsberg/servo/components/script/dom/element.rs)

Does not seem to be the same as #7936.

I'm not really sure what this file is (yet), but am looking into it.

CC: @jdm @Ms2ger @alexcrichton @metajack

@larsbergstrom larsbergstrom added A-content/script Related to the script thread A-build Related to or part of the build process labels Feb 28, 2016
@larsbergstrom
Copy link
Contributor Author

Interesting, in another run (I've been switching between a normal and CEF build), this time from normal -> CEF, I got:

[larsberg@lbergstrom servo]$ RUST_LOG=cargo::ops::cargo_rustc::fingerprint=info ./mach build-cef -r 2>&1 | tee fingerprint-cef-log.txt
INFO:cargo::ops::cargo_rustc::fingerprint: fingerprint error for embedding v0.0.1 (file:///Users/larsberg/servo/ports/cef): failed to read `/Users/larsberg/servo/target/release/.fingerprint/embedding-532c6397928d6611/lib-embedding`
INFO:cargo::ops::cargo_rustc::fingerprint:   cause: No such file or directory (os error 2)
INFO:cargo::ops::cargo_rustc::fingerprint: fingerprint error for devtools v0.0.1 (file:///Users/larsberg/servo/ports/cef): new (devtools_traits v0.0.1 (file:///Users/larsberg/servo/ports/cef)) != old (devtools_traits v0.0.1 (file:///Users/larsberg/servo/components/servo))
INFO:cargo::ops::cargo_rustc::fingerprint: fingerprint error for msg v0.0.1 (file:///Users/larsberg/servo/ports/cef): new (util v0.0.1 (file:///Users/larsberg/servo/ports/cef)) != old (util v0.0.1 (file:///Users/larsberg/servo/components/servo))
INFO:cargo::ops::cargo_rustc::fingerprint: fingerprint error for devtools_traits v0.0.1 (file:///Users/larsberg/servo/ports/cef): new (msg v0.0.1 (file:///Users/larsberg/servo/ports/cef)) != old (msg v0.0.1 (file:///Users/larsberg/servo/components/servo))
INFO:cargo::ops::cargo_rustc::fingerprint: fingerprint error for style v0.0.1 (file:///Users/larsberg/servo/ports/cef): new (style_traits v0.0.1 (file:///Users/larsberg/servo/ports/cef)) != old (style_traits v0.0.1 (file:///Users/larsberg/servo/components/servo))
INFO:cargo::ops::cargo_rustc::fingerprint: fingerprint error for style_traits v0.0.1 (file:///Users/larsberg/servo/ports/cef): new (util v0.0.1 (file:///Users/larsberg/servo/ports/cef)) != old (util v0.0.1 (file:///Users/larsberg/servo/components/servo))
INFO:cargo::ops::cargo_rustc::fingerprint: fingerprint error for glutin_app v0.0.1 (file:///Users/larsberg/servo/ports/cef): new (compositing v0.0.1 (file:///Users/larsberg/servo/ports/cef)) != old (compositing v0.0.1 (file:///Users/larsberg/servo/components/servo))
INFO:cargo::ops::cargo_rustc::fingerprint: fingerprint error for net_traits v0.0.1 (file:///Users/larsberg/servo/ports/cef): new (msg v0.0.1 (file:///Users/larsberg/servo/ports/cef)) != old (msg v0.0.1 (file:///Users/larsberg/servo/components/servo))
INFO:cargo::ops::cargo_rustc::fingerprint: fingerprint error for compositing v0.0.1 (file:///Users/larsberg/servo/ports/cef): new (canvas v0.0.1 (file:///Users/larsberg/servo/ports/cef)) != old (canvas v0.0.1 (file:///Users/larsberg/servo/components/servo))
INFO:cargo::ops::cargo_rustc::fingerprint: fingerprint error for script_traits v0.0.1 (file:///Users/larsberg/servo/ports/cef): new (canvas_traits v0.0.1 (file:///Users/larsberg/servo/ports/cef)) != old (canvas_traits v0.0.1 (file:///Users/larsberg/servo/components/servo))
INFO:cargo::ops::cargo_rustc::fingerprint: fingerprint error for canvas_traits v0.0.1 (file:///Users/larsberg/servo/ports/cef): new (gfx_traits v0.0.1 (file:///Users/larsberg/servo/ports/cef)) != old (gfx_traits v0.0.1 (file:///Users/larsberg/servo/components/servo))
INFO:cargo::ops::cargo_rustc::fingerprint: fingerprint error for gfx_traits v0.0.1 (file:///Users/larsberg/servo/ports/cef): new (msg v0.0.1 (file:///Users/larsberg/servo/ports/cef)) != old (msg v0.0.1 (file:///Users/larsberg/servo/components/servo))
INFO:cargo::ops::cargo_rustc::fingerprint: fingerprint error for canvas v0.0.1 (file:///Users/larsberg/servo/ports/cef): new (canvas_traits v0.0.1 (file:///Users/larsberg/servo/ports/cef)) != old (canvas_traits v0.0.1 (file:///Users/larsberg/servo/components/servo))
INFO:cargo::ops::cargo_rustc::fingerprint: fingerprint error for layout_traits v0.0.1 (file:///Users/larsberg/servo/ports/cef): new (gfx v0.0.1 (file:///Users/larsberg/servo/ports/cef)) != old (gfx v0.0.1 (file:///Users/larsberg/servo/components/servo))
INFO:cargo::ops::cargo_rustc::fingerprint: fingerprint error for gfx v0.0.1 (file:///Users/larsberg/servo/ports/cef): new (canvas_traits v0.0.1 (file:///Users/larsberg/servo/ports/cef)) != old (canvas_traits v0.0.1 (file:///Users/larsberg/servo/components/servo))
INFO:cargo::ops::cargo_rustc::fingerprint: fingerprint error for servo v0.0.1 (file:///Users/larsberg/servo/ports/cef): new (canvas v0.0.1 (file:///Users/larsberg/servo/ports/cef)) != old (canvas v0.0.1 (file:///Users/larsberg/servo/components/servo))
INFO:cargo::ops::cargo_rustc::fingerprint: fingerprint error for script v0.0.1 (file:///Users/larsberg/servo/ports/cef): new (canvas v0.0.1 (file:///Users/larsberg/servo/ports/cef)) != old (canvas v0.0.1 (file:///Users/larsberg/servo/components/servo))
INFO:cargo::ops::cargo_rustc::fingerprint: fingerprint error for layout v0.0.1 (file:///Users/larsberg/servo/ports/cef): new (canvas v0.0.1 (file:///Users/larsberg/servo/ports/cef)) != old (canvas v0.0.1 (file:///Users/larsberg/servo/components/servo))
INFO:cargo::ops::cargo_rustc::fingerprint: fingerprint error for webdriver_server v0.0.1 (file:///Users/larsberg/servo/ports/cef): new (compositing v0.0.1 (file:///Users/larsberg/servo/ports/cef)) != old (compositing v0.0.1 (file:///Users/larsberg/servo/components/servo))
INFO:cargo::ops::cargo_rustc::fingerprint: fingerprint error for profile v0.0.1 (file:///Users/larsberg/servo/ports/cef): new (profile_traits v0.0.1 (file:///Users/larsberg/servo/ports/cef)) != old (profile_traits v0.0.1 (file:///Users/larsberg/servo/components/servo))
INFO:cargo::ops::cargo_rustc::fingerprint: fingerprint error for net v0.0.1 (file:///Users/larsberg/servo/ports/cef): new (devtools_traits v0.0.1 (file:///Users/larsberg/servo/ports/cef)) != old (devtools_traits v0.0.1 (file:///Users/larsberg/servo/components/servo))

Maybe some error in path normalization has crept in here? They're building from the same directory, but with different relative paths.

@larsbergstrom
Copy link
Contributor Author

And here' s a run of ./mach build -r with fingerprinting just after a ./mach build-cef -r:

-index`
INFO:cargo::ops::cargo_rustc::fingerprint: fingerprint error for servo v0.0.1 (file:///Users/larsberg/servo/components/servo): new (canvas v0.0.1 (file:///Users/larsberg/servo/components/servo)) != old (canvas v0.0.1 (file:///Users/larsberg/servo/ports/cef))
INFO:cargo::ops::cargo_rustc::fingerprint: fingerprint error for net_traits v0.0.1 (file:///Users/larsberg/servo/components/servo): new (msg v0.0.1 (file:///Users/larsberg/servo/components/servo)) != old (msg v0.0.1 (file:///Users/larsberg/servo/ports/cef))
INFO:cargo::ops::cargo_rustc::fingerprint: fingerprint error for msg v0.0.1 (file:///Users/larsberg/servo/components/servo): new (util v0.0.1 (file:///Users/larsberg/servo/components/servo)) != old (util v0.0.1 (file:///Users/larsberg/servo/ports/cef))
INFO:cargo::ops::cargo_rustc::fingerprint: fingerprint error for devtools v0.0.1 (file:///Users/larsberg/servo/components/servo): new (devtools_traits v0.0.1 (file:///Users/larsberg/servo/components/servo)) != old (devtools_traits v0.0.1 (file:///Users/larsberg/servo/ports/cef))
INFO:cargo::ops::cargo_rustc::fingerprint: fingerprint error for devtools_traits v0.0.1 (file:///Users/larsberg/servo/components/servo): new (msg v0.0.1 (file:///Users/larsberg/servo/components/servo)) != old (msg v0.0.1 (file:///Users/larsberg/servo/ports/cef))
INFO:cargo::ops::cargo_rustc::fingerprint: fingerprint error for compositing v0.0.1 (file:///Users/larsberg/servo/components/servo): new (canvas v0.0.1 (file:///Users/larsberg/servo/components/servo)) != old (canvas v0.0.1 (file:///Users/larsberg/servo/ports/cef))
INFO:cargo::ops::cargo_rustc::fingerprint: fingerprint error for gfx_traits v0.0.1 (file:///Users/larsberg/servo/components/servo): new (msg v0.0.1 (file:///Users/larsberg/servo/components/servo)) != old (msg v0.0.1 (file:///Users/larsberg/servo/ports/cef))
INFO:cargo::ops::cargo_rustc::fingerprint: fingerprint error for canvas_traits v0.0.1 (file:///Users/larsberg/servo/components/servo): new (gfx_traits v0.0.1 (file:///Users/larsberg/servo/components/servo)) != old (gfx_traits v0.0.1 (file:///Users/larsberg/servo/ports/cef))
INFO:cargo::ops::cargo_rustc::fingerprint: fingerprint error for gfx v0.0.1 (file:///Users/larsberg/servo/components/servo): new (canvas_traits v0.0.1 (file:///Users/larsberg/servo/components/servo)) != old (canvas_traits v0.0.1 (file:///Users/larsberg/servo/ports/cef))
INFO:cargo::ops::cargo_rustc::fingerprint: fingerprint error for style_traits v0.0.1 (file:///Users/larsberg/servo/components/servo): new (util v0.0.1 (file:///Users/larsberg/servo/components/servo)) != old (util v0.0.1 (file:///Users/larsberg/servo/ports/cef))
INFO:cargo::ops::cargo_rustc::fingerprint: fingerprint error for style v0.0.1 (file:///Users/larsberg/servo/components/servo): new (style_traits v0.0.1 (file:///Users/larsberg/servo/components/servo)) != old (style_traits v0.0.1 (file:///Users/larsberg/servo/ports/cef))
INFO:cargo::ops::cargo_rustc::fingerprint: fingerprint error for script_traits v0.0.1 (file:///Users/larsberg/servo/components/servo): new (canvas_traits v0.0.1 (file:///Users/larsberg/servo/components/servo)) != old (canvas_traits v0.0.1 (file:///Users/larsberg/servo/ports/cef))
INFO:cargo::ops::cargo_rustc::fingerprint: fingerprint error for canvas v0.0.1 (file:///Users/larsberg/servo/components/servo): new (canvas_traits v0.0.1 (file:///Users/larsberg/servo/components/servo)) != old (canvas_traits v0.0.1 (file:///Users/larsberg/servo/ports/cef))
INFO:cargo::ops::cargo_rustc::fingerprint: fingerprint error for layout_traits v0.0.1 (file:///Users/larsberg/servo/components/servo): new (gfx v0.0.1 (file:///Users/larsberg/servo/components/servo)) != old (gfx v0.0.1 (file:///Users/larsberg/servo/ports/cef))
INFO:cargo::ops::cargo_rustc::fingerprint: fingerprint error for layout v0.0.1 (file:///Users/larsberg/servo/components/servo): new (canvas v0.0.1 (file:///Users/larsberg/servo/components/servo)) != old (canvas v0.0.1 (file:///Users/larsberg/servo/ports/cef))
INFO:cargo::ops::cargo_rustc::fingerprint: fingerprint error for script v0.0.1 (file:///Users/larsberg/servo/components/servo): new (canvas v0.0.1 (file:///Users/larsberg/servo/components/servo)) != old (canvas v0.0.1 (file:///Users/larsberg/servo/ports/cef))
INFO:cargo::ops::cargo_rustc::fingerprint: fingerprint error for profile v0.0.1 (file:///Users/larsberg/servo/components/servo): new (profile_traits v0.0.1 (file:///Users/larsberg/servo/components/servo)) != old (profile_traits v0.0.1 (file:///Users/larsberg/servo/ports/cef))
INFO:cargo::ops::cargo_rustc::fingerprint: fingerprint error for glutin_app v0.0.1 (file:///Users/larsberg/servo/components/servo): new (compositing v0.0.1 (file:///Users/larsberg/servo/components/servo)) != old (compositing v0.0.1 (file:///Users/larsberg/servo/ports/cef))
INFO:cargo::ops::cargo_rustc::fingerprint: fingerprint error for net v0.0.1 (file:///Users/larsberg/servo/components/servo): new (devtools_traits v0.0.1 (file:///Users/larsberg/servo/components/servo)) != old (devtools_traits v0.0.1 (file:///Users/larsberg/servo/ports/cef))
INFO:cargo::ops::cargo_rustc::fingerprint: fingerprint error for webdriver_server v0.0.1 (file:///Users/larsberg/servo/components/servo): new (compositing v0.0.1 (file:///Users/larsberg/servo/components/servo)) != old (compositing v0.0.1 (file:///Users/larsberg/servo/ports/cef))
INFO:cargo::ops::cargo_rustc::fingerprint: fingerprint error for servo v0.0.1 (file:///Users/larsberg/servo/components/servo): new (canvas v0.0.1 (file:///Users/larsberg/servo/components/servo)) != old (canvas v0.0.1 (file:///Users/larsberg/servo/components/servo))
   Compiling style_traits v0.0.1 (file:///Users/larsberg/servo/componen

@larsbergstrom
Copy link
Contributor Author

Maybe related to rust-lang/cargo#2383 ?

@alexcrichton
Copy link
Contributor

This is probably related to how Cargo stores the "package id" for path dependencies. Right now it incorrectly changes the package id depending on which path dependency is the root package being built. That explains the differences in paths you're seeing here.

I've reopened rust-lang/cargo#497 which I believe is the underlying issue here.

@larsbergstrom
Copy link
Contributor Author

Thanks for looking into it, @alexcrichton! This would save a ton of time on our build machines.

I'm also open to restructuring our various Cargo.toml files, if that's the "correct" fix (or the one that puts us on a better path to only-one-Cargo-toml).

@alexcrichton
Copy link
Contributor

One way you may be able to get around this is to always have the same "root" package and then use cargo test -p or cargo build -p to build only selective portions of the graph.

@alexcrichton
Copy link
Contributor

@larsbergstrom it looks like the first error is legit:

precalculated components have changed: 1456675029.000000000s (/Users/larsberg/servo/components/script/parser.out) != 1456447866.000000000s (/Users/larsberg/servo/components/script/dom/element.rs)

Namely, parser.out appears to be set here which is later turned into a logger. That should probably be in the OUT_DIR, or the build.rs for the script crate should print out cargo:rerun-if-changed for the input files.

That's not the entire story here, however, as I think there's something more subtle at play here. Haven't yet tracked it down yet.

@alexcrichton
Copy link
Contributor

Aha, found it! I couldn't reproduce because it turns out this was a regression introduced by rust-lang/cargo#2279. This also confirms to me that my suspected fix is indeed the route I would like to take to fix it. Time to clean up the commit and send a PR. Thanks for the cc @larsbergstrom!

@Ms2ger
Copy link
Contributor

Ms2ger commented Mar 1, 2016

Got rid of parser.out in #9817

@larsbergstrom
Copy link
Contributor Author

@alexcrichton Awesome, thanks a ton for looking into this! It'll really help decrease our CI cycle times.

@nox
Copy link
Contributor

nox commented Mar 1, 2016

This also confirms to me that my suspected fix is indeed the route I would like to take to fix it.

Do you mean the part where we only build specific parts of the graph? Because that's an ugly work-around, I don't see why geckolib and Servo should be driven by the same top-level Cargo.toml file. :(

@larsbergstrom
Copy link
Contributor Author

@nox I was assuming Alex meant it was:

This is probably related to how Cargo stores the "package id" for path dependencies. Right now it incorrectly changes the package id depending on which path dependency is the root package being built.

@nox
Copy link
Contributor

nox commented Mar 1, 2016

Oh, disregard me then.

bors added a commit to rust-lang/cargo that referenced this issue Mar 4, 2016
All crates being compiled by Cargo are identified by a unique `PackageId` instance. This ID incorporates information such as the name, version, and source from where the crate came from. Package ids are allowed to have path sources to depend on local crates on the filesystem. The package id itself encodes the path of where the crate came from.

Historically, however, the "path source" from where these packages are learned had some interesting logic. Specifically one specific source would be able to return many packages within. In other words, a path source would recursively walk crate definitions and the filesystem attempting to find crates. Each crate returned from a source has the same source id, so consequently all packages from one source path would have the same source path id.

This in turn leads to confusing an surprising behavior, for example:

* When crates are compiled the status message indicates the path of the crate root, not the crate being compiled
* When viewed from two different locations (e.g. two different crate roots) the same package would have two different source ids because the id is based on the root location.

This hash mismatch has been [papered over](#1697) in the past to try to fix some spurious recompiles, but it unfortunately [leaked back in](#2279). This is clearly indicative of the "hack" being inappropriate so instead these commits fix the root of the problem.

---

In short, these commits ensure that the package id for a package defined locally has a path that points precisely at that package. This was a relatively invasive change and had ramifications on a few specific portions which now require a bit of extra code to support.

The fundamental change here was to change `PathSource` to be non-recursive by default in terms of what packages it thinks it contains. There are still two recursive use cases, git repositories and path overrides, which are used for backwards compatibility. This meant, however, that the packaging step for crate no longer has knowledge of other crates in a repository to filter out files from. Some specific logic was added to assist in discovering a git repository as well as filtering out sibling packages.

Another ramification of this patch, however, is that special care needs to be taken when decoding a lockfile. We now need all path dependencies in the lockfile to point precisely at where the path dependency came from, and this information is not encoded in the lock file. The decoding support was altered to do a simple probe of the filesystem to recursively walk path dependencies to ensure that we can match up packages in a lock file to where they're found on the filesystem.

Overall, however, this commit closes #1697 and also addresses servo/servo#9794 where this issue was originally reported.
bors-servo pushed a commit that referenced this issue Mar 4, 2016
bors-servo pushed a commit that referenced this issue Mar 4, 2016
bors-servo pushed a commit that referenced this issue Mar 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-build Related to or part of the build process A-content/script Related to the script thread
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants