Skip to content

Don't create errors for ignored failed commands #19718

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

brianreavis
Copy link
Contributor

@brianreavis brianreavis commented Jun 18, 2025

Objective

Reduce overhead from error handling for ECS commands that intentionally ignore errors, such as try_despawn. These commands currently allocate error objects and pass them to a no-op handler (ignore), which can impact performance when many operations fail.

Fix a hang when removing ChildOf components during entity despawning. Excessive logging of these failures can cause significant hangs (I'm noticing around 100ms).

image

Solution

  • Made the error handler on handle_error_with optional to avoid creating error objects when the error is just going to be swallowed.
  • Replaced remove::<ChildOf> with try_remove::<ChildOf> to suppress expected (?) errors and reduce log noise.

Future Work

  • Take a similar approach for observers

Testing

  • Not super versed with ECS internals! Happy to make changes or go with a completely other approach. The Option approach on handle_error_with is not elegant or super clear, but didn't have any better ideas at the time.
  • I ran these changes on a local project.

@brianreavis brianreavis changed the title Don't create errors for ignored failed commands Don't create errors for ignored failed commands + Jun 18, 2025
@brianreavis brianreavis changed the title Don't create errors for ignored failed commands + Don't create errors for ignored failed commands Jun 18, 2025
@brianreavis brianreavis marked this pull request as draft June 18, 2025 15:43
@brianreavis brianreavis added A-ECS Entities, components, systems, and events C-Performance A change motivated by improving speed, memory usage or compile times D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jun 18, 2025
@brianreavis brianreavis marked this pull request as ready for review June 18, 2025 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Performance A change motivated by improving speed, memory usage or compile times D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Needs-Review Needs reviewer attention (from anyone!) to move forward
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant