
# Objective Fixes #18103 #17330 introduced a significant compile time performance regression (affects normal builds, clippy, and Rust Analyzer). While it did fix the type-resolution bug (and the general approach there is still our best known solution to the problem that doesn't involve [significant maintenance overhead](https://github.com/bevyengine/bevy/issues/18103#issuecomment-2702724676)), the changes had a couple of issues: 1. It used a Mutex, which poses a significant threat to parallelization. 2. It externalized existing, relatively simple, performance critical Bevy code to a crate outside of our control. I am not comfortable doing that for cases like this. Going forward @bevyengine/maintainer-team should be much stricter about this. 3. There were a number of other areas that introduced complexity and overhead that I consider unnecessary for our use case. On a case by case basis, if we encounter a need for more capabilities we can add them (and weigh them against the cost of doing so). ## Solution 1. I moved us back to our original code as a baseline 2. I selectively ported over the minimal changes required to fix the type resolution bug 3. I swapped `Mutex<BTreeMap<PathBuf, &'static Mutex<CargoManifest>>>` for `RwLock<BTreeMap<PathBuf, CargoManifest>>`. Note that I used the `parking_lot` RwLock because it has a mapping API that enables us to return mapped guards.
38 lines
1.1 KiB
Rust
38 lines
1.1 KiB
Rust
#![expect(missing_docs, reason = "Not all docs are written yet, see #3492.")]
|
|
#![forbid(unsafe_code)]
|
|
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
|
|
#![doc(
|
|
html_logo_url = "https://bevyengine.org/assets/icon.png",
|
|
html_favicon_url = "https://bevyengine.org/assets/icon.png"
|
|
)]
|
|
|
|
use bevy_macro_utils::BevyManifest;
|
|
use encase_derive_impl::{implement, syn};
|
|
|
|
const ENCASE: &str = "encase";
|
|
|
|
fn bevy_encase_path() -> syn::Path {
|
|
let bevy_manifest = BevyManifest::shared();
|
|
bevy_manifest
|
|
.maybe_get_path("bevy_render")
|
|
.map(|bevy_render_path| {
|
|
let mut segments = bevy_render_path.segments;
|
|
segments.push(BevyManifest::parse_str("render_resource"));
|
|
syn::Path {
|
|
leading_colon: None,
|
|
segments,
|
|
}
|
|
})
|
|
.map(|path| {
|
|
let mut segments = path.segments;
|
|
segments.push(BevyManifest::parse_str(ENCASE));
|
|
syn::Path {
|
|
leading_colon: None,
|
|
segments,
|
|
}
|
|
})
|
|
.unwrap_or_else(|| bevy_manifest.get_path(ENCASE))
|
|
}
|
|
|
|
implement!(bevy_encase_path());
|