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

Including crate increases build times by an order of magnitude #342

Open
NickDriscoll opened this issue May 11, 2022 · 4 comments
Open

Including crate increases build times by an order of magnitude #342

NickDriscoll opened this issue May 11, 2022 · 4 comments

Comments

@NickDriscoll
Copy link

Good afternoon everyone.

I was looking for a simple way to load gltf files into my existing 3D application. I found this crate, and added a line to test it out:
let glb = Gltf::open("./data/models/BoomBox.glb").unwrap();

However, even adding this one line causes my build times to explode!
For this test, the application has already been built before, so we'll just be incrementally compiling main.rs.

Below are the incremental build timings measured using powershell's Measure-Command feature.

Without the new line of code:

Seconds           : 3
Milliseconds      : 595

With the new line of code:

Seconds           : 32
Milliseconds      : 766

Does anyone know what might be causing this huge increase? I assume that others are not simply living with these crazy build times.

Thank you.

@NickDriscoll
Copy link
Author

I had to learn that incremental compilation isn't enabled by default in release mode. Enabling it brought the build times back down to normal, but of course this is just masking the underlying problem.

@aloucks
Copy link
Contributor

aloucks commented May 14, 2022

The primary culprits are: serde + serde_derive + gltf-json

serde is known to be somewhat slow to compile. The derived serialization and deserialization code is monomorhpized, resulting in quite a lot of generated code. On the other hand, miniserde uses trait objects (dynamic dispatch), so much less code is generated (and will result in some performance loss). It may be worthwhile to explore miniserde, but it has a substantially reduced set of customizations.

@Elabajaba
Copy link
Contributor

gltf-json is the main slowdown from my testing. (with LLD on windows, 1.64 nightly)

Release build of the whole gltf repo (cargo +nightly build --release -Z unstable-options --timings=html)

gltf-json

Release build of bevy where gltf-json doesn't seem to block any crates from compiling, but still takes 40% of the overall time to compile.

bevy-timings

@Elabajaba
Copy link
Contributor

Elabajaba commented Aug 4, 2022

Checking this with cargo-llvm-lines, a release build of gltf-json expands to 577761 lines of llvm, with the vast majority of the time being spent in codegen.

edit: There's an open PR for serde_json that improves build times for me by over 50%.

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