-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Add Commands::insert_batch for faster component modification #2693
Copy link
Copy link
Closed
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-PerformanceA change motivated by improving speed, memory usage or compile timesA change motivated by improving speed, memory usage or compile timesD-StraightforwardSimple bug fixes and API improvements, docs, test and examplesSimple bug fixes and API improvements, docs, test and examplesS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!This issue is ready for an implementation PR. Go for it!X-UncontroversialThis work is generally agreed uponThis work is generally agreed upon
Metadata
Metadata
Assignees
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-PerformanceA change motivated by improving speed, memory usage or compile timesA change motivated by improving speed, memory usage or compile timesD-StraightforwardSimple bug fixes and API improvements, docs, test and examplesSimple bug fixes and API improvements, docs, test and examplesS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!This issue is ready for an implementation PR. Go for it!X-UncontroversialThis work is generally agreed uponThis work is generally agreed upon
What problem does this solve or what need does it fill?
Inserting components one at a time is slow.
What solution would you like?
Add
Commands::insert_batchandremove_batchto modify components en-masse in a more efficient way.As discussed in #3227 (comment), this should be a safe, typed equivalent to
EntityWorldMut::insert_by_idsthat's exposed to commands.I think that a builder API that iteratively modifies the underlying
Commandstruct is probably the correct design.What alternative(s) have you considered?
We could use
insert_or_spawn_batchfor the insertion case, but that does not fail in the desired ways at all.Additional context
Follows up on the work from #2673, which added
insert_or_spawn_batch. Ideally we can use the same strategy for this work, and perform similar benchmarks.