hlsf wrong slicing solving
This commit is contained in:
@@ -25,10 +25,6 @@
|
||||
//
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="HlsfStressTest" (performance benchmark)
|
||||
// Project: StgSharp
|
||||
// -----------------------------------------------------------------------
|
||||
using StgSharp.HighPerformance.Memory;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -46,7 +42,7 @@ namespace StgSharp
|
||||
int.TryParse(mbStr, out int mb) &&
|
||||
mb >= 64 ?
|
||||
(ulong)mb * 1024UL * 1024UL :
|
||||
3UL * 1024UL * 1024UL * 1024UL;
|
||||
512UL * 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
|
||||
@@ -56,42 +52,61 @@ namespace StgSharp
|
||||
{
|
||||
Console.WriteLine("=== HLSF Allocator Single-Thread Performance Benchmark ===");
|
||||
Console.WriteLine($"Arena size: {ArenaBytes / (1024 * 1024)} MiB (env override: HLSF_ARENA_MB)");
|
||||
using HybridLayerSegregatedFitAllocator allocator = new HybridLayerSegregatedFitAllocator((nuint)ArenaBytes);
|
||||
|
||||
Warmup(allocator);
|
||||
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("[1] Allocation throughput (no touch)");
|
||||
foreach (uint sz in SizeSweep)
|
||||
using (HybridLayerSegregatedFitAllocator allocator = new HybridLayerSegregatedFitAllocator((nuint)ArenaBytes))
|
||||
{
|
||||
uint size = sz > MaxAllocSize ? MaxAllocSize : sz;
|
||||
BenchAllocThroughput(allocator, size, touch:false);
|
||||
GC.Collect();
|
||||
GC.WaitForPendingFinalizers();
|
||||
Warmup(allocator);
|
||||
|
||||
foreach (uint sz in SizeSweep)
|
||||
{
|
||||
uint size = sz > MaxAllocSize ? MaxAllocSize : sz;
|
||||
BenchAllocThroughput(allocator, size, touch:false);
|
||||
GC.Collect();
|
||||
GC.WaitForPendingFinalizers();
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("[2] Allocation throughput (touch first byte)");
|
||||
foreach (uint sz in SizeSweep)
|
||||
using (HybridLayerSegregatedFitAllocator allocator = new HybridLayerSegregatedFitAllocator((nuint)ArenaBytes))
|
||||
{
|
||||
uint size = sz > MaxAllocSize ? MaxAllocSize : sz;
|
||||
BenchAllocThroughput(allocator, size, touch:true);
|
||||
GC.Collect();
|
||||
GC.WaitForPendingFinalizers();
|
||||
Warmup(allocator);
|
||||
|
||||
foreach (uint sz in SizeSweep)
|
||||
{
|
||||
uint size = sz > MaxAllocSize ? MaxAllocSize : sz;
|
||||
BenchAllocThroughput(allocator, size, touch:true);
|
||||
GC.Collect();
|
||||
GC.WaitForPendingFinalizers();
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("[3] Free throughput after pre-allocation (256k blocks of 1KB)");
|
||||
BenchFreeThroughput(allocator, 256 * 1024, 1024);
|
||||
using (HybridLayerSegregatedFitAllocator allocator = new HybridLayerSegregatedFitAllocator((nuint)ArenaBytes))
|
||||
{
|
||||
Warmup(allocator);
|
||||
|
||||
Console.WriteLine("[3] Free throughput after pre-allocation (256k blocks of 1KB)");
|
||||
BenchFreeThroughput(allocator, 256 * 1024, 1024);
|
||||
}
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("[4] Alloc+Immediate Free pairs (5,000,000 x 256B)");
|
||||
BenchAllocFreePairs(allocator, 5_000_000, 256);
|
||||
using (HybridLayerSegregatedFitAllocator allocator = new HybridLayerSegregatedFitAllocator((nuint)ArenaBytes))
|
||||
{
|
||||
Warmup(allocator);
|
||||
|
||||
BenchAllocFreePairs(allocator, 5_000_000, 256);
|
||||
}
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("[5] Fragmentation cycle (allocate ~1024MB random, free half, reallocate)");
|
||||
BenchFragmentationCycle(allocator, 1024);
|
||||
using (HybridLayerSegregatedFitAllocator allocator = new HybridLayerSegregatedFitAllocator((nuint)ArenaBytes))
|
||||
{
|
||||
Warmup(allocator);
|
||||
|
||||
BenchFragmentationCycle(allocator, 512); // target within 500MB arena
|
||||
}
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("=== Benchmark Complete ===");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user