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
Replaced the deprecated Allocator API with the new AllocationHandle API across the codebase. Updated constructors, methods, and tests to use AllocationHandle for memory management. Marked Allocator-based methods as [Obsolete] and provided alternatives.
Added OwnershipTransferAnalyzer to detect ownership transfer issues and introduced OwnershipTransferAttribute for marking parameters. Enhanced DefensiveCopyAnalyzer with additional checks for readonly and ValueType instances.
Refactored internal memory management in AllocationManager and updated benchmarks, utilities, and documentation to reflect the changes.
BREAKING CHANGE: Deprecated Allocator API in favor of AllocationHandle. Updated constructors and methods to use AllocationHandle. Users must migrate to the new API.
Refactored memory management by removing safety checks and introducing `MemoryHandle` for centralized tracking. Simplified allocation logic across allocators and enhanced `Dispose` methods for better resource cleanup.
Added `UnsafeChunkedQueue<T>`, a lock-free, dynamically resizing queue with chunk-based memory management, supporting parallel producers and consumers.
Updated unit tests to validate new queue functionality and ensure compatibility with refactored memory logic. Incremented assembly version to 1.6.12.
BREAKING CHANGE: Removed `#if MHP_ENABLE_SAFETY_CHECKS` blocks, altering memory validation behavior.
Refactor all unsafe collection enumerators to use ref struct types,
removing support for boxing and standard .NET enumeration interfaces.
GetEnumerator methods now return stack-only, more efficient enumerators
with [UnscopedRef] and inlining attributes. IEnumerable<T> and
IEnumerable implementations are removed from affected types. Interfaces
now require unmanaged types. Also includes minor doc and bug fixes.
BREAKING CHANGE: Enumerators are no longer compatible with LINQ, and collections no longer implement IEnumerable/IEnumerator.
Refactored UnsafeBitSet.Iterator to store a pointer to the bitset and accept a start index in its constructor. Updated GetIterator to support an optional start parameter and return an iterator using a pointer to the current instance. Revised Program.cs to demonstrate new usage and removed unrelated code. Bumped assembly version to 1.6.11.
Refactor memory allocation system to use generic MemoryPool<TAllocator, TOpts> for arena, stack, and free list allocators, replacing custom allocator structs. Introduce MemoryBlock as a safer, more robust replacement for UnTypedArray. Improve thread safety, safety checks, and documentation. Reorder and clarify Allocator enum. Add comprehensive unit tests for all allocators and pointer assertion utilities. Update project to enable safety checks in Debug builds. Remove obsolete interfaces and ensure consistent deallocation with MemoryUtility.Free.
BREAKING CHANGE: Custom allocator structs are removed and replaced with MemoryPool-based abstraction. UnTypedArray is replaced by MemoryBlock. Allocator enum order and semantics are changed. Public API changes may require code updates.
Introduce a unified Reallocate method to all memory allocator types (Arena, Stack, FreeList, VirtualArena, VirtualStack, DynamicArena) and require it in the IMemoryAllocator interface. This enables efficient resizing of memory blocks, with fast-path optimizations for stack-like allocators.
Update AllocationManager and MemoryPool to use the new Reallocate method, simplifying and optimizing memory resizing logic. Add public properties for buffer pointers, sizes, and offsets to allocator structs for easier diagnostics.
Set FreeList's default concurrency level to 1 and make its allocation method return null on dispose instead of throwing. Clean up vector types for formatting, fix UnsafeList's RemoveRangeSwapBack logic, and simplify RemoveAtSwapBack.
Simplify Program.cs to only run SPMDBenchmark. Add new unit tests for FixedString, UnsafeList, UnsafeHashMap, and UnsafeHashSet. Apply minor test code cleanups for consistency in TestUnsafeQueue.
BREAKING CHANGE: IMemoryAllocator now requires a Reallocate method, and allocator APIs have changed accordingly.
Refactored UnsafeQueue<T>.Resize to prevent shrinking below
current count and handle wrap-around copying correctly.
Exposed AllocationHandle in UnsafeArray<T> via a new property.
Bumped project version to 1.6.10.
Added TestUnsafeQueue class to cover core queue operations.
Added scalar operator overloads for Vector types, fixed pointer math in Store methods, and improved enumerator and memory management. Updated test setup and removed allocation leak tests.
- Added left-hand scalar operator overloads for Vector2/3/4.
- Fixed pointer arithmetic in Store and GetUnsafePtr methods.
- Marked SetValue as readonly in UnsafeSparseSet.
- Improved enumerator initialization/reset for slot map and sparse set.
- Updated test projects' AssemblyVersion.
- Removed TestAllocationManager and added global AllocationManager setup/teardown.
- Updated TestConcurrentSlotMap for thread safety and correct cancellation.
- Minor formatting and parameter improvements.
Added debug-only checks in Dispose methods of HashMapHelper, UnTypedArray, and UnsafeArray to log a message (with optional stack trace) if Dispose is called on an uninitialized or already disposed instance, unless the buffer is null. Incremented assembly version to 1.6.6.
Enhanced Dispose() in HashMapHelper, UnTypedArray, and UnsafeArray<T> to provide more informative debug messages when called on uninitialized or already disposed objects. When MHP_ENABLE_STACKTRACE is defined, the debug output now includes a stack trace with file, type, method, and line number details.
Also incremented project version to 1.6.5.
Add AllocationManager.GetTotalAllocatedMemory() to track total allocations when safety checks are enabled. Improve diagnostics by calling Debug.Fail in Dispose methods of HashMapHelper, UnTypedArray, and UnsafeArray when disposing uninitialized or already disposed arrays. Remove AddRange(ReadOnlyUnsafeCollection<T>) from UnsafeList<T>. Increment assembly version to 1.6.4. Ensure arrcpy is disposed in Program.cs.
- JobScheduler now explicitly frees unmanaged memory in _jobInfoPool before disposal.
- Removed the unused TempJobAllocator struct and implementation.
- Refactored AllocationManager to use conditional compilation for safety checks, making MemoryHandle usage conditional.
- Improved documentation in AllocationManager for clarity on allocation size and safety check behavior.
- Added UnsafeSetCount method to UnsafeList<T> for direct count manipulation with validation.
- Bumped AssemblyVersion in Jobs and LowLevel projects.
Refactor to use MHP_ENABLE_SAFETY_CHECKS, MHP_ENABLE_STACKTRACE, and MHP_ENABLE_MIMALLOC for feature toggling. Remove FreeList allocator in JobSchedular and debug-layer code, simplifying memory management. Improve memory leak detection and reporting, update memory allocation API, and guard all safety/debug features with new defines. Update csproj files, README, and code samples to match new API and toggles. Fix and improve collection types for correct behavior with and without safety checks. The codebase is now more modular and easier to configure for different build environments.
BREAKING CHANGE: Old defines (ENABLE_SAFETY_CHECKS, ENABLE_DEBUG_LAYER, ENABLE_MIMALLOC) are replaced with MHP_* equivalents. FreeList allocator and related debug features are removed. Some APIs and behaviors have changed for safety/debug configuration.
CopyTo, CopyFrom, ToArray, and ToList are now implemented as instance methods on UnsafeArray<T> and UnsafeList<T>, replacing the previous extension methods. This change enables more direct and efficient copying between unsafe collections and managed spans, arrays, and lists, with overloads for ranges and resizing as needed. Extension methods for these operations have been removed. Minor cleanup and usage updates are included.
BREAKING CHANGE: Extension methods for copying and converting between unsafe collections and spans/arrays/lists have been removed. Use the new instance methods instead.
Added implicit conversion operators to UnsafeArray<T> and UnsafeList<T> for easier conversion to ReadOnlyUnsafeCollection<T> and Span<T>. Introduced new AddRange overloads in UnsafeList<T> for ReadOnlyUnsafeCollection<T> and pointer-based sources. Updated AssemblyVersion in all projects. Improved MemoryLeakException stack trace output and fixed a documentation comment.
Introduce VirtualStack allocator, refactor memory management to use virtual memory stacks, and update documentation.
Added VirtualStack as a new stack allocator using virtual memory, replaced Stack with VirtualStack in allocation manager and related APIs, and updated TempJobAllocator to use VirtualArena. Introduced AllocationManagerInitOpts for allocator configuration. Replaced ENABLE_COLLECTION_CHECKS with ENABLE_SAFETY_CHECKS for safety checks. Removed Result.cs and updated project files and examples. Added comprehensive README files for all major packages and improved root documentation.
BREAKING CHANGE: Stack allocator replaced by VirtualStack; TempJobAllocator and AllocationManager initialization signatures changed; Result types removed.
Enhanced FreeList to handle oversized allocations by bypassing chunk management and allocating directly from the OS, with proper header assignment and immediate release on free. Updated IUnsafeCollection<T> documentation, removed unnecessary array clearing in Clear() methods, refined UnsafeSlotMap initialization logic, and removed redundant default element addition. Bumped assembly version to 1.5.1.
Introduce VirtualArena for large, thread-safe virtual memory allocation and FreeList allocator for efficient persistent allocations. Update AllocationManager to support new allocators, add cross-platform virtual memory utilities, and improve thread-safety and performance in existing allocators. Bump version to 1.5.0 and update project configuration.
BREAKING CHANGE: AllocationManager initialization now requires explicit parameters for arena and FreeList capacities. Existing allocator usage may require code changes.
Refactored FreeList allocator to use per-thread caches for improved scalability and performance, with configurable max concurrency and overflow cache. AllocationManager debug layer is now compile-time via ENABLE_DEBUG_LAYER. MemoryUtility methods no longer catch exceptions. Argument validation standardized with ThrowIfNegative. JobScheduler passes maxConcurrencyLevel to allocator. CollectionUtility's GetElementUnsafe returns mutable ref. AssemblyVersion incremented. Added comprehensive FreeList unit tests. Improved robustness and error handling in allocation classes.
BREAKING CHANGE: Debug layer APIs removed; FreeList allocator interface changed for thread cache support.
- Reserve index 0 as always invalid in SlotMap, ConcurrentSlotMap, UnsafeSlotMap, and UnsafeSparseSet; update all index checks and slot operations accordingly
- Refactor SlotMap to use parallel arrays and BitArray for occupancy
- Double capacity on resize for all major unsafe collections
- Add debugger display support for unsafe collections
- Improve NuGet publishing workflow to skip existing versions
- Increment package versions (LowLevel: 1.3.1, main: 1.0.2)
- Add comprehensive unit tests for SlotMap and ConcurrentSlotMap
- Update main program and documentation for new slot map behavior
Added new AllocationHandle property in Stack.Scope.
Changed the ref AllocationHandle constructor parameter to AllocationHandle on of all UnsafeCollection types
Removed Allocator.Stack. Use Stack.Scope.AllocationHandle to allocate on stack instead.
Introduced `Iterator` structs in `UnsafeBitSet` and `SpanBitSet`
to enable efficient traversal of set bits. Added `GetIterator`
methods to both structs to return iterator instances. Implemented
`NextSetBit` in `SpanBitSet` to support iterator functionality.
Changed constants in `UnsafeBitSet` from `private` to `internal`
for broader assembly access. Removed redundant methods from
`SpanBitSet` to streamline the API in favor of iterator-based
operations.
Updated constructors in `UnsafeSlotMap` and `UnsafeSparseSet` to
conditionally clear arrays based on `AllocationOption.Clear`.
Incremented assembly version to 1.2.7 to reflect these updates.
Replaced `SafeHandle` with a new `MemoryHandle` system for improved memory tracking, safety, and leak detection. Updated allocators (`ArenaAllocator`, `HeapAllocator`, `StackAllocator`) and collections (`UnTypedArray`, `UnsafeArray<T>`, `UnsafeBitSet`) to use `MemoryHandle`.
Refactored `AllocationManager` to use `ConcurrentSlotMap` for live allocation tracking and added methods for managing `MemoryHandle` instances. Simplified alignment and padding logic across allocators and collections.
Enhanced performance with optimized memory operations (`MemClear`, `MemSet`, `MemCpy`) and vectorized operations in `MemoryUtility` and `UnsafeBitSet`. Fixed alignment issues in vectorized memory operations.
Updated tests to reflect the new memory management system and added new tests for `UnsafeBitSet` bitwise operations. Enabled `ENABLE_COLLECTION_CHECKS` for debug builds and improved error messages and documentation.
Removed unused `SafeHandle` code and adjusted project configuration to include necessary references.
- Updated `.gitignore` to include `.vscode/` and clarified comments.
- Introduced `SafeHandle` for managing memory alignment and safe access.
- Refactored `UnsafeArray<T>` to add bounds checking and alignment logic.
- Added `IUnsafeHashCollection<T>` for specialized hash-based collections.
- Refactored `UnsafeHashMap<TKey, TValue>` and `UnsafeHashSet<T>` to use `HashMapHelper<TKey>` with alignment support.
- Made `UnsafeSlotMap<T>` methods `readonly` for immutability.
- Enhanced `HashMapHelper<TKey>` with alignment-aware buffer management and validation.
- Updated benchmarks to use `UnsafeArray<Vector256<int>>` and added capacity checks.
- Incremented assembly version to `1.1.3` in `Misaki.HighPerformance.LowLevel.csproj`.
- Updated `Program.cs` to run `CollectionBenchmark` and demonstrate safe disposal handling.
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`.
Refactored enumerators across multiple unsafe collections to use
`ref` returns for `Current`, improving performance and reducing
memory usage. Enhanced memory management with `AllocationOption`
support and optimized resizing logic for collections like
`UnsafeBitSet`, `UnsafeSlotMap`, and `UnsafeSparseSet`.
Updated `publish-nuget.yaml` to support manual workflow dispatch
and trigger on `push`/`pull_request` events. Incremented project
version to `1.1.2` and ensured NuGet package generation on build.
Refactored `AllocationManager` to introduce intrusive allocation tracking with `AllocationHeader` structs for debug mode. Added lightweight allocation counters for non-debug mode. Enhanced memory leak detection with detailed stack traces and `MemoryLeakException`.
Simplified `AllocationInfo` by removing the `Allocator` property. Updated `AllocationOption` enum to remove `UnTracked` and clarified documentation.
Improved unsafe collections (`UnsafeArray`, `UnsafeStack`, etc.) with strongly-typed enumerators and better compatibility with `IEnumerable<T>`. Enhanced `UnsafeStack` with a dedicated `Enumerator` struct and consistent constructor parameters.
Refactored `MemoryLeakException` to support detailed allocation info and improved stack trace formatting. Simplified `MemoryUtility` by removing redundant null checks.
Added unit tests for `AllocationManager`, `UnsafeArray`, and `UnsafeStack` to validate memory management and functionality. Updated `Program.cs` with new examples.
Cleaned up namespaces, removed redundant `using` directives, and improved XML documentation. Applied `MethodImplOptions.AggressiveInlining` to performance-critical methods.
Refactored `sincos` usage across `quaternion` and `random` to use `out` parameters for improved performance. Enhanced `random` struct with updated random direction generation methods.
Added new benchmarks in `MathematicsBenchmark` for vector operations, including SIMD-based `f4` struct. Downgraded target framework to `net9.0` for compatibility.
Introduced `ReadOnlyUnsafeCollection` for low-level memory management. Added utility methods in `CollectionUtility` for span creation and optimized list operations.
Renamed `MemoryUtilities` to `MemoryUtility` and updated all references. Enhanced `ObjectPool` with `Rent` and `TryRent` methods. Enabled `AllowUnsafeBlocks` and AOT compatibility in project configuration.
Performed general code cleanup, including removal of unused methods, improved formatting, and alignment with modern coding practices.
Updated `ReallocFunc` to support `oldSize`, `newSize`, and `AllocationOption`, enabling more granular control over memory reallocation. Simplified `AllocationInfo` by removing the `FreeHandler` property. Enhanced `Reallocate` and `Allocate` methods in `AllocationManager` to handle memory clearing and tracking more effectively.
Refactored `UnsafeSparseSet` to use `UnsafeArray<T>` directly, added a `generations` array, and replaced the `freeList` with `UnsafeStack<int>` for better performance and simplicity. Updated `Resize`, `Add`, and `Remove` methods to improve memory handling and code clarity.
Introduced `AllocationOption` support in `Resize` methods across `IUnsafeCollection` implementations for flexible resizing behavior. Added `GetUnsafePtr` extension methods in `UnsafeUtilities` for direct access to span data.
Added new tests for `UnsafeSparseSet` to validate resizing, clearing, enumeration, and memory compaction. These changes improve memory management, enhance performance, and ensure correctness.
Refactored `StbImage` classes to be publicly accessible. Updated namespaces and introduced `NumericTypeAttribute` for metadata. Enhanced `VectorGenerator` with new utility methods (`any`, `all`, `length`, etc.) and improved code generation. Consolidated vector operations in `math` utilities.
Refactored `Plane` and `svd` classes for better encapsulation and readability. Improved `DynamicArray` with `uint` indexer support and cleaner loops. Added SIMD-based benchmarking placeholders in `MathematicsBenchmark`.
Removed redundant code and unused files, including `IUnsafeSet.cs`. Updated project file to include `CodeGen` as an analyzer. Introduced `SupportedVectorMath` and `SupportedMatrixMath` enums for better operation definitions.
Improved code style, fixed minor bugs, and cleaned up unused code in `Program.cs`. Enhanced maintainability and readability across the codebase.
Refactored `sincos` usage in `quaternion` to use tuple-based
returns for improved readability. Introduced a `random` struct
with methods for generating random values of various types
and dimensions, including ranges and directions. Added a
`DynamicArray` class for dynamic resizing and manipulation
of collections. Enhanced `SlotMap` with new methods for
safe access and updates.
Updated `uint` vector types with `NumericConvertable`
attributes for better type interoperability. Removed the
`MathUtilities` class and refactored `adj` and `adjInverse`
methods for encapsulation. Improved memory management
with `StackAllocator` and `UnsafeArray` enhancements.
Added geometry utilities like `AABB`, `OBB`, `Plane`, and
`SphereBounds` for 3D operations. Updated project
configuration for versioning and NuGet packaging.
Performed general code cleanup, improved validation, and
aligned with modern C# practices.