-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
The Great Debuggening #632
Conversation
Id like to collect a couple of datapoints on how compile times are affected by this. Can you clean-compile the base of this branch, record the time, then clean compile with these changes? And also do the same for iterative compiles? Ex: compile and run 3d_scene, then insert a newline into 3d_scene, then recompile and record the time? |
I'll do the same before merging. |
Sure. I'll do it both on my Windows desktop and my chromebook. I'm just gonna finish satiating clippy first, so give me at most an hour. |
Apparently on my Windows desktop, I get a linker error code 1120 with the note:
Exciting! This error doesn't show up on the base of the branch, but does with my commits. It seems like these are places where I'm converting a function pointer into another with lifetimes that allow |
Windows
I don't know why it got faster, I'll see if I can reproduce it. Chromebook (Debian Crostini)
|
In macOS on a 16-core (32 logical) Mac Pro in debug mode (all with 4 warm runs, averaged) - clean builds of the More interesting to me was the incremental when using bevy as a library from an external project with all the |
I would've thought that the impact would've been at least noticeable. Rust is impressive. |
I ran tests and I can confirm that its all in the noise on my machine too. Starting a review now! |
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.
In general this looks good, but I think theres been a "impl Debug at all costs" mindset here, which I personally don't agree with. For derive(Debug)
thats not as big of a deal, but its important to call out that custom Debug impls have a number of negative implications:
- not resilient to field renames
- not resilient to field additions
- add code bloat + maintenance burden
I'd appreciate it if we took a second pass and applied the following criteria, with a general mindset of "remove as many custom debug impls as possible" and "remove Debug derives from things that really don't need them":
Things that don't need custom debug impls:
- structs that just print out a pointer or set of pointers
- iterators
- private implementation details like "intermediate serde helpers" and "fetch types in bevy_ecs". keep in mind that people developing these internal implementation details have the freedom to print the things they want to test / impl what they want.
- "large" structs that produce a lot of noise by printing them, especially when the "useful" debuggable fields are individually accessible.
Things that should have custom debug impls:
- Public-facing components / resources / assets that contain "useful" information, but cant derive debug
- Make sure the debug impl avoids printing "useless" information. If a field isn't debuggable id rather not use the NoDebug pattern. NoDebug introduces a lot of code bloat and just produces noise in the printed debug info. Id prefer to just not print those fields.
Things that don't need debug derives:
- unit structs
- types where you can't imagine a reasonable scenario where someone would want the info printed
Alright, I'll do another pass today. Thanks! |
Awesome. Thanks for putting in the work here. People are really going to appreciate this :) |
Also none of the criteria I listed are hard rules. Feel free to use your own judgement on a case-by-case basis and we can talk about cases where we don't agree. |
The iterators don't have custom Debugs anymore, many custom debugs impls now more helpful
Every type in Bevy now has
Debug
implemented.Some caveats:
rodio::Device
,notify::RecommendedWatcher
, andguillotiere::AtlasAllocator
) don't implementDebug
, so I got around this by having custom empty structs in the relevantDebug
impls that have the messageType doesn't implement Debug
for that field value.dyn
s are turned into pointers so that they can be formatted. This could also be solved by makingDebug
be a supertrait of allResource
s etc, but that's easy to change to and adds extra constraints, so I didn't do this in this PR. I'm happy to change it to be that though. With this, at least the pointers are visible and the rest of the type is formatted correctly