Upgrade to .NET 10 and refactor core components

Upgraded target framework to .NET 10 across all projects to leverage new features and improve performance.

Refactored `JobScheduler` to fix method naming inconsistencies and ensure proper resource disposal. Enhanced `AllocationManager` with safer memory operations and better performance handling. Simplified `ReadOnlyUnsafeCollection` enumerator logic for efficiency.

Overhauled `UnsafeBitSet` with new properties, improved bitwise operations, and optimized memory management. Updated `UnsafeSlotMap` and `ConcurrentSlotMap` for better validation and naming consistency.

Revised `MemoryLeakException` to use `ReadOnlySpan` for improved performance. Simplified `MathematicsBenchmark` logic and integrated `BenchmarkDotNet` for testing.

Added AOT compatibility settings for `Debug` and `Release` configurations. Introduced unit tests for `UnsafeBitSet` to validate functionality. Cleaned up unused code, improved readability, and ensured consistent naming conventions.

Updated project references and metadata for consistency. Enabled inline methods for `NET10_0_OR_GREATER` in `VectorGenerator`.
This commit is contained in:
2025-11-14 11:14:09 +09:00
parent bf4dd5670e
commit 24a7d49ae2
18 changed files with 223 additions and 260 deletions

View File

@@ -1,7 +1,6 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Attributes;
using Misaki.HighPerformance.Mathematics;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.Intrinsics;
namespace Misaki.HighPerformance.Test.Benchmark;
@@ -25,7 +24,7 @@ public unsafe class MathematicsBenchmark
public static f4 operator +(f4 a, f4 b)
{
var result = a._vec + b._vec;
return Unsafe.As<Vector128<float>, f4>(ref result);
return new f4(result);
}
}
@@ -108,7 +107,7 @@ public unsafe class MathematicsBenchmark
}
[Benchmark]
public unsafe Vector128<float> v128Add()
public Vector128<float> v128Add()
{
var a = Vector128.Create(1f, 2f, 3f, 4f);
var b = Vector128.Create(5f, 6f, 7f, 8f);

View File

@@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PublishAot>True</PublishAot>

View File

@@ -20,7 +20,7 @@
//using Misaki.HighPerformance.Test.Benchmark;
//BenchmarkDotNet.Running.BenchmarkRunner.Run<MathematicsBenchmark>();
BenchmarkDotNet.Running.BenchmarkRunner.Run<Misaki.HighPerformance.Test.Benchmark.MathematicsBenchmark>();
//using Misaki.HighPerformance.LowLevel.Buffer;
//using Misaki.HighPerformance.LowLevel.Collections;
@@ -40,17 +40,3 @@
// }
//}
using Misaki.HighPerformance.LowLevel.Buffer;
using Misaki.HighPerformance.LowLevel.Collections;
//AllocationManager.EnableDebugLayer();
//var array = new UnsafeArray<int>(10, Allocator.Persistent);
//var array2 = new UnsafeArray<int>(10, Allocator.Persistent);
//array.Dispose();
//array2.Dispose();
//AllocationManager.Dispose();
using (AllocationManager.CreateStackScope())
{
var arr = new UnsafeArray<int>(10, Allocator.Stack);
}

View File

@@ -0,0 +1,78 @@
using Misaki.HighPerformance.LowLevel.Buffer;
using Misaki.HighPerformance.LowLevel.Collections;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace Misaki.HighPerformance.Test.UnitTest.Collections;
[TestClass]
public class TestUnsafeBitSet
{
private UnsafeBitSet _set1;
private UnsafeBitSet _set2;
[TestInitialize]
public void Initialize()
{
_set1 = new UnsafeBitSet(16, Allocator.Persistent, AllocationOption.Clear);
_set2 = new UnsafeBitSet(16, Allocator.Persistent, AllocationOption.Clear);
}
[TestCleanup]
public void Cleanup()
{
_set1.Dispose();
_set2.Dispose();
}
[TestMethod]
public void TestBitCount()
{
Assert.AreEqual(256, _set1.BitCount);
}
[TestMethod]
public void TestSetAndGet()
{
Assert.IsFalse(_set1.IsSet(0));
_set1.SetBit(0);
Assert.IsTrue(_set1.IsSet(0));
_set1.ClearBit(0);
Assert.IsFalse(_set1.IsSet(0));
}
[TestMethod]
public void TestClearAll()
{
for (int i = 0; i < _set1.BitCount; i++)
{
_set1.SetBit(i);
}
_set1.ClearAll();
for (int i = 0; i < _set1.BitCount; i++)
{
Assert.IsFalse(_set1.IsSet(i));
}
}
[TestMethod]
public void TestAndOperation()
{
_set1.SetBit(0);
_set1.SetBit(1);
_set2.SetBit(1);
_set2.SetBit(2);
_set1.And(_set2);
Assert.IsFalse(_set1.IsSet(0));
Assert.IsTrue(_set1.IsSet(1));
Assert.IsFalse(_set1.IsSet(2));
}
}

View File

@@ -11,7 +11,7 @@ public class TestUnsafeSlotMap
[TestInitialize]
public void Initialize()
{
_slotMap = new UnsafeSlotMap<int>(16, Allocator.Persistent, AllocationOption.Clear);
_slotMap = new UnsafeSlotMap<int>(16, Allocator.Persistent);
}
[TestCleanup]