Skip to content
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

Add feature/native - An arch variant only using native memory #141

Open
genaray opened this issue Sep 25, 2023 · 1 comment
Open

Add feature/native - An arch variant only using native memory #141

genaray opened this issue Sep 25, 2023 · 1 comment
Labels
enhancement New feature or request postponed This feature was postponed to a later release.

Comments

@genaray
Copy link
Owner

genaray commented Sep 25, 2023

Problem

Arch itself uses managed arrays. There's no way around it, this way it can support managed and unmanaged components.
However, not anyone needs managed arrays since they create additional GC pressure.

The hybrid feature/unsafe variant exists to combine unmanaged and managed memory efficiently. However, it is rarely used and is a bit slower than the master. Unfortunately feature/unsafe can not provide a clean way to split between native and managed arrays and therefore it causes a lot of branching during queries or lookups (since it is always forced to check whether it's a managed or unmanaged array that is being accessed: https://github.com/genaray/Arch/blob/feature/unsafe/src/Arch/Core/Chunk.cs#L144 ). I haven't found a clean way yet to separate those and prevent the branching.

Solution

It might be easier and more efficient to create a feature/native branch instead that ONLY uses native memory for those arrays. Classes and references would be forced to lay outside the ECS, but it would be a good fast alternative to the master for those wanting the maximum performance. feature/unsafe would be obsolete and discontinued in favor of feature/native.

@genaray genaray added enhancement New feature or request postponed This feature was postponed to a later release. labels Sep 25, 2023
@genaray genaray changed the title Add feature/native - An arch variant that only uses pure native memory Add feature/native - An arch variant only using native memory Sep 25, 2023
@martindevans
Copy link
Contributor

See Discord discussion here: https://discord.com/channels/1099813114876284928/1100418566706171974/1171139303288602735

Summary: if (RuntimeHelpers.IsReferenceOrContainsReferences<T>()) is JIT intrinsic and is free to branch on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request postponed This feature was postponed to a later release.
Projects
Status: Todo
Development

No branches or pull requests

2 participants