Skip to content
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

perf: Reduce component structure check overhead #516

Merged
merged 2 commits into from
Jan 20, 2025

Conversation

bdunderscore
Copy link
Owner

Previously, we issued change events whenever component order changed; this resulted in spurious invocations of listeners,
which when did (potentially very expensive) redundant checks of what components were in their children. In particular, this
was done whenever a component changed; this was probably a bug, as a change event on the GameObject is issued when
component order changes.

This change makes a few adjustments to fix this:

  • We record the child component list in the ShadowGameObject, and only generate change events if it actually changes.
  • We only perform component structure checks when game objects change, not when the components themselves change.
  • We avoid registering complex filters for component structure events; those filters were expensive, frequently redundantly
    registered, and are no longer needed with the new ShadowGameObject component tracking.

Closes: #513

perf: Remove redundant listener filters for MonitorGetComponents

Now that the shadow hierarchy is checking for component structure changes, we don't need to perform these checks in SingleObjectQueries.

Avoiding doing these checks there avoids redundant processing, which is particularly important since these will all generally
converge into the same invalidation.

Previously, we issued change events whenever component order changed; this resulted in spurious invocations of listeners,
which when did (potentially very expensive) redundant checks of what components were in their children. In particular, this
was done whenever a _component_ changed; this was probably a bug, as a change event on the _GameObject_ is issued when
component order changes.

This change makes a few adjustments to fix this:
* We record the child component list in the ShadowGameObject, and only generate change events if it actually changes.
* We only perform component structure checks when _game objects_ change, not when the components themselves change.
* We avoid registering complex filters for component structure events; those filters were expensive, frequently redundantly
registered, and are no longer needed with the new ShadowGameObject component tracking.

Closes: #513

perf: Remove redundant listener filters for MonitorGetComponents

Now that the shadow hierarchy is checking for component structure changes, we don't need to perform these checks in SingleObjectQueries.

Avoiding doing these checks there avoids redundant processing, which is particularly important since these will all generally
 converge into the same invalidation.
@bdunderscore bdunderscore force-pushed the component-monitor-perf branch from 2cf7154 to 1f9f0f6 Compare January 20, 2025 22:30
@bdunderscore bdunderscore merged commit 12e2805 into main Jan 20, 2025
4 checks passed
@bdunderscore bdunderscore deleted the component-monitor-perf branch January 20, 2025 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve detection of component reordering
1 participant