-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[Merged by Bors] - [ecs] Improve Commands
performance
#2332
Conversation
Here is a list of the minimal performance tests I created.
|
I have a feeling that since this is a pretty specialized structure I should probably just move it into |
Hmm, should we maybe pull the commands benchmark into a separate PR and merge it earlier? It's far less controversial than the unsafe anystack impl, and reducing the scope of PR s with unsafe is usually a good thing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like the idea of using an fn
here. Apart from the alignment issue you have pointed out, this looks good.
6a179d1
to
5d6db0f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't checked over the tests in detail, but if this passes miri
, I can believe it's good to go.
I'll go ahead and run miri with this sometime today/tomorrow and report back the results. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, a few docs thoughts
51b2fe0
to
0d75c6b
Compare
Here are the most recent benchmarks (taken from #2334).
|
543522c
to
2fb8a5a
Compare
As @mockersf suggested I created a benchmark that utilized
|
ae297f1
to
2a614b8
Compare
benchmarks for the most recent version. (with special casing for 0 sized commands and ensuring the vector isn't null).
|
9dbe32f
to
a9be103
Compare
@cart this should be good to go now :) |
bors r+ |
# Objective - Currently `Commands` are quite slow due to the need to allocate for each command and wrap it in a `Box<dyn Command>`. - For example: ```rust fn my_system(mut cmds: Commands) { cmds.spawn().insert(42).insert(3.14); } ``` will have 3 separate `Box<dyn Command>` that need to be allocated and ran. ## Solution - Utilize a specialized data structure keyed `CommandQueueInner`. - The purpose of `CommandQueueInner` is to hold a collection of commands in contiguous memory. - This allows us to store each `Command` type contiguously in memory and quickly iterate through them and apply the `Command::write` trait function to each element.
Commands
performanceCommands
performance
# Objective - Currently `Commands` are quite slow due to the need to allocate for each command and wrap it in a `Box<dyn Command>`. - For example: ```rust fn my_system(mut cmds: Commands) { cmds.spawn().insert(42).insert(3.14); } ``` will have 3 separate `Box<dyn Command>` that need to be allocated and ran. ## Solution - Utilize a specialized data structure keyed `CommandQueueInner`. - The purpose of `CommandQueueInner` is to hold a collection of commands in contiguous memory. - This allows us to store each `Command` type contiguously in memory and quickly iterate through them and apply the `Command::write` trait function to each element.
Objective
Commands
are quite slow due to the need to allocate for each command and wrap it in aBox<dyn Command>
.will have 3 separate
Box<dyn Command>
that need to be allocated and ran.Solution
CommandQueueInner
.CommandQueueInner
is to hold a collection of commands in contiguous memory.Command
type contiguously in memory and quickly iterate through them and apply theCommand::write
trait function to each element.