Skip to content

Consider splitting ComponentTicks #4884

Closed
@james7132

Description

@james7132

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

ComponentTicks is a lopsided datatype. The added ticks are immutable over the lifetime of the component and the changed ticks may be updated every frame. When using them in Changed<T> or Added<T> filters, half the memory fetched goes unused. When writing to it via Mut, cache lines are written out twice as often as they could.

This will likely be blocked on #4883 being resolved first before making any changes here.

What solution would you like?

Split Vec<UnsafeCell<ComponentTicks>> into two Vec<UnsafeCell<u32>> for added and changed ticks. Update related structs (i.e. Added<T>, Changed<T>, ChangeTrackers<T>, Mut<T>) to fetch only the ones needed.

Ideally, this should also enable autovectorization in query code for these filters, which should further speed up change detection filters.

What alternative(s) have you considered?

Leaving change detection as is.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-PerformanceA change motivated by improving speed, memory usage or compile timesS-Needs-BenchmarkingThis set of changes needs performance benchmarking to double-check that they help

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions