Skip to content
This repository was archived by the owner on Apr 18, 2022. It is now read-only.

[MAINTENANCE] Multiple versions of crates #1948

Closed
eliaspekkala opened this issue Sep 27, 2019 · 8 comments
Closed

[MAINTENANCE] Multiple versions of crates #1948

eliaspekkala opened this issue Sep 27, 2019 · 8 comments
Labels
team: engine type: maintenance A task that has no noticeable user-facing effect. Code cleanup, small refactors, etc.

Comments

@eliaspekkala
Copy link
Contributor

eliaspekkala commented Sep 27, 2019

Description

In my investigation to reduce Amethyst build times I have found that there are many crates in Amethyst's dependency tree that Cargo isn't able to resolve into a single version. This means that Cargo will build and include several versions of some crates.

I have created a command to automatically find and list crates with many versions. The command is cargo tree --duplicate --prefix-depth | grep '^[\0]' | sort | cut -c3-.

To run the command you need cargo tree. You also need to specify the features you want to include in Amethyst's Cargo.toml.

Note that:

  • I am on this commit: a304ad8c
  • I specified these features: animation, audio, locale, network, renderer, gltf, tiles, json, sdl_controller, vulkan
  • I ran cargo update before the command

The command output:

approx v0.1.1
approx v0.3.2

arrayvec v0.4.11
arrayvec v0.5.0

hibitset v0.5.4
hibitset v0.6.2

image v0.21.3
image v0.22.3

lock_api v0.1.5
lock_api v0.3.1

num-traits v0.1.43
num-traits v0.2.8

num v0.1.42
num v0.2.0

parking_lot_core v0.4.0
parking_lot_core v0.6.2

parking_lot v0.7.1
parking_lot v0.9.0

png v0.14.1
png v0.15.0

proc-macro2 v0.4.30
proc-macro2 v1.0.4

quote v0.6.13
quote v1.0.2

rand_chacha v0.1.1
rand_chacha v0.2.1

rand_core v0.3.1
rand_core v0.4.2
rand_core v0.5.1

rand_hc v0.1.0
rand_hc v0.2.0

rand v0.4.6
rand v0.5.6
rand v0.6.5
rand v0.7.2

rusttype v0.7.9
rusttype v0.8.1

scopeguard v0.3.3
scopeguard v1.0.0

synstructure v0.10.2
synstructure v0.12.1

syn v0.14.9
syn v0.15.44
syn v1.0.5

tiff v0.2.2
tiff v0.3.1

unicode-xid v0.1.0
unicode-xid v0.2.0

This shows that are 22 crates that have multiple versions included in Amethyst.

It also shows that there are 26 older versions of crates that could potentially be removed with some upgrades/updates in Amethyst or in the crates in its dependency tree.

Steps to remove multiple versions

The table below shows the old versions that we want to remove and the steps to remove them.
You can use cargo tree or cargo tree --duplicate to investigate the steps in the cases where I haven't figured them out yet.

Note: Some of the steps will require the crate author to do the updates and then to create a release on crates.io.

Crate and version Steps to remove
approx v0.1.1 bump palette(needs release first) in amethyst_rendy, rendy-texture, and amethyst. Also bump genmesh(needs release first) in amethyst_rendy and amethyst
cgmath v0.16.1 gfx-rs/genmesh#66 Swap cgmath with nalgebra in genmesh.
arrayvec v0.4.11 4 instances, see dependency tree
hibitset v0.5.4 bump rendy in amethyst_rendy
image v0.21.3 3 instances, see dependency tree
lock_api v0.1.5 bump rendy in amethyst_rendy
num-traits v0.1.43 bump genmesh(needs release first) in amethyst_rendy and amethyst
num v0.1.42 bump num in sdl2, then bump sdl2(needs release first) in amethyst_input
parking_lot_core v0.4.0 bump rendy in amethyst_rendy
parking_lot v0.7.1 bump rendy in amethyst_rendy
png v0.14.1 bump image in winit, then bump winit(needs release first) in amethyst_window
proc-macro2 v0.4.30 13 instances, see dependency tree
quote v0.6.13 12 instances, see dependency tree
rand_chacha v0.1.1 bump quickcheck in alga_derive, then bump alga_derive(needs release first) in amethyst_core
rand_core v0.3.1 bump quickcheck in alga_derive, then bump alga_derive(needs release first) in amethyst_core. Also bump laminar in amethyst_network
rand_core v0.4.2 bump quickcheck in alga_derive, then bump alga_derive(needs release first) in amethyst_core
rand_hc v0.1.0 bump quickcheck in alga_derive, then bump alga_derive(needs release first) in amethyst_core
rand v0.4.6 gfx-rs/genmesh#66 Switch to nalgebra in genmesh then bump genmesh (needs release first) in amethyst_rendy
rand v0.5.6 bump laminar in amethyst_network
rand v0.6.5 6 instances, see dependency tree
rusttype v0.7.9 1 instance but many steps, see dependency tree
scopeguard v0.3.3 bump rendy in amethyst_rendy
synstructure v0.10.2 1 instance but many steps, see dependency tree
syn v0.14.9 bump palette_derive(needs release first) in palette, then bump palette(needs release first) in amethyst_rendy
syn v0.15.44 8 instances, see dependency tree
tiff v0.2.2 bump image in winit, then bump winit(needs release first) in amethyst_window
unicode-xid v0.1.0 4 instances, see dependency tree

Progess

This table shows the old crate versions that have been removed, the steps taken, and the PR where it was done.

Crate and version Steps to remove Removed with PR
glyph_brush v0.5.4 bump glyph_brush in amethyst_ui #1955
memmap v0.6.2 bump font-kit in amethyst_ui #1955
parking_lot v0.6.4 bump parking_lot in amethyst_assets #1955
parking_lot_core v0.3.1 bump parking_lot in amethyst_assets #1955
shred v0.7.2 bump shred in amethyst_network #1955

The PR #1952 also reduced the number of steps necessary to remove some of the crates.

Reason

To reduce build times.

Impact

I have not measured the benefits in terms of build times.

Additional Information

Use cargo tree to see Amethyst's dependency tree and the origin of the crates.

@eliaspekkala eliaspekkala added status: needs triage type: maintenance A task that has no noticeable user-facing effect. Code cleanup, small refactors, etc. labels Sep 27, 2019
@eliaspekkala
Copy link
Contributor Author

I have now measured the old crates percentages of the total build time using the data from: cargo +nightly build -Z timings.

Here's the results:

Crate and version % of total build time
approx v0.1.1 0.03
arrayvec v0.4.11 0.18
hibitset v0.5.4 0.17
image v0.21.3 1.26
lock_api v0.1.5 0.07
num-traits v0.1.43 0.01
num v0.1.42 0.01
parking_lot_core v0.4.0 0.18
parking_lot v0.7.1 0.17
png v0.14.1 0.26
proc-macro2 v0.4.30 0.32
quote v0.6.13 0.11
rand_chacha v0.1.1 0.07
rand_core v0.3.1 0.01
rand_core v0.4.2 0.08
rand_hc v0.1.0 0.11
rand v0.4.6 0.33
rand v0.5.6 0.53
rand v0.6.5 0.40
rusttype v0.7.9 0.03
scopeguard v0.3.3 0.01
synstructure v0.10.2 0.51
syn v0.14.9 1.71
syn v0.15.44 1.78
tiff v0.2.2 0.18
unicode-xid v0.1.0 0.03
SUM 8.55

My build time is usually around 120s, so if these old crate versions are removed cargo build should complete around 10.3s (120 * 8.55 / 100) faster on my computer.

@azriel91
Copy link
Member

Thanks! Shall slowly chew through the ecosystem (syn, quote, proc-macro2 all go hand in hand).

cc: @Veykril if you ever feel bored

@malobre
Copy link

malobre commented Oct 28, 2019

Related: amethyst/rendy#203
We're currently resolving the syn duplication but it takes time (see amethyst/rendy#203 (comment))

@azriel91
Copy link
Member

azriel91 commented Feb 15, 2020

Current state: 45536af (2020-02-15)
approx v0.1.1
approx v0.3.2

arrayvec v0.4.12
arrayvec v0.5.1

autocfg v0.1.7
autocfg v1.0.0

crossbeam-channel v0.3.9
crossbeam-channel v0.4.0

crossbeam-queue v0.1.2
crossbeam-queue v0.2.1

crossbeam-utils v0.6.6
crossbeam-utils v0.7.0

env_logger v0.6.2
env_logger v0.7.1

generic-array v0.12.3
generic-array v0.13.2

image v0.21.3
image v0.22.5

nalgebra v0.18.1
nalgebra v0.19.0

num-traits v0.1.43
num-traits v0.2.11

parking_lot v0.10.0
parking_lot v0.9.0

parking_lot_core v0.6.2
parking_lot_core v0.7.0

png v0.14.1
png v0.15.3

proc-macro2 v0.4.30
proc-macro2 v1.0.8

quote v0.6.13
quote v1.0.2

rand v0.4.6
rand v0.6.5
rand v0.7.3

rand_chacha v0.1.1
rand_chacha v0.2.1

rand_core v0.3.1
rand_core v0.4.2
rand_core v0.5.1

rand_pcg v0.1.2
rand_pcg v0.2.1

rusttype v0.7.9
rusttype v0.8.2

smallvec v0.6.13
smallvec v1.2.0

static_assertions v0.3.4
static_assertions v1.1.0

syn v0.14.9
syn v0.15.44
syn v1.0.14

tiff v0.2.2
tiff v0.3.1

unicode-xid v0.1.0
unicode-xid v0.2.0
Item Waiting on
rand_core v0.3.1 gfx-rs/genmesh#66
rand_core v0.4.2 See all rand v0.6.5 PRs
rand_chacha v0.1.1 See all rand v0.6.5 PRs
rand_pcg v0.1.2 See all rand v0.6.5 PRs
nalgebra 0.18.1 rodio release > 0.11.0 RustAudio/rodio#268
cgmath v0.16.1 gfx-rs/genmesh#66
rand v0.4.6 gfx-rs/genmesh#66
rand v0.6.5 sentry release > 0.17.0 getsentry/sentry-rust#182
rand v0.6.5 getsentry/sentry-rust#179 (sentry -> reqwest -> uuid -> rand)
rand v0.6.5 Update palette to 0.5. amethyst/rendy#268 (palette -> phf_codegen -> phf_generator -> rand)
syn v0.14.9 Update palette to 0.5. amethyst/rendy#268
syn v0.15.44 alga-derive > 0.9.2 dimforge/alga#94
tiff v0.2.2 gltf-rs/gltf#278 Bump image in gltf https://github.com/gltf-rs/gltf
tiff v0.2.2 Bump winit

Somehow it's gotten worse

@stale
Copy link

stale bot commented Aug 15, 2020

This issue has been automatically marked as stale because it has not had recent activity. Maybe it's time to revisit this?

@stale stale bot added the stale Issue had no recent activity label Aug 15, 2020
@CleanCut
Copy link
Member

Yes, thank you stalebot! I added a reference to this issue in #2407 where we are tracking ways we can improve CI -- I think we should clean this up once as much as we can and then add some CI to watch for regressions.

@stale stale bot removed the stale Issue had no recent activity label Aug 21, 2020
@ezpuzz
Copy link
Contributor

ezpuzz commented Jan 16, 2021

#2590 has gotten build time to around 100s on ryzen 1950x from clean. rendy and atelier-assets trees have lots of duplication but because they are internal crates we can manage their dependency updates with github actions / dependabot. already have dependabot running for rendy.

I've also disabled some unused default-features on crates to shorten build times a bit. I will be adding dependabot config from rendy to amethyst repo.

@AnneKitsune
Copy link
Contributor

Currently, we have heavy issues with bloat and having too many dependencies. This will be addressed, but will take a lot of time and will never be "complete". As such, instead of tracking progress in this issue, we'll progressively work to reduce our dependency list and update it whenever we can. To encourage this, we will encourage the use of smaller dependencies whenever possible. We will also notify people with merge access that pull requests that add dependencies should be carefully looked at starting from now.

We will not be tracking tasks here (because the list would be endless and keep changing), but that doesn't mean you can't help!
Use the command provided in the description as well as looking at cargo tree in general, try to reduce the dependencies count and open a pull request with the changes when you have the chance. Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
team: engine type: maintenance A task that has no noticeable user-facing effect. Code cleanup, small refactors, etc.
Projects
None yet
Development

No branches or pull requests

7 participants