Stream: git-wasmtime

Topic: wasmtime / PR #6917 Decouple `serde` from its `derive` crate


view this post on Zulip Wasmtime GitHub notifications bot (Aug 27 2023 at 20:01):

CryZe opened PR #6917 from CryZe:decouple-serde-derive to bytecodealliance:main:

By not activating the derive feature on serde, the compilation speed can be improved by a lot. This is because serde can then compile in parallel to serde_derive, allowing it to finish compilation possibly even before serde_derive, unblocking all the crates waiting for serde 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 the derive 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:
https://github.com/serde-rs/serde/issues/2584

For wasmtime I'm seeing a reduction from 24.75s to 22.45s when compiling in release mode. This is because wasmtime through gimli has a dependency on indexmap which can only start compiling when serde is finished, which you want to happen as early as possible so some of wasmtime's dependencies can start compiling.

To measure the full effect, the dependencies can't by themselves activate the derive feature. I've upstreamed a patch for fxprof-processed-profile which was the only dependency that activated it for wasmtime (not yet published to crates.io). wasmtime-cli and co. may need patches for their dependencies to see a similar improvement.

<!--
Please make sure you include the following information:

Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.html

Please ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->

view this post on Zulip Wasmtime GitHub notifications bot (Aug 27 2023 at 20:01):

CryZe requested fitzgen for a review on PR #6917.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 27 2023 at 20:01):

CryZe requested wasmtime-compiler-reviewers for a review on PR #6917.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 27 2023 at 20:01):

CryZe requested wasmtime-default-reviewers for a review on PR #6917.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 27 2023 at 20:01):

CryZe requested wasmtime-core-reviewers for a review on PR #6917.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 28 2023 at 15:43):

fitzgen submitted PR review:

Thanks! One comment below.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 28 2023 at 15:44):

fitzgen submitted PR review:

Thanks! One comment below.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 28 2023 at 15:44):

fitzgen created PR review comment:

Can you avoid this version bump in this PR? IIUC, decoupling the dependencies is orthogonal from upgrading them, and upgrading dependencies requires a core team member do an audit, which will slow things down here.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 28 2023 at 16:00):

CryZe created PR review comment:

I did the bump, because serde itself ensures that serde_derive is always a compatible version since https://github.com/serde-rs/serde/releases/tag/v1.0.186

view this post on Zulip Wasmtime GitHub notifications bot (Aug 28 2023 at 16:00):

CryZe submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 28 2023 at 16:00):

CryZe edited PR review comment.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 28 2023 at 20:48):

CryZe updated PR #6917.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 29 2023 at 16:02):

fitzgen submitted PR review:

Thanks!

view this post on Zulip Wasmtime GitHub notifications bot (Aug 29 2023 at 16:54):

fitzgen merged PR #6917.


Last updated: Nov 22 2024 at 16:03 UTC