vladbat00 / bevy_egui

This crate provides an Egui integration for the Bevy game engine. 🇺🇦 Please support the Ukrainian army: https://savelife.in.ua/en/
MIT License
974 stars 252 forks source link

Compile time improvement: depend on subcrates #319

Closed aevyrie closed 3 weeks ago

aevyrie commented 3 weeks ago

bevy_egui was causing compilation of our large projects to delay until bevy, and more critically, bevy_pbr were done compiling. bevy_pbr is extremely slow, and depends on bevy_render, which is also slow to compile. The result is compilation cannot parallelize well.

This change should be entirely idempotent for users, it simply switches dependencies to the bevy subcrates. The effect of this is that bevy_egui, and anything that depend on it, can now start compiling at the same time as bevy_pbr, this had a huge positive effect on compile times in our larger project, because many things depend on bevy_egui.

The only "gotcha" here is that I had to depend on encase manually, otherwise you end up needing to go through bevy's ShaderType derive, which falls over when bevy is not in scope.

Using --timings on the simple example, on an M3 Max:

Before image

After image

As expected, this has no impact on the compile time of examples, because bevy_pbr still dominates, but in real applications, you will usually have a bunch of crates depending on bevy_egui, which can now start compiling a whole 4 seconds earlier (and even more on slower machines).

vladbat00 commented 3 weeks ago

This is great, thank you!