Performance degredation when enabling `wgpu` dep
@cachebag is already working on this.
Since Sep 23, 2025.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
https://github.com/GraphiteEditor/Graphite/ is seeing terrible rustc performance when compiling graphene-core (./node-graph/gcore) with the wgpu feature (3m 07s clean) vs without (52.57s clean). The wgpu feature only enables the wgpu dependency and only has a two #[cfg]'ed blocks of ~50 lines to provide an alternative implementation if not enabled. With such a relatively small difference, a compile time increase of over 200% is quite unexpected. Using -Ztime-passes reveals that the passes coherence_checking, type_check_crate and generate_crate_metadata take significantly longer.
Test methodology
With RUSTFLAGS="-Ztime-passes" potentially multiple crates are all printed into a single log. So I'm running a warmup phase to build all dependencies, then selectively delete the build artifacts of graphene-core and build again with -j 1. This seems to separate the time-passes values of graphene-core to be printed after cargo printing Compiling graphene-core v0.1.0. Though, there are a bunch of other time-passes before that I cannot associate to a specific crate.
cargo clean
export CARGO_INCREMENTAL=false RUSTFLAGS="-Ztime-passes"
cargo +nightly b -p graphene-core &> warmup.log
cargo +nightly b -p graphene-core --features wgpu &> warmup_wgpu.log
rm ./target/debug/deps/*graphene_core-* ./target/debug/libgraphene_core.* -v
cargo +nightly b -p graphene-core -j 1 &> measure.log
cargo +nightly b -p graphene-core --features wgpu -j 1 &> measure_wgpu.log
Results
only passes above 1s, large changes marked italic
| pass | default | wgpu |
|---|---|---|
| coherence_checking | 0.476 | 44.813 |
| type_check_crate | 2.174 | 93.618 |
| MIR_borrow_checking | 3.360 | 5.863 |
| monomorphization_collector_graph_walk | 1.587 | 3.291 |
| generate_crate_metadata | 2.192 | 48.571 |
| codegen_to_LLVM_IR | 2.034 | 2.131 |
| codegen_crate | 16.511 | 16.062 |
| LLVM_passes | 46.112 | 45.793 |
| finish_ongoing_codegen | 29.703 | 29.860 |
| total | 55.406 | 195.463 |
time-passes log default
Compiling graphene-core v0.1.0 (/home/firestar99/workspace/graphite/node-graph/gcore)
time: 0.001; rss: 38MB -> 40MB ( +2MB) parse_crate
time: 0.000; rss: 45MB -> 45MB ( +0MB) crate_injection
time: 0.613; rss: 45MB -> 236MB ( +191MB) expand_crate
time: 0.613; rss: 45MB -> 236MB ( +191MB) macro_expand_crate
time: 0.000; rss: 236MB -> 236MB ( +0MB) maybe_building_test_harness
time: 0.011; rss: 236MB -> 236MB ( +0MB) AST_validation
time: 0.004; rss: 236MB -> 238MB ( +2MB) finalize_imports
time: 0.006; rss: 238MB -> 241MB ( +2MB) compute_effective_visibilities
time: 0.000; rss: 241MB -> 241MB ( +0MB) lint_reexports
time: 0.004; rss: 241MB -> 241MB ( +1MB) finalize_macro_resolutions
time: 0.119; rss: 241MB -> 281MB ( +40MB) late_resolve_crate
time: 0.000; rss: 281MB -> 281MB ( +0MB) resolve_main
time: 0.011; rss: 281MB -> 282MB ( +0MB) resolve_check_unused
time: 0.017; rss: 282MB -> 282MB ( +0MB) resolve_postprocess
time: 0.162; rss: 236MB -> 282MB ( +46MB) resolve_crate
time: 0.009; rss: 282MB -> 283MB ( +0MB) write_dep_info
time: 0.008; rss: 283MB -> 283MB ( +0MB) complete_gated_feature_checking
time: 0.021; rss: 324MB -> 324MB ( +0MB) drop_ast
time: 0.000; rss: 306MB -> 306MB ( +0MB) looking_for_entry_point
time: 0.001; rss: 306MB -> 306MB ( +0MB) looking_for_derive_registrar
time: 0.000; rss: 304MB -> 304MB ( +0MB) unused_lib_feature_checking
time: 0.036; rss: 306MB -> 305MB ( -1MB) misc_checking_1
time: 0.476; rss: 305MB -> 395MB ( +90MB) coherence_checking
time: 0.000; rss: 395MB -> 395MB ( +0MB) emit_ast_lowering_delayed_lints
time: 2.174; rss: 305MB -> 526MB ( +221MB) type_check_crate
time: 3.360; rss: 526MB -> 672MB ( +146MB) MIR_borrow_checking
time: 0.047; rss: 673MB -> 673MB ( +0MB) module_lints
time: 0.047; rss: 673MB -> 673MB ( +0MB) lint_checking
time: 0.058; rss: 673MB -> 674MB ( +0MB) privacy_checking_modules
time: 0.132; rss: 672MB -> 674MB ( +1MB) misc_checking_3
time: 0.001; rss: 702MB -> 702MB ( +0MB) monomorphization_collector_root_collections
time: 1.587; rss: 702MB -> 837MB ( +135MB) monomorphization_collector_graph_walk
time: 0.122; rss: 838MB -> 855MB ( +17MB) partition_and_assert_distinct_symbols
time: 2.192; rss: 674MB -> 855MB ( +182MB) generate_crate_metadata
time: 0.000; rss: 855MB -> 855MB ( +0MB) find_cgu_reuse
time: 2.034; rss: 855MB -> 1035MB ( +180MB) codegen_to_LLVM_IR
time: 16.511; rss: 855MB -> 1035MB ( +180MB) codegen_crate
time: 0.000; rss: 1035MB -> 1035MB ( +0MB) serialize_dep_graph
time: 46.112; rss: 877MB -> 765MB ( -112MB) LLVM_passes
time: 0.005; rss: 663MB -> 616MB ( -47MB) join_worker_thread
time: 29.703; rss: 719MB -> 616MB ( -104MB) finish_ongoing_codegen
time: 0.108; rss: 616MB -> 628MB ( +12MB) link_rlib
time: 0.019; rss: 628MB -> 628MB ( +0MB) link_binary_remove_temps
time: 0.129; rss: 616MB -> 628MB ( +12MB) link_binary
time: 0.129; rss: 616MB -> 616MB ( +1MB) link_crate
time: 0.129; rss: 616MB -> 616MB ( +1MB) link
time: 55.406; rss: 28MB -> 139MB ( +111MB) total
Finished `dev` profile [optimized + debuginfo] target(s) in 55.75s
time-passes log wgpu
Compiling graphene-core v0.1.0 (/home/firestar99/workspace/graphite/node-graph/gcore)
time: 0.001; rss: 38MB -> 40MB ( +2MB) parse_crate
time: 0.000; rss: 45MB -> 45MB ( +0MB) crate_injection
time: 0.606; rss: 45MB -> 235MB ( +190MB) expand_crate
time: 0.607; rss: 45MB -> 235MB ( +190MB) macro_expand_crate
time: 0.000; rss: 235MB -> 236MB ( +0MB) maybe_building_test_harness
time: 0.010; rss: 236MB -> 236MB ( +0MB) AST_validation
time: 0.004; rss: 236MB -> 238MB ( +2MB) finalize_imports
time: 0.006; rss: 238MB -> 240MB ( +2MB) compute_effective_visibilities
time: 0.000; rss: 240MB -> 240MB ( +0MB) lint_reexports
time: 0.004; rss: 240MB -> 241MB ( +1MB) finalize_macro_resolutions
time: 0.124; rss: 241MB -> 290MB ( +49MB) late_resolve_crate
time: 0.000; rss: 290MB -> 290MB ( +0MB) resolve_main
time: 0.011; rss: 290MB -> 291MB ( +0MB) resolve_check_unused
time: 0.015; rss: 291MB -> 291MB ( +0MB) resolve_postprocess
time: 0.165; rss: 236MB -> 291MB ( +55MB) resolve_crate
time: 0.007; rss: 291MB -> 291MB ( +0MB) write_dep_info
time: 0.008; rss: 292MB -> 292MB ( +0MB) complete_gated_feature_checking
time: 0.022; rss: 332MB -> 332MB ( +0MB) drop_ast
time: 0.000; rss: 315MB -> 315MB ( +0MB) looking_for_entry_point
time: 0.001; rss: 315MB -> 315MB ( +0MB) looking_for_derive_registrar
time: 0.000; rss: 313MB -> 313MB ( +0MB) unused_lib_feature_checking
time: 0.032; rss: 315MB -> 314MB ( -1MB) misc_checking_1
time: 44.813; rss: 314MB -> 424MB ( +110MB) coherence_checking
time: 0.000; rss: 424MB -> 424MB ( +0MB) emit_ast_lowering_delayed_lints
time: 93.618; rss: 314MB -> 571MB ( +257MB) type_check_crate
time: 5.863; rss: 571MB -> 778MB ( +207MB) MIR_borrow_checking
time: 0.050; rss: 779MB -> 779MB ( +1MB) module_lints
time: 0.050; rss: 779MB -> 779MB ( +1MB) lint_checking
time: 0.056; rss: 779MB -> 780MB ( +0MB) privacy_checking_modules
time: 0.131; rss: 778MB -> 780MB ( +2MB) misc_checking_3
time: 0.001; rss: 832MB -> 832MB ( +0MB) monomorphization_collector_root_collections
time: 3.291; rss: 832MB -> 1283MB ( +450MB) monomorphization_collector_graph_walk
time: 0.133; rss: 1284MB -> 1300MB ( +16MB) partition_and_assert_distinct_symbols
time: 48.571; rss: 780MB -> 1300MB ( +521MB) generate_crate_metadata
time: 0.000; rss: 1300MB -> 1300MB ( +0MB) find_cgu_reuse
time: 2.131; rss: 1300MB -> 1482MB ( +182MB) codegen_to_LLVM_IR
time: 16.062; rss: 1300MB -> 1482MB ( +182MB) codegen_crate
time: 0.000; rss: 1482MB -> 1482MB ( +0MB) serialize_dep_graph
time: 45.793; rss: 1321MB -> 1108MB ( -213MB) LLVM_passes
time: 0.001; rss: 671MB -> 667MB ( -5MB) join_worker_thread
time: 29.860; rss: 1094MB -> 667MB ( -427MB) finish_ongoing_codegen
time: 0.111; rss: 667MB -> 679MB ( +13MB) link_rlib
time: 0.019; rss: 679MB -> 679MB ( +0MB) link_binary_remove_temps
time: 0.132; rss: 667MB -> 679MB ( +13MB) link_binary
time: 0.133; rss: 667MB -> 665MB ( -1MB) link_crate
time: 0.133; rss: 667MB -> 665MB ( -1MB) link
time: 195.463; rss: 28MB -> 142MB ( +113MB) total
Finished `dev` profile [optimized + debuginfo] target(s) in 3m 15s
raw logs
Meta
rustc --version --verbose:
rustc 1.89.0 (29483883e 2025-08-04)
binary: rustc
commit-hash: 29483883eed69d5fb4db01964cdf2af4d86e9cb2
commit-date: 2025-08-04
host: x86_64-unknown-linux-gnu
release: 1.89.0
LLVM version: 20.1.7
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.