-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[mono][gc] Objects larger than LOS section size call the LOS heap to grow without bound #97991
Comments
Tagging subscribers to this area: @BrzVlad Issue Detailsconsider this program: long bigger_than_los_section = 32 * 1024 * 1024;
long bigger_than_small_obj = 100 * 1024;
long small_obj = 50;
long alloc_size = bigger_than_small_obj;
long cnt = 0;
long[] data = new long[1024*1024*32];
var end = DateTime.Now + TimeSpan.FromMilliseconds(10000);
do
{
// these are just dummy computations to keep CPU busy
Interlocked.Increment(ref cnt);
data = new long[alloc_size];
data[0] = cnt;
// force some GC
if(cnt % 10000 == 0)
{
GC.Collect();
var total = GC.GetTotalMemory(true);
Console.WriteLine("GC.GetTotalMemory: "+total);
}
}
while(DateTime.Now<end); if $ MONO_LOG_MASK=gc MONO_LOG_LEVEL=debug dotnet run
...
Mono: GC_MAJOR: (user request) time 0.05ms, stw 0.08ms los size: 1024K in use: 24K
...
Mono: GC_MAJOR: (user request) time 0.05ms, stw 0.06ms los size: 1024K in use: 24K if $ MONO_LOG_MASK=gc MONO_LOG_LEVEL=debug dotnet run
...
Mono: GC_MAJOR_CONCURRENT_FINISH: (finishing) time 0.23ms, stw 0.12ms los size: 3072K in use: 1625K
...
Mono: GC_MAJOR_CONCURRENT_FINISH: (finishing) time 0.24ms, stw 0.14ms los size: 3072K in use: 1625K if $ MONO_LOG_MASK=gc MONO_LOG_LEVEL=debug dotnet run
...
Mono: GC_MAJOR_CONCURRENT_FINISH: (finishing) time 0.20ms, stw 0.13ms los size: 525344K in use: 524313K
...
Mono: GC_MAJOR_CONCURRENT_FINISH: (finishing) time 0.19ms, stw 0.13ms los size: 787504K in use: 786457K
...
Mono: GC_MAJOR_CONCURRENT_FINISH: (finishing) time 0.14ms, stw 0.09ms los size: 1049664K in use: 1048601K
...
Mono: GC_MAJOR_CONCURRENT_FINISH: (finishing) time 0.20ms, stw 0.14ms los size: 1573984K in use: 1572889K
... I believe this is due to this code: runtime/src/mono/mono/sgen/sgen-los.c Lines 442 to 460 in b94a82d
We always call This showed up in a MT WASM test #97970
|
It's weird that we keep printing a larger and larger LOS size. I thought maybe the problem is in the call to runtime/src/mono/mono/sgen/sgen-los.c Lines 442 to 460 in b94a82d
but I don't see |
Update With the interpreter too, it stays constant, like with the JIT. with $ MONO_ENV_OPTIONS=--interp MONO_LOG_MASK=gc MONO_LOG_LEVEL=debug dotnet run
...
Mono: GC_MAJOR_CONCURRENT_FINISH: (finishing) time 0.21ms, stw 0.07ms los size: 525344K in use: 524313K
...
Mono: GC_MAJOR_CONCURRENT_FINISH: (finishing) time 0.23ms, stw 0.16ms los size: 787504K in use: 786457K
...
Mono: GC_MAJOR_CONCURRENT_FINISH: (finishing) time 0.23ms, stw 0.17ms los size: 2098304K in use: 2097177K
...
Mono: GC_MAJOR_CONCURRENT_FINISH: (finishing) time 0.23ms, stw 0.16ms los size: 2360464K in use: 2359321K
...
Mono: GC_MAJOR_CONCURRENT_FINISH: (finishing) time 0.24ms, stw 0.18ms los size: 2360464K in use: 2359321K
...
Mono: GC_MAJOR_CONCURRENT_FINISH: (finishing) time 0.22ms, stw 0.16ms los size: 2098304K in use: 2097177K
...
Mono: GC_MAJOR_CONCURRENT_FINISH: (finishing) time 0.24ms, stw 0.17ms los size: 1836144K in use: 1835033K
...
Mono: GC_MAJOR_CONCURRENT_FINISH: (finishing) time 0.25ms, stw 0.18ms los size: 2360464K in use: 2359321K
...
Mono: GC_MAJOR_CONCURRENT_FINISH: (finishing) time 0.24ms, stw 0.17ms los size: 2360464K in use: 2359321K
...
Mono: GC_MAJOR_CONCURRENT_FINISH: (finishing) time 0.23ms, stw 0.16ms los size: 2098304K in use: 2097177K With the interpreter it climbs higher and then oscillates around I think it's a problem with the test case. This variant runs with constant LOS size: using System.Runtime.CompilerServices;
long bigger_than_los_section = 32 * 1024 * 1024;
long bigger_than_small_obj = 100 * 1024;
long small_obj = 50;
long alloc_size = bigger_than_los_section;
long cnt = 0;
long[] data = null;
AssignData(ref data, alloc_size);
var end = DateTime.Now + TimeSpan.FromMilliseconds(10000);
do
{
// these are just dummy computations to keep CPU busy
Interlocked.Increment(ref cnt);
AssignData(ref data, alloc_size);
data[0] = cnt;
// force some GC
if(cnt % 10000 == 0)
{
GC.Collect();
// GC.WaitForPendingFinalizers();
// GC.Collect();
// GC.WaitForPendingFinalizers();
var total = GC.GetTotalMemory(true);
Console.WriteLine("GC.GetTotalMemory: "+total);
}
}
while(DateTime.Now<end);
[MethodImpl(MethodImplOptions.NoInlining)]
static void AssignData (ref long[] d, long size, int recurse = 20)
{
if (recurse >= 0) {
AssignData(ref d, size, recurse - 1);
} else {
d = new long[size];
}
} ...
Mono: GC_MAJOR_CONCURRENT_FINISH: (finishing) time 0.22ms, stw 0.14ms los size: 525344K in use: 524313K
...
Mono: GC_MAJOR_CONCURRENT_FINISH: (finishing) time 0.14ms, stw 0.08ms los size: 1049664K in use: 1048601K
...
Mono: GC_MAJOR_CONCURRENT_FINISH: (finishing) time 0.23ms, stw 0.16ms los size: 787504K in use: 786457K
...
Mono: GC_MAJOR_CONCURRENT_FINISH: (finishing) time 0.23ms, stw 0.17ms los size: 787504K in use: 786457K
...
Mono: GC_MAJOR_CONCURRENT_FINISH: (finishing) time 0.23ms, stw 0.17ms los size: 787504K in use: 786457K it starts a bit lower, spikes and then reaches a steady state of 787504K |
I can get the interpreter to hold steady at the same LOS size as the JIT if I chance the
|
consider this program:
if
alloc_size
issmall_obj
then the LOS size stays constant, as we would expectif
alloc_size
isbigger_than_small_obj
then we also have a LOS size that stays constantif
alloc_size
isbigger_than_los_section
then the LOS heap size grows bigger and bigger (despite us not actually placing thenew long[alloc_size]
in the LOS section (!)This showed up in a MT WASM test #97970
The text was updated successfully, but these errors were encountered: