-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Print a warning for un-applied commands being dropped from a CommandQueue #11146
Conversation
@@ -161,6 +162,9 @@ impl CommandQueue { | |||
|
|||
impl Drop for CommandQueue { | |||
fn drop(&mut self) { | |||
if !self.bytes.is_empty() { |
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 we should only warn in debug mode and save an additional check here
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.
The bevy book recommends compiling bevy with opt-level=3
. Disabling in debug mode means people who follow those instructions won't see the warning, making it pretty useless.
I do agree however that we could avoid checks, and additional binary bloat (log statements add a fairly large number of instructions, without counting the log message) But not sure how. I see some alternatives:
- Use
info!
, so that the log can be disabled at compile-time using thelog/max_level_warn
feature - (controversial I think) use the
detailed_trace
feature - Add a new feature, enabled by default, something like
costly_runtime_checks
and use it as a feature gate for the check.
Honestly, I don't prefer any in particular, all have their appeal and tradeoffs, and I don't think it's very important to avoid the check/log here.
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.
The bevy book recommends compiling bevy with opt-level=3. Disabling in debug mode means people who follow those instructions won't see the warning, making it pretty useless.
Debug checks are still included when compiling with optimizations, as long as you don't switch to release mode.
That said, I don't think it's worth spending too much thought on this check. For regular systems, or exclusive systems that properly reuse their SystemState, command queues will only get dropped when the app exit. The only time this check will be called unnecessarily is if users create a new SystemState every time the system runs, which is a performance pitfall of its own that's going to matter a lot more than this check.
Here is a gist with code to test the feature: https://gist.github.com/nicopap/cbff7a6dd36df728dd73ec40914bf931 It should show the warn, and when line 38 is uncommented, it shouldn't. |
Objective
CommandQueue
gets dropped with un-applied commands #11125Solution
Add a warning for un-applied commands to the
drop
function.