hlsf gong on rewrite again

This commit is contained in:
Youmu Liu
2025-11-27 20:13:09 +08:00
parent 83537c7be7
commit a3570bf20a
7 changed files with 267 additions and 242 deletions
+8 -2
View File
@@ -42,7 +42,7 @@ namespace StgSharp
int.TryParse(mbStr, out int mb) &&
mb >= 64 ?
(ulong)mb * 1024UL * 1024UL :
1024UL * 1024UL * 1024UL; // lower default to 512MB
3UL * 1024UL * 1024UL * 1024UL; // lower default to 512MB
private static readonly uint[] SizeSweep = {
64, 128, 192, 256, 512, 768, 1024, 2048, 3072, 4096, 8192, 12288, 16384, 32768, 49152, 65536, 131072, 196608, 262144, 524288, 786432, 1_048_576, 2_097_152, 3_145_728, 4_194_304, 8_388_608, 12_582_912, 16_777_216, 25_165_824, 33_554_432
@@ -64,6 +64,7 @@ namespace StgSharp
{
uint size = sz > MaxAllocSize ? MaxAllocSize : sz;
BenchAllocThroughput(allocator, size, touch:false);
allocator.Collect();
GC.Collect();
GC.WaitForPendingFinalizers();
}
@@ -79,6 +80,7 @@ namespace StgSharp
{
uint size = sz > MaxAllocSize ? MaxAllocSize : sz;
BenchAllocThroughput(allocator, size, touch:true);
allocator.Collect();
GC.Collect();
GC.WaitForPendingFinalizers();
}
@@ -90,6 +92,7 @@ namespace StgSharp
Console.WriteLine("[3] Free throughput after pre-allocation (256k blocks of 1KB)");
BenchFreeThroughput(allocator, 256 * 1024, 1024);
allocator.Collect();
}
Console.WriteLine();
Console.WriteLine("[4] Alloc+Immediate Free pairs (5,000,000 x 256B)");
@@ -98,6 +101,7 @@ namespace StgSharp
Warmup(allocator);
BenchAllocFreePairs(allocator, 5_000_000, 256);
allocator.Collect();
}
Console.WriteLine();
Console.WriteLine("[5] Fragmentation cycle (allocate ~1024MB random, free half, reallocate)");
@@ -106,6 +110,7 @@ namespace StgSharp
Warmup(allocator);
BenchFragmentationCycle(allocator, 512); // target within 500MB arena
allocator.Collect();
}
Console.WriteLine();
Console.WriteLine("=== Benchmark Complete ===");
@@ -156,7 +161,8 @@ namespace StgSharp
}
}
list.Add(h);
Console.WriteLine(i);
// Console.WriteLine(i);
}
sw.Stop();
double allocOpsPerSec = ops / sw.Elapsed.TotalSeconds;
+2 -2
View File
@@ -45,9 +45,9 @@ namespace StgSharp
.InitializeModule();
// TestRender();
TestHlsf();
// TestHlsf();
// HlsfStressTest.Run();
HlsfStressTest.Run();
/*
HybridLayerSegregatedFitAllocator hlsf = new HybridLayerSegregatedFitAllocator((nuint)(64 * (ulong)10000 * 10000));