-
-
Notifications
You must be signed in to change notification settings - Fork 63
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
Use overlapped union of sequential layout via Unsafe class? #57
Comments
The purpose of the command recorder is to allow sequential deferred execution of actions saved in parallel so I am not sure what you mean by processing commands in parallel?
This goes with the overlapped union I guess. The problem I see with this is the recording of Set, since you need to record the value which will be set, and obviously we can't know the max size of a command from the start, and even so a lot of space would be lost.
I went with offset for code reuse actually. Since you can create new entities on the recorder but you don't know their ids beforehand, I didn't find a better solution that leave space for the entity when it will be really created on the buffer and save the offset to later retrieve it. For already existing entities, I just save them and use the offset the same way so there is no difference for each case.
not sure what you mean here.
All that unsafe code is ugly but apart the benefit of dropping the unsafe directive I am not sold on the Unsafe class usage, especially if it imply some overhead. I will do some testing and see if it's just bad supposition on my part.
I hesitated to use ArrayPool but decided against for now. Recycling of array sure is nice for initialization speed up but they remained in memory even if you don't need them anymore. There is already a lot of static array used here and there so I didn't want to stress the retained memory further. |
I mean that may be in some future time commands may be processed in parallel. So current design is limiting.
The design of Rust unions to have max size of struct from possible. It is possible to do exactly same in C# manually via field layout and I doubt about much space given limited amount of commands generated per frame. But uniform size of command (choose max) probably will give more capabilites to evolve in future. Size of components matter more.
First field of union could be
I have found Unsafe to be faster is some scenarios. I think it is because CRL has proper type information and may generate better code (inlike with pointers)
Unity has its own allocators https://github.com/dzmitry-lahoda/memory-pool-unity-unsafe. I see people experiment with custom allocators in C# either. So to have reusable ECS probably memory allocations should be abstracted somehow. |
Cleaning old issues as this is not something that's going to change now without a pretty good reason. |
DefaultEcs/source/DefaultEcs/Technical/Command/Executer.cs
Line 9 in f283587
unsafe
compile directive andalien
(star) codeswitch
heavy for custom commands-events (this are marker interface, but optimization will be overlapped union).The text was updated successfully, but these errors were encountered: