Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This removes
num-rational
as a dependency. As it turns out,num-rational
, based on which features are active, can very easily end up on the critical path during compilation, meaning that it is the crate that determines how long it takes to compile theimage
crate. This is becausecargo
can parallelize compilation of many crates, but crates with a long dependency chains (rather than wide), are the ones that in the end determine the compilation speed. This is one of the learnings of theserde
drama, where it has been noticed that allowingserde
andserde_derive
to compile in parallel reduces its long dependency chain, resulting in faster compile times. This introduces the same kind of optimization here, where for all the following features,num-rational
turns out to be the longest dependency chain:png,jpeg,gif,bmp,ico,pnm,tga,tiff,webp,hdr,dxt,dds,farbfeld,qoi
The critical path is the following:
autocfg
→num-traits
compile build.rs →num-traits
run build.rs →num-traits
→num-integer
→num-rational
→image
As it turns out, the only thing really used in
num-rational
isRatio
, which can be easily replicated.This cuts out both
num-integer
andnum-rational
cutting compile times by around 0.5 seconds on a debug build.