Job system priorities, async waits, parallel map/queue

Major refactor:
- Add job priority tiers and async wait APIs to IJobScheduler
- Implement priority-based job queues and scheduling logic
- Introduce UnsafeParallelHashMap and refactor UnsafeParallelQueue
- Refactor UnsafeSlotMap to chunked storage for scalability
- Update SlotMap/ConcurrentSlotMap for consistency and perf
- Add new benchmarks and unit tests for parallel collections
- Misc: add MemoryUtility.AlignUp, version bumps, test improvements, bug fixes
This commit is contained in:
2026-04-18 11:26:08 +09:00
parent d5616daa05
commit 13802ca6c8
22 changed files with 1459 additions and 267 deletions

View File

@@ -0,0 +1,95 @@
using BenchmarkDotNet.Attributes;
using Misaki.HighPerformance.Collections;
using Misaki.HighPerformance.Mathematics;
namespace Misaki.HighPerformance.Test.Benchmark;
public struct BigStruct
{
public int a, b, c, d, e, f, g, h, i, j;
public long k, l, m, n, o, p, q, r, s, t;
}
public class Integer
{
public BigStruct value;
}
public class ConcurrentSlotMapBenchmark
{
private readonly ConcurrentSlotMap<BigStruct> _concurrentMap = new ConcurrentSlotMap<BigStruct>(1000);
private readonly SlotMap<BigStruct> _slotMap = new SlotMap<BigStruct>(1000);
private readonly BigStruct[] _slots = new BigStruct[1000];
private readonly Integer[] _objects = new Integer[1000];
private readonly int2[] _randomIndices1 = new int2[1000];
private readonly int2[] _randomIndices2 = new int2[1000];
private readonly int[] _randomSlots = new int[1000];
[GlobalSetup]
public void Setup()
{
for (var i = 0; i < 1000; i++)
{
var element = new BigStruct
{
a = i
};
var id = _concurrentMap.Add(element, out var generation);
_randomIndices1[i] = new int2(id, generation);
id = _slotMap.Add(element, out generation);
_randomIndices2[i] = new int2(id, generation);
_slots[i] = element;
_objects[i] = new Integer { value = element };
_randomSlots[i] = i;
}
Random.Shared.Shuffle(_randomIndices1);
Random.Shared.Shuffle(_randomIndices2);
Random.Shared.Shuffle(_randomSlots);
}
[Benchmark]
public void ConcurrentSlotMap()
{
for (var i = 0; i < 1000; i++)
{
var v = _randomIndices1[i];
ref var element = ref _concurrentMap.GetElementReferenceAt(v.x, v.y, out var _);
element.a += 1;
}
}
[Benchmark]
public void SlotMap()
{
for (var i = 0; i < 1000; i++)
{
var v = _randomIndices2[i];
ref var element = ref _slotMap.GetElementReferenceAt(v.x, v.y, out var _);
element.a += 1;
}
}
[Benchmark]
public void Array()
{
for (var i = 0; i < 1000; i++)
{
_slots[_randomSlots[i]].a += 1;
}
}
[Benchmark]
public void ObjectArray()
{
for (var i = 0; i < 1000; i++)
{
_objects[_randomSlots[i]].value.a += 1;
}
}
}

View File

@@ -1,7 +1,3 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Misaki.HighPerformance.Test.Benchmark;
public class ReadWriteLockBenchmark