Decouple serde
from its derive
crate
#65
Merged
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.
By not activating the
derive
feature onserde
, the compilation speed can be improved by a lot. This is becauseserde
can then compile in parallel toserde_derive
, allowing it to finish compilation possibly even beforeserde_derive
, unblocking all the crates waiting forserde
to start compiling much sooner.As it turns out the main deciding factor for how long the compile time of a project is, is primarly determined by the depth of dependencies rather than the width. In other words, a crate's compile times aren't affected by how many crates it depends on, but rather by the longest chain of dependencies that it needs to wait on. In many cases
serde
is part of that long chain, as it is part of a long chain if thederive
feature is active:proc-macro2
compile build script >proc-macro2
run build script >proc-macro2
>quote
>syn
>serde_derive
>serde
>serde_json
(or any crate that depends on serde)By decoupling it from
serde_derive
, the chain is shortened and compile times get much better.Check this issue for a deeper elaboration:
serde-rs/serde#2584
For
samply
I'm seeing a reduction from 5.43s to 3.70s when compilingfxprof-processed-profile
inrelease
mode.The impact is even larger for crates that depend on
fxprof-processed-profile
such aswasmtime
.