-
-
Notifications
You must be signed in to change notification settings - Fork 72
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
SOH allocation issues #41
Comments
I'll check and mention you!! |
Using stack memory introduces some potential risks that need careful consideration. before // Build sampling pattern aligned to desired velocity.
float[] pat = new float[(DT_MAX_PATTERN_DIVS * DT_MAX_PATTERN_RINGS + 1) * 2]; after // Build sampling pattern aligned to desired velocity.
int patSize = (DT_MAX_PATTERN_DIVS * DT_MAX_PATTERN_RINGS + 1) * 2;
RcStackArray512<float> pat = RcStackArray512<float>.Empty;
ThrowHelper.ThrowExceptionIfIndexOutOfRange(patSize - 1, pat.Length); |
Hey, thanks for taking the time to look at the issue. The solution is a bit above my league so I can't really say anything. But if you wish to release a preview version I can see if the SOH warnings are gone |
I added RcRentedArray, which internally utilizes the functionality of ArrayPool. If everything seems fine with its features and usage, I will release it and mention you. Thank you for reporting the issue. [Test]
public void Test()
{
var rand = new RcRand();
for (int loop = 0; loop < 1024; ++loop)
{
int length = (int)(rand.Next() * 2048);
var values = RandomValues(length);
using var array = RcRentedArray.RentDisposableArray<float>(length);
for (int i = 0; i < array.Length; ++i)
{
array[i] = values[i];
}
for (int i = 0; i < array.Length; ++i)
{
Assert.That(array[i], Is.EqualTo(values[i]));
}
Assert.That(array[^1], Is.EqualTo(values[^1]));
Assert.Throws<IndexOutOfRangeException>(() => array[-1] = 0);
Assert.Throws<IndexOutOfRangeException>(() => array[array.Length + 1] = 0);
Assert.Throws<IndexOutOfRangeException>(() => _ = array[-1]);
Assert.Throws<IndexOutOfRangeException>(() => _ = array[array.Length + 1]);
}
} |
next !! |
fix: SOH issue step2 (#41) #41 fix: SOH issue step3 (#41) - #41 fix : SOH issue (#41) - #41 (comment) fix: SOH issue (#41) - #41 (comment) fix: SOH issue(#41) #41 (comment) array benchmark benchmark array test step2 test ss
fix: SOH issue step2 (#41) #41 fix: SOH issue step3 (#41) - #41 fix : SOH issue (#41) - #41 (comment) fix: SOH issue (#41) - #41 (comment) fix: SOH issue(#41) #41 (comment) array benchmark benchmark array test step2 test ss
fix: SOH issue step2 (#41) #41 fix: SOH issue step3 (#41) - #41 fix : SOH issue (#41) - #41 (comment) fix: SOH issue (#41) - #41 (comment) fix: SOH issue(#41) #41 (comment) array benchmark benchmark array test step2 test ss
fix: SOH issue step2 (#41) #41 fix: SOH issue step3 (#41) - #41 fix : SOH issue (#41) - #41 (comment) fix: SOH issue (#41) - #41 (comment) fix: SOH issue(#41) #41 (comment) array benchmark benchmark array test step2 test ss remove unused using dd
fix: SOH issue step2 (#41) #41 fix: SOH issue step3 (#41) - #41 fix : SOH issue (#41) - #41 (comment) fix: SOH issue (#41) - #41 (comment) fix: SOH issue(#41) #41 (comment) array benchmark benchmark array test step2 test ss remove unused using dd
fix: SOH issue step2 (#41) #41 fix: SOH issue step3 (#41) - #41 fix : SOH issue (#41) - #41 (comment) fix: SOH issue (#41) - #41 (comment) fix: SOH issue(#41) #41 (comment) array benchmark benchmark array test step2 test ss remove unused using dd
It was released on 2024.2.1. |
Test with ba68157 It is better to keep the GC pause time within 0.5ms. |
Thank you for the insight, I'll check it out! |
Hello! I'm back with some news.
Top allocations after after:
However there are some methods I would like to be more optimized than it is now. Specifically |
@wrenge What do you think about actually using RcRentedArray.Rent? When I tested it, I was able to reduce the creation of new memory, but I didn’t see any significant speed improvement, so I haven’t applied it. |
Depends on runtime. In CoreClr gc moves objects in memory and defragments it. So allocation itself is pretty fast since its always on top of the heap. However when it comes to garbage collection itself, the performance hit can be significant. It also depends on gc implementation. Server one collects garbage rarely. But it does a lot. The memory consumption is higher. Client one collects much more often, but memory consumption is lower. In unity and mono (correct if I'm wrong) gc doesn't move objects. So allocation is slower. The reason why I started to care about memory consumption is because my dedicated server was generating so much garbage, the runtime runs out of memory and forces gc. |
In #85 I tried to fix most of concering places. |
@wrenge Thank you. I will review the code you contributed whenever I have time and apply it to DotRecast while mentioning you. I apologize for the delayed responses as I am not a full-time open-source developer. |
Hello, We are currently analyzing the contributions you made and applying them to the project. While working on the implementation, there are some parts we do not fully understand, so I would like to ask a question. |
Hello! Since All of this is not neccessary if you rent and return array in the same place. Like using |
It is a similiar principle used in many ECS frameworks to determine if entity is alive or not. |
Thank you for letting me know that I designed it incorrectly. Therefore, I will check if it can be changed to "readonly ref struct RcRentedArray"! |
commit: 156e0f4 BenchmarkDotNet v0.14.0, Windows 11 (10.0.26100.2605)
|
Rider keeps telling me that Small Object Heap allocation is high for the DtCrowd.Update method.
This is my usage
Where the Update method is called every 0.3...
On the pictures above the compiler is complaining about 200mb-ish, but I've seen it complaining about almost 800mb. Do you have any idea of what could it be?
The text was updated successfully, but these errors were encountered: