Skip to content

Better entities tracking issue #18719

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
9 tasks
ElliottjPierce opened this issue Apr 4, 2025 · 0 comments
Open
9 tasks

Better entities tracking issue #18719

ElliottjPierce opened this issue Apr 4, 2025 · 0 comments
Labels
A-ECS Entities, components, systems, and events C-Tracking-Issue An issue that collects information about a broad development initiative X-Controversial There is active debate or serious implications around merging this PR

Comments

@ElliottjPierce
Copy link
Contributor

ElliottjPierce commented Apr 4, 2025

Objective

I've been deep in Bevy's entity code for a few weeks now, working on remote entity reservation. Having become pretty familiar with it, there's a few areas I think we can significantly improve.

This is a tracking issues for my ideas here. Each one deserves discussion, but since they are separate issues, I figured a tracking issue would be better than a discussion post with disjoint comments.

Roadmap

  • Remove old alloc_at functionality. Remove insert_or_spawn function family #18148 . This was a performance foot gun for users and it made Entities overly restrictive.
  • Properly handle u32::MAX index entity. Right now, this is a bug in Entities. One solution is out here: Make entity::index non max #18704 . (But that's still up for debate).
  • Make generations u32 in a new type.
  • Make TableRow, ArchetypeRow, etc non-max. Maybe even their ids too.
  • Implement remote entity reservation. Remote entity reservation v9 #18670 is a clear winner for this IMO. It has better performance than main while offering a much more flexible interface.
  • Remove the Identifier system. This is an ecs utility that is only used by Entity. But these changes make Entity pretty unique as far as identifiers go, and given that the identifier system is only used by entities, I think we can safely let this go to reduce complexity.
  • Make ComponentId an EntityRow via a wrapper. This is the first step in components as entities.
  • Create a custom ComponentId map that is an optimized HashMap<ComponentId, T>. This would be a vec index for the first SOME_CONSTANT entities and then a hashmap after that.
  • Allow getting a Entity from an EntityRow through Entities (unsafe).

These changes open up the door for a lot of other improvements, but those can come later. These are my hopes/dreams for entities themselves. Note that while some tasks depend on others, this isn't an all or nothing effort (hence not being a discussion post). Bevy can pick and choose which of these ideas to discard or prioritize etc. But hopefully this gives a clear vision of what I think the entity system can become and how we can use it to improve performance and flexibility, especially with components as entities on the horizon.

As a side note, this is in the same spirit as the rules from this post (which I completely agree with.)

@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events C-Tracking-Issue An issue that collects information about a broad development initiative X-Controversial There is active debate or serious implications around merging this PR labels Apr 5, 2025
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-Tracking-Issue An issue that collects information about a broad development initiative X-Controversial There is active debate or serious implications around merging this PR
Projects
None yet
Development

No branches or pull requests

2 participants