Add/fix track_caller attribute on panicking entity accessor methods#8951
Add/fix track_caller attribute on panicking entity accessor methods#8951james7132 merged 3 commits intobevyengine:mainfrom
track_caller attribute on panicking entity accessor methods#8951Conversation
track_caller attribute on panicking entity accessors methodstrack_caller attribute on panicking entity accessor methods
alice-i-cecile
left a comment
There was a problem hiding this comment.
Being able to debug this better would be incredible: I was confused about why track_caller wouldn't work.
nicopap
left a comment
There was a problem hiding this comment.
I had to remember why you'd want the #[inline(never)] and #[cold], but I recall its' because it will avoid too much overhead from that panic call. I would have preferred to see an explanation for them, but alright.
|
would running benches be relevant when changing those functions? |
|
Yeah, it's worth checking. I'll do a bench before merging this. |
Yes, this will avoid having the panic in the hot code path. Maybe adding some comment for that is a good idea.
I suspect there to be little difference between this and the previous version, they should effectively result in the same codegen, but the additional |
Co-authored-by: Giacomo Stevanato <giaco.stevanato@gmail.com>
|
Results are main vs this PR, for relevant benchmarks:
|
|
These benchmarks are noisy for me, even with every other program closed. I'd call this "probably performance-neutral", and this is very impactful for UX. @james7132, if you agree please merge <3 |
|
These do look like they're within margin of error, sans the insert_commands results, which is typically pretty stable and a 10-13% improvement is indeed welcome. Merging. |
Objective
World::entity,World::entity_mutandCommands::entityshould be marked withtrack_callerto display where (in user code) the call with the invalidEntitywas made.Commands::entityalready has the attibute, but it does nothing due to the call tounwrap_or_else.Solution
track_callerattribute to theWorld::entity_mutandWorld::entity.unwrap_or_elsewhich makes thetrack_callerattribute useless (becauseunwrap_or_elseis nottrack_calleritself). The avoid eager evaluation of the panicking branch it is never inlined.