Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bevy depends on 4 different versions of the windows crate #11244

Open
Veykril opened this issue Jan 7, 2024 · 8 comments
Open

Bevy depends on 4 different versions of the windows crate #11244

Veykril opened this issue Jan 7, 2024 · 8 comments
Labels
C-Bug An unexpected or incorrect behavior C-Dependencies A change to the crates that Bevy depends on C-Performance A change motivated by improving speed, memory usage or compile times O-Windows Specific to the Windows desktop operating system

Comments

@Veykril
Copy link
Contributor

Veykril commented Jan 7, 2024

Bevy version

  • Original: 0.12.1
  • Current: 0.12.1

Relevant system information

❯ cargo --version
cargo 1.77.0-nightly (ac6bbb332 2023-12-26)

on windows 10

What's performing poorly?

This is not necessarily a regression, but it was the template that fits best. Bevy currently depends on 4 versions of the windows crate, namely 0.44.0, 0.46.0, 0.48.0 and 0.52.0:

windows v0.44.0
└── gpu-allocator v0.22.0
    └── wgpu-hal v0.17.2
        ├── wgpu v0.17.2
        │   └── bevy_render v0.12.1
        │       ├── bevy_animation v0.12.1
        │       │   ├── bevy_gltf v0.12.1 (*)
        │       │   └── bevy_internal v0.12.1 (*)
        │       ├── bevy_core_pipeline v0.12.1
        │       │   ├── bevy-inspector-egui v0.22.1 (*)
        │       │   ├── bevy_gizmos v0.12.1
        │       │   │   └── bevy_internal v0.12.1 (*)
        │       │   ├── bevy_gltf v0.12.1 (*)
        │       │   ├── bevy_internal v0.12.1 (*)
        │       │   ├── bevy_pbr v0.12.1
        │       │   │   ├── bevy-inspector-egui v0.22.1 (*)
        │       │   │   ├── bevy_gizmos v0.12.1 (*)
        │       │   │   ├── bevy_gltf v0.12.1 (*)
        │       │   │   └── bevy_internal v0.12.1 (*)
        │       │   ├── bevy_sprite v0.12.1
        │       │   │   ├── bevy_gizmos v0.12.1 (*)
        │       │   │   ├── bevy_internal v0.12.1 (*)
        │       │   │   ├── bevy_text v0.12.1
        │       │   │   │   ├── bevy_internal v0.12.1 (*)
        │       │   │   │   └── bevy_ui v0.12.1
        │       │   │   │       └── bevy_internal v0.12.1 (*)
        │       │   │   └── bevy_ui v0.12.1 (*)
        │       │   └── bevy_ui v0.12.1 (*)
        │       ├── bevy_gizmos v0.12.1 (*)
        │       ├── bevy_gltf v0.12.1 (*)
        │       ├── bevy_internal v0.12.1 (*)
        │       ├── bevy_pbr v0.12.1 (*)
        │       ├── bevy_scene v0.12.1
        │       │   ├── bevy_gltf v0.12.1 (*)
        │       │   └── bevy_internal v0.12.1 (*)
        │       ├── bevy_sprite v0.12.1 (*)
        │       ├── bevy_text v0.12.1 (*)
        │       └── bevy_ui v0.12.1 (*)
        └── wgpu-core v0.17.1
            └── wgpu v0.17.2 (*)
windows v0.46.0
└── cpal v0.15.2
    └── rodio v0.17.3
        └── bevy_audio v0.12.1
            └── bevy_internal v0.12.1
                └── bevy v0.12.1
windows v0.48.0
└── accesskit_windows v0.15.1
    └── accesskit_winit v0.15.0
        └── bevy_winit v0.12.1
            └── bevy_internal v0.12.1
                └── bevy v0.12.1
windows v0.52.0
└── gilrs-core v0.5.10
    └── gilrs v0.10.4
        └── bevy_gilrs v0.12.1
            └── bevy_internal v0.12.1
                └── bevy v0.12.1

This is a pretty big issue for rust-analyzer users at least (and I assume not too nice for compilation speed either). Why? Well, these crates are absolutely massive, and due to how rust-analyzer works (for the time being, ideally it wouldn't), rust-analyzer currently loads every source file into memory at start up for speed (and unfortunately duplicates this for normalizing file endings). This wastes a ton of memory due to the windows crate being enormous in source code size (a whopping 1.5 - 1.6gb!), and this is without any other related computed information like early name resolution which could be pretty big for these crates as well!

Now this is not a problem for bevy itself, but certainly for the user experience of people working with the engine in rust-analyzer so I figured I should bring this up.

Additional information

rust-lang/rust-analyzer#16301

@Veykril Veykril added C-Bug An unexpected or incorrect behavior C-Performance A change motivated by improving speed, memory usage or compile times P-Regression Functionality that used to work but no longer does. Add a test for this! S-Needs-Triage This issue needs to be labelled labels Jan 7, 2024
@alice-i-cecile alice-i-cecile added C-Dependencies A change to the crates that Bevy depends on O-Windows Specific to the Windows desktop operating system and removed S-Needs-Triage This issue needs to be labelled P-Regression Functionality that used to work but no longer does. Add a test for this! labels Jan 7, 2024
@rlidwka
Copy link
Contributor

rlidwka commented Jan 7, 2024

cargo tree -d is a cool command, we should probably pay more attention to what it says

@mockersf
Copy link
Member

mockersf commented Jan 7, 2024

it's known, Bevy CI used to fail on this... but not much we can do as the dependencies don't have all the same lifecycle.

it should "only" impact the build time and the bin size, not performance

@Veykril
Copy link
Contributor Author

Veykril commented Jan 7, 2024

Well, feel free to close this. Just wanted to raise for awareness as r-a is kind of limited in what it can do here currently. I have a small idea that will get memory waste from this down by a third, gonna try implementing that next week, but that still leaves a lot of memory.

@Veykril
Copy link
Contributor Author

Veykril commented Jan 8, 2024

Okay, rust-lang/rust-analyzer#16307 will get rid of the extra in memory source file stores, so this can be closed if you don't think this is a problem for you to track. I would seriously recommend though trying to get rid of windows crate duplication as it is just a really damn massive crate in terms of source size. Someone checking out rust + bevy for the first time will download 700mbs of source files to their crates io index just for those 4 crates.

@lnicola
Copy link

lnicola commented Jan 8, 2024

N.b.: that gets rid of the extra copy, but we still store all the source code of the four crates in memory (as described above).

@JMS55 JMS55 added this to the 0.13 milestone Jan 8, 2024
@VirxEC
Copy link

VirxEC commented Jan 9, 2024

At the very least, windows v0.44.0 will be dropped when 0.13 lands and wgpu is updated to 0.18.

@Vrixyz
Copy link
Member

Vrixyz commented Jan 11, 2024

I got curious so ran cargo bloat:

on my machine the example 2d_gizmos, windows ends up taking 0.1% of the file size, 107.7KiB on my machine.

Size in binary is not the main point of this issue but it's interesting nonetheless.

Details

cargo bloat -n 250 --crates --example 2d_gizmos
Finished dev [unoptimized + debuginfo] target(s) in 0.53s
Analyzing C:\Users\thier\Documents\cargo_target_dir\debug\examples\2d_gizmos.exe

File .text Size Crate
7.4% 10.1% 5.4MiB wgpu
6.3% 8.5% 4.6MiB bevy_render
5.7% 7.7% 4.1MiB bevy_pbr
3.1% 4.2% 2.2MiB bevy_core_pipeline
2.7% 3.7% 2.0MiB bevy_ui
2.6% 3.6% 1.9MiB wgpu_hal
2.5% 3.5% 1.8MiB taffy
2.5% 3.4% 1.8MiB naga
2.0% 2.8% 1.5MiB bevy_gltf
1.9% 2.6% 1.4MiB bevy_asset
1.8% 2.4% 1.3MiB bevy_sprite
1.7% 2.3% 1.2MiB bevy_reflect
1.6% 2.2% 1.2MiB bevy_input
1.6% 2.2% 1.2MiB regex_automata
1.6% 2.1% 1.1MiB bevy_window
1.4% 1.9% 1.0MiB bevy_ecs
1.4% 1.9% 1.0MiB gltf_json
1.3% 1.7% 933.7KiB regex_syntax
1.3% 1.7% 929.1KiB bevy_audio
1.2% 1.6% 877.0KiB aho_corasick
1.1% 1.4% 786.3KiB bevy_winit
1.1% 1.4% 783.6KiB bevy_text
1.0% 1.3% 735.2KiB bevy_scene
1.0% 1.3% 705.5KiB naga_oil
0.9% 1.2% 667.6KiB std
0.9% 1.2% 665.1KiB bevy_animation
0.9% 1.2% 664.1KiB bevy_gizmos
0.8% 1.1% 617.8KiB wgpu_core
0.8% 1.1% 598.9KiB data_encoding
0.6% 0.9% 470.5KiB tracing_subscriber
0.5% 0.7% 394.4KiB bevy_transform
0.5% 0.7% 360.0KiB bevy_time
0.4% 0.6% 329.3KiB lewton
0.4% 0.6% 301.4KiB winit
0.4% 0.5% 291.3KiB ttf_parser
0.3% 0.4% 212.8KiB gilrs
0.3% 0.4% 203.7KiB rodio
0.3% 0.4% 198.3KiB image
0.3% 0.4% 196.2KiB gilrs_core
0.3% 0.3% 189.8KiB gltf
0.3% 0.3% 185.8KiB bevy_core
0.2% 0.3% 174.2KiB glow
0.2% 0.3% 170.6KiB ruzstd
0.2% 0.3% 164.1KiB accesskit_consumer
0.2% 0.3% 159.8KiB png
0.2% 0.3% 155.3KiB sysinfo
0.2% 0.3% 154.6KiB accesskit_windows
0.2% 0.3% 148.9KiB bevy_app
0.2% 0.3% 143.2KiB memchr
0.2% 0.2% 129.1KiB bevy_internal
0.2% 0.2% 126.4KiB ash
0.2% 0.2% 126.2KiB bevy_hierarchy
0.2% 0.2% 121.3KiB cpal
0.2% 0.2% 117.2KiB gpu_allocator
0.2% 0.2% 113.5KiB rustc_demangle
0.1% 0.2% 109.4KiB async_fs
0.1% 0.2% 107.7KiB windows
0.1% 0.2% 102.5KiB serde_json
0.1% 0.2% 92.4KiB bevy_gilrs
0.1% 0.2% 91.9KiB ron
0.1% 0.2% 85.0KiB wgpu_types
0.1% 0.2% 84.6KiB codespan_reporting
0.1% 0.1% 80.7KiB bevy_tasks
0.1% 0.1% 80.5KiB windows_core
0.1% 0.1% 66.7KiB tracing_core
0.1% 0.1% 65.7KiB ab_glyph
0.1% 0.1% 60.6KiB d3d12
0.1% 0.1% 59.9KiB fdeflate
0.1% 0.1% 57.8KiB bevy_log
0.1% 0.1% 57.6KiB backtrace
0.1% 0.1% 57.5KiB async_executor
0.1% 0.1% 56.2KiB accesskit
0.1% 0.1% 55.7KiB ogg
0.1% 0.1% 55.1KiB hassle_rs
0.1% 0.1% 53.3KiB hashbrown
0.1% 0.1% 49.8KiB glam
0.1% 0.1% 49.3KiB blake3
0.1% 0.1% 45.0KiB parking_lot
0.1% 0.1% 40.0KiB parking_lot_core
0.0% 0.1% 34.7KiB gpu_alloc
0.0% 0.1% 34.5KiB base64
0.0% 0.1% 34.1KiB blocking
0.0% 0.1% 29.6KiB simd_adler32
0.0% 0.1% 29.4KiB bevy_a11y
0.0% 0.1% 28.7KiB bevy_mikktspace
0.0% 0.1% 28.2KiB const_panic
0.0% 0.0% 27.4KiB event_listener
0.0% 0.0% 26.0KiB crossbeam_utils
0.0% 0.0% 25.0KiB widestring
0.0% 0.0% 25.0KiB tracing_log
0.0% 0.0% 24.6KiB owned_ttf_parser
0.0% 0.0% 22.2KiB bevy_diagnostic
0.0% 0.0% 22.1KiB async_lock
0.0% 0.0% 21.6KiB ab_glyph_rasterizer
0.0% 0.0% 21.3KiB uuid
0.0% 0.0% 21.0KiB guillotiere
0.0% 0.0% 19.2KiB ktx2
0.0% 0.0% 17.8KiB termcolor
0.0% 0.0% 17.4KiB thread_local
0.0% 0.0% 17.0KiB libloading
0.0% 0.0% 16.8KiB sharded_slab
0.0% 0.0% 15.1KiB nu_ansi_term
0.0% 0.0% 14.9KiB enum2$<regex_syntax
0.0% 0.0% 14.7KiB bevy_utils
0.0% 0.0% 14.0KiB fixedbitset
0.0% 0.0% 13.4KiB unicode_segmentation
0.0% 0.0% 12.5KiB async_task
0.0% 0.0% 11.6KiB regex
0.0% 0.0% 10.7KiB parking
0.0% 0.0% 10.7KiB crc32fast
0.0% 0.0% 9.7KiB hexf_parse
0.0% 0.0% 9.6KiB twox_hash
0.0% 0.0% 9.5KiB serde
0.0% 0.0% 9.1KiB crossbeam_channel
0.0% 0.0% 8.7KiB fastrand
0.0% 0.0% 8.6KiB percent_encoding
0.0% 0.0% 8.5KiB enum2$<accesskit_windows
0.0% 0.0% 8.4KiB piper
0.0% 0.0% 8.0KiB miniz_oxide
0.0% 0.0% 7.7KiB smol_str
0.0% 0.0% 7.6KiB log
0.0% 0.0% 7.1KiB flume
0.0% 0.0% 7.0KiB once_cell
0.0% 0.0% 6.7KiB spirv
0.0% 0.0% 6.6KiB gpu_alloc_types
0.0% 0.0% 6.3KiB enum2$<wgpu_hal
0.0% 0.0% 6.3KiB bevy_ptr
0.0% 0.0% 5.8KiB bit_vec
0.0% 0.0% 5.4KiB futures_io
0.0% 0.0% 5.2KiB color_quant
0.0% 0.0% 5.2KiB encase
0.0% 0.0% 5.2KiB hexasphere
0.0% 0.0% 4.9KiB enum2$<gilrs_core
0.0% 0.0% 4.3KiB getrandom
0.0% 0.0% 4.2KiB futures_lite
0.0% 0.0% 4.0KiB xi_unicode
0.0% 0.0% 3.5KiB enum2$<bevy_pbr
0.0% 0.0% 3.4KiB winapi_util
0.0% 0.0% 3.4KiB enum2$<nu_ansi_term
0.0% 0.0% 3.4KiB atomic_waker
0.0% 0.0% 3.2KiB raw_window_handle
0.0% 0.0% 3.0KiB tracing
0.0% 0.0% 3.0KiB enum2$<ttf_parser
0.0% 0.0% 2.9KiB bevy_math
0.0% 0.0% 2.5KiB flate2
0.0% 0.0% 2.4KiB [Unknown]
0.0% 0.0% 2.4KiB num_traits
0.0% 0.0% 2.2KiB petgraph
0.0% 0.0% 2.1KiB _2d_gizmos
0.0% 0.0% 2.0KiB glyph_brush_layout
0.0% 0.0% 1.9KiB erased_serde
0.0% 0.0% 1.9KiB indexmap
0.0% 0.0% 1.9KiB futures_core
0.0% 0.0% 1.9KiB enum2$<naga
0.0% 0.0% 1.7KiB winapi
0.0% 0.0% 1.7KiB svg_fmt
0.0% 0.0% 1.4KiB enum2$<regex_automata
0.0% 0.0% 1.1KiB enum2$<tracing_core
0.0% 0.0% 999B unicode_ident
0.0% 0.0% 964B enum2$<gilrs
0.0% 0.0% 964B 2d_gizmos
0.0% 0.0% 961B enum2$<bevy_gltf
0.0% 0.0% 910B glutin_wgl_sys
0.0% 0.0% 847B unicode_width
0.0% 0.0% 756B slotmap
0.0% 0.0% 709B smallvec
0.0% 0.0% 662B arrayvec
0.0% 0.0% 597B unicode_xid
0.0% 0.0% 579B matchers
0.0% 0.0% 542B enum2$<smol_str
0.0% 0.0% 473B allocator_api2
0.0% 0.0% 467B num_rational
0.0% 0.0% 455B bytemuck
0.0% 0.0% 454B enum2$<cpal
0.0% 0.0% 454B rustc_hash
0.0% 0.0% 434B enum2$<tracing_subscriber
0.0% 0.0% 425B ahash
0.0% 0.0% 369B gpu_descriptor
0.0% 0.0% 312B async_channel
0.0% 0.0% 305B enum2$<regex
0.0% 0.0% 275B com_rs
0.0% 0.0% 274B byteorder
0.0% 0.0% 252B num_integer
0.0% 0.0% 247B
0.0% 0.0% 218B dasp_sample
0.0% 0.0% 192B gpu_descriptor_types
0.0% 0.0% 191B enum2$<wgpu_core
0.0% 0.0% 167B async_broadcast
0.0% 0.0% 148B enum2$<gpu_alloc
0.0% 0.0% 127B enum2$<parking_lot_core
0.0% 0.0% 122B cursor_icon
0.0% 0.0% 114B event_listener_strategy
0.0% 0.0% 100B enum2$<log
0.0% 0.0% 89B enum2$<backtrace
0.0% 0.0% 65B enum2$<event_listener
0.0% 0.0% 63B bitflags
0.0% 0.0% 55B lock_api
0.0% 0.0% 55B enum2$<glyph_brush_layout
0.0% 0.0% 53B accesskit_winit
0.0% 0.0% 30B `__scrt_common_main_seh'
0.0% 0.0% 19B zerocopy
73.8% 100.0% 53.5MiB .text section size, the file size is 72.5MiB

Note: numbers above are a result of guesswork. They are not 100% correct and never will be.

@JMS55
Copy link
Contributor

JMS55 commented Jan 26, 2024

We're currently down to 3 copies (2 outdated)

  1. One will be fixed by updating accesskit_winit Update accesskit_winit requirement from 0.17 to 0.18 #11466
  2. One of them needs rodio->cpal to update their windows dependency

@JMS55 JMS55 removed this from the 0.13 milestone Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Bug An unexpected or incorrect behavior C-Dependencies A change to the crates that Bevy depends on C-Performance A change motivated by improving speed, memory usage or compile times O-Windows Specific to the Windows desktop operating system
Projects
None yet
Development

No branches or pull requests

8 participants