Skip to content

Add a T: Component bound to Mut and Ref smart pointers #23529

@alice-i-cecile

Description

@alice-i-cecile

What problem does this solve or what need does it fill?

While working towards #23152 in #23519, @pcwalton found that while change indexes were a serious performance improvement for use cases that used them, they introduced overhead in the current use cases.

What solution would you like?

This could be alleviated if we had access to metadata about the Component inside of our Mut and Ref smart pointers, triggered when marking data as changed.

To do so, we would need to add a T: Component bound to these.

This change is quite intrusive (many compiler errors!) and distracts from the core work of adding a new change detection strategy, so we should do that before merging #23152, then rebase that branch once this issue is complete.

What alternative(s) have you considered?

We could simply swallow the performance regression.
This would allow us to modify the change detection strategy at runtime.

That would be desirable for allowing users to tune the performance characteristics of their dependencies to meet their needs, but would, as seen in the linked PR, unavoidably introduce performance overhead in all cases.

Additional context

Change ticks are one possible alternate change detection strategy, as proposed in #4882.

If we want zero overhead compile-time configurable change detection, we almost certainly need to do this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-FeatureA new feature, making something new possibleD-ModestA "normal" level of difficulty; suitable for simple features or challenging fixesM-Migration-GuideA breaking change to Bevy's public API that needs to be noted in a migration guideS-BlockedThis cannot move forward until something else changesX-ContentiousThere are nontrivial implications that should be thought through

    Type

    No type

    Projects

    Status

    SME Triaged

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions