Skip to content

Consider splitting ComponentTicks #4884

Closed

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.

Activity

  1. added
    A-ECSEntities, components, systems, and events
    C-PerformanceA change motivated by improving speed, memory usage or compile times
    on May 31, 2022
  2. alice-i-cecile commented on May 31, 2022

    @alice-i-cecile
    Member

    I'm fully on board with this plan. Before we merge a PR for this, I'd like a benchmark for change detection so we can see the impact.

  3. added
    S-Needs-BenchmarkingThis set of changes needs performance benchmarking to double-check that they help
    on May 31, 2022
  4. james7132 commented on May 31, 2022

    @james7132
    MemberAuthor

    Updated the issue to mention this is blocked on #4883.

  5. added a commit that references this issue on Nov 21, 2022
    55ca7fc
  6. added a commit that references this issue on Jan 22, 2023
    59a312b
  7. added a commit that references this issue on Feb 1, 2023
    3dd0202
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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