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

incr.comp.: We don't achieve 100% CGU re-use when recompiling Stylo #48184

Closed
michaelwoerister opened this issue Feb 13, 2018 · 12 comments
Closed
Assignees
Labels
A-incr-comp Area: Incremental compilation C-bug Category: This is a bug. I-compiletime Issue: Problems and improvements with respect to compile times. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-incr-comp Working group: Incremental compilation

Comments

@michaelwoerister
Copy link
Member

The following CGU are re-compiled even though there's been no change to the source code (just touch components/style/lib.rs).

alloc-vec.volatile
style-properties-animated_properties
style-gecko_bindings-structs-root
style-properties-declaration_block
smallvec.volatile
style-gecko-wrapper
hashglobe-table.volatile
servo_arc.volatile
style-gecko_bindings-structs-root-mozilla.volatile
core-iter.volatile
style-values-computed.volatile
style-properties-longhands-grid_template_columns
style-properties-longhands-grid_template_rows
style-properties-longhands-border_image_source
style-properties-longhands-clip_path
style-properties-longhands-shape_outside
style-values-animated.volatile

Version of Stylo used: https://github.com/rust-lang-nursery/rustc-perf/tree/6b3404678be0c1e3c013ca9234083984ae13b101/collector/benchmarks/style-2f3bc0de49

Steps to reproduce:

cd collector/benchmarks/style-2f3bc0de49
cargo clean
cargo rustc --release --features gecko --manifest-path components/style/Cargo.toml -- --cap-lints=warn -Zincremental=/tmp/somethingsomething -Ztime-passes -Zhuman-readable-cgu-names
touch components/style/lib.rs
cargo rustc --release --features gecko --manifest-path components/style/Cargo.toml -- --cap-lints=warn -Zincremental=/tmp/somethingsomething -Ztime-passes -Zhuman-readable-cgu-names
rustc 1.25.0-nightly (b8398d947 2018-02-11)
binary: rustc
commit-hash: b8398d947d160ad4f26cc22da66e5fbc7030817b
commit-date: 2018-02-11
host: x86_64-unknown-linux-gnu
release: 1.25.0-nightly
LLVM version: 6.0

Need to investigate further why these CGUs are being recompiled? @SimonSapin, @emilio, is there maybe some kind of build script or proc-macro that modifies the source code during a rebuild?

@michaelwoerister michaelwoerister added the A-incr-comp Area: Incremental compilation label Feb 13, 2018
@SimonSapin
Copy link
Contributor

Adding -v to the commands I see that the build script is run the first time but not the second. As expected, since cargo:rerun-if-changed=… is used.

There are multiple (derive) proc macros in use, but they should be deterministic as far as I know.

@kennytm kennytm added the C-bug Category: This is a bug. label Feb 13, 2018
@michaelwoerister
Copy link
Member Author

Thanks for the information, @SimonSapin!

@michaelwoerister
Copy link
Member Author

One way to find out if this is due to a StableHash instability is to compile the crate a few times in a row with the -Zincremental-verify-ich flag enabled. That should point to any instabilities pretty quickly.

@goffrie
Copy link
Contributor

goffrie commented Mar 14, 2018

I suspect it is because of hashset ordering in style_derive; see in cg.rs

impl<'input, 'path> WhereClause<'input, 'path> {
    pub fn add_trait_bound(&mut self, ty: &Ty) {
        let trait_path = self.trait_path;
        let params = self.params;
        let mut found = self.trait_output.map(|_| HashSet::new());

.. later:

        if let Some(found) = found {
            for ident in found {
                let ty = Ty::Path(None, ident.into());

At least, this is responsible for causing differences in the --pretty=expanded output.

@michaelwoerister
Copy link
Member Author

@goffrie Wow, great find! That surely would explain instabilities.

@SimonSapin What would you suggest that we do with the benchmark? Do newer versions of style_derive have this problem too? We could also just patch the benchmark. Anything that will make the generated AST deterministic would help.

@SimonSapin
Copy link
Contributor

https://github.com/servo/servo/blob/master/components/style_derive/cg.rs now doesn’t use use HashSet at all, but that’s part of a large-ish change that’s not easily backported.

We can update the entire benchmark to current Servo, but maybe it’s undesirable to change what’s being measured too much?

Another option is patching the benchmark to replace HashSet with BTreeSet or using a non-random hasher, to get deterministic iteration order.

@michaelwoerister
Copy link
Member Author

I'd say let's patch the benchmark. One thing to look out for is if the values of pointers are being hashed (or compared in the case of BTreeSet). The version of syn being used seems to be an old one so I didn't see immediately if that could be the case.

@andjo403
Copy link
Contributor

andjo403 commented Mar 7, 2019

looks like it is possible to close this

@michaelwoerister
Copy link
Member Author

We should verify that we get 100% re-use first.

@jonas-schievink jonas-schievink added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-incr-comp Working group: Incremental compilation labels Aug 19, 2019
@jonas-schievink jonas-schievink added the I-compiletime Issue: Problems and improvements with respect to compile times. label Aug 27, 2019
@wesleywiser wesleywiser self-assigned this Nov 17, 2020
@wesleywiser

This comment has been minimized.

@michaelwoerister
Copy link
Member Author

I'm wondering why these CGUs are not named? Are you sure that this is an incr. build? You could try running the test again with -Zhuman-readable-cgu-names. That might give you some more insight.

@wesleywiser
Copy link
Member

Doh! I forgot to pass -Cincremental. If I do that, I can confirm we get 100% CGU re-use. 🎉

@pnkfelix pnkfelix closed this as completed Dec 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-incr-comp Area: Incremental compilation C-bug Category: This is a bug. I-compiletime Issue: Problems and improvements with respect to compile times. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-incr-comp Working group: Incremental compilation
Projects
None yet
Development

No branches or pull requests

8 participants