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

Long compilation time #29

Open
jens1o opened this issue Oct 29, 2018 · 7 comments
Open

Long compilation time #29

jens1o opened this issue Oct 29, 2018 · 7 comments

Comments

@jens1o
Copy link

jens1o commented Oct 29, 2018

Hey folks,

from time to time I see this, when I compile a project. This is like the crate that takes the longest time to finish. :/ Is there something I can help to speed it up?

Regards

@Manishearth
Copy link
Member

That's surprising, are you sure it's this crate that's the bottleneck and not a different one? Cargo builds things in parallel and it's hard to tell from the output what the currently building crates are. Nightly has better output for this.

I'm unable to reproduce any slowness with a quick test.

@jens1o
Copy link
Author

jens1o commented Oct 29, 2018

Well, for example when I type in cargo install diesel_cli, I always see unicode-normalization for quite a moment and other jobs waiting for it, because, as soon as it's done, other crates start to build. I'll take an eye on this.

@Manishearth
Copy link
Member

Oh, wait, no, was compiling the wrong thing.

Yeah this contains some giant match statements which are slow. We could perhaps use something like phf_map here but that may not improve compile times.

@jens1o
Copy link
Author

jens1o commented Oct 30, 2018

Okay, so as there is nothing you can do here, I'll just close it?

@Manishearth
Copy link
Member

It's worth filing an issue on the rust repo for this. There is stuff we can try here, though

bors added a commit to rust-lang/rust that referenced this issue Jan 10, 2019
Speed up item_bodies for large match statements involving regions

These changes don't change anything about the complexity of the algorithms, but use some easy shortcuts or modifications to cut down some overhead.

The first change, which incrementally removes the constraints from the set we're iterating over probably introduces some overhead for small to medium sized constraint sets, but it's not big enough for me to observe it in any project I tested against (not that many though).

Though most other crates probably won't improve much at all, because huge matches aren't that common, the changes seemed simple enough for me to make them.

Ref #55528

cc unicode-rs/unicode-normalization#29

r? @nikomatsakis
bors added a commit to rust-lang/rust that referenced this issue Jan 12, 2019
Avoid layout calculations in assert_bits to speed up match checking

assert_bits ensures that the given type matches the type of the constant
value, and additionally performs a query for the layout of the given
type to get its size. This is then used to assert that it matches the
size of the constant. But since the types are already known to be the
same, this second check is unnecessary, and skipping it also allows to
skip the expensive layout query.

For the unicode_normalization crate, the match checking time drops from
about 3.8s to about 0.8s for me.

Ref #55528

cc unicode-rs/unicode-normalization#29
pietroalbini added a commit to pietroalbini/rust that referenced this issue Jan 12, 2019
Speed up item_bodies for large match statements involving regions

These changes don't change anything about the complexity of the algorithms, but use some easy shortcuts or modifications to cut down some overhead.

The first change, which incrementally removes the constraints from the set we're iterating over probably introduces some overhead for small to medium sized constraint sets, but it's not big enough for me to observe it in any project I tested against (not that many though).

Though most other crates probably won't improve much at all, because huge matches aren't that common, the changes seemed simple enough for me to make them.

Ref rust-lang#55528

cc unicode-rs/unicode-normalization#29

r? @nikomatsakis
Centril added a commit to Centril/rust that referenced this issue Jan 13, 2019
Speed up item_bodies for large match statements involving regions

These changes don't change anything about the complexity of the algorithms, but use some easy shortcuts or modifications to cut down some overhead.

The first change, which incrementally removes the constraints from the set we're iterating over probably introduces some overhead for small to medium sized constraint sets, but it's not big enough for me to observe it in any project I tested against (not that many though).

Though most other crates probably won't improve much at all, because huge matches aren't that common, the changes seemed simple enough for me to make them.

Ref rust-lang#55528

cc unicode-rs/unicode-normalization#29

r? @nikomatsakis
@raphlinus
Copy link
Contributor

One approach that might address this (and I'm considering for other reasons, mostly because I need raw data for HarfBuzz integration) is to use a script to generate perfect hash maps from the Unicode data, and check those hash maps into the repo. Using a crate like phf_map would work, but would add the compilation time and run time for phf_map to the total compile.

I am happy to measure and PR this approach if there's interest.

@Manishearth
Copy link
Member

I'd definitely love to have script-generated phf-map stuff here. Go for it.

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

No branches or pull requests

3 participants