-
-
Notifications
You must be signed in to change notification settings - Fork 4k
ECS: put strings only used for debug behind a feature #19558
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
base: main
Are you sure you want to change the base?
Conversation
I don't understand your table there 🤔 Why are there two rows? |
bytes and megabytes! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. I don't love the increased feature flagging, but I think that this is a reasonable optimization to make, especially in the context of games being deployed to web.
The strategy looks reasonable to me: top-level flag, trickling down, on-by-default.
I'm sure there's more places we could use this, but I'm happy with this as a start.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me the approach does look useful. I left some comments which I hope are helpful. I think I'll leave it to others to given approval though.
crates/bevy_ecs/Cargo.toml
Outdated
@@ -85,6 +85,8 @@ critical-section = [ | |||
|
|||
hotpatching = ["dep:subsecond"] | |||
|
|||
debug = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worth a comment describing the scope of debug
? It reminds me of the the old if environment == dev
checks in code which can become grab bags of everything.
For example in my game I have an entity_names
feature:
commands.spawn((
#[cfg(feature = "entity_names")]
Name::new("Foo"),
));
I could have used a dev
or debug
feature, but I wanted to separate the actual feature in case I want to turn just this feature on for release builds.
To be clear, I think the feature debug
probably makes sense compared to trying to break it down into many little features, but I just wonder if there's room to describe the scope of what a future Bevy developer should expect or be allowed to use this feature for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about doing different features for things like system_name
, component_name
, ... but that would make the features more complex, with more tests needed, and bigger conditions when needing both.
I think a single feature debug
(or maybe with a name around diagnostics? I'm open to another name) is better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally like the name and I don't think it comes across as a grab bag. I just thought a comment here on the possible scope could be useful, but comment is non-blocking. Maybe over time it will be come clear and obvious what should and shouldn't go in this feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think debug_info
would be much clearer and less likely to conflict as a name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What could this actually conflict with?
There is also https://doc.rust-lang.org/rustc/codegen-options/index.html#debuginfo, which could be cause for confusion, not sure though.
But yeah both sound fine to me. If I had to pick myself I'd probably go with debug
, but I don't have a strong argument more than "adding _info
at the end feels overly specific to how the code that it's enabling is used".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking user defined dev-mode flags? I also think it's a clearer / narrower purpose that will allow us to more clearly decide whether or not something else belongs in this flag.
91b1c22
to
bf85334
Compare
Switched to a new That made the diff smaller, and made it easier to use it in more places which increased a bit the size reduction, now 3.7MB! |
Objective
Solution
strings
to find ... strings in a binarytype_name::<T>()
and only used in error / debug messagesDebugName
that holds no value ifdebug
feature is disabledcore::any::type_name::<T>()
byDebugName::type_name::<T>()
Testing
Measurements were taken without the new feature being enabled by default, to help with commands
File Size
I tried building the
breakout
example withcargo run --release --example breakout
debug
enableddebug
disabledCompilation time
hyperfine --min-runs 15 --prepare "cargo clean && sleep 5" 'RUSTC_WRAPPER="" cargo build --release --example breakout' 'RUSTC_WRAPPER="" cargo build --release --example breakout --features debug'