Faster.Collections.Pooled
1.0.3
dotnet add package Faster.Collections.Pooled --version 1.0.3
NuGet\Install-Package Faster.Collections.Pooled -Version 1.0.3
<PackageReference Include="Faster.Collections.Pooled" Version="1.0.3" />
<PackageVersion Include="Faster.Collections.Pooled" Version="1.0.3" />
<PackageReference Include="Faster.Collections.Pooled" />
paket add Faster.Collections.Pooled --version 1.0.3
#r "nuget: Faster.Collections.Pooled, 1.0.3"
#:package Faster.Collections.Pooled@1.0.3
#addin nuget:?package=Faster.Collections.Pooled&version=1.0.3
#tool nuget:?package=Faster.Collections.Pooled&version=1.0.3
Faster.Collections.Pooled
A high-performance collection library for .NET 10+ that provides pooled alternatives to standard collections, reducing GC pressure and improving throughput.
Features
- Array Pooling - All collections leverage shared array pools to minimize allocations
- High-Performance Hashing - Includes optimized hash algorithms (FastHash, WyHash, xxHash3, CRC32) powered by
Faster.Map. - Drop-in Replacements - Compatible APIs for Dictionary, List, Queue, Stack, and PriorityQueue.
- Comprehensive Testing - Includes comparison tests against BCL collections.
- Benchmarking - Includes a dedicated benchmarking project for performance evaluation.
API Compatibility
| Collection | API Source |
|---|---|
PooledList |
List |
PooledQueue |
Queue |
PooledStack |
Stack |
PooledPriorityQueue |
PriorityQueue |
PooledDictionary |
FasterMap.BlitzMap + Interfaces* of Dictionary |
* PooledDictionary implements standard interfaces of Dictionary except ISerializable and IDeserializationCallback
Special API
ToPooledCollection Series
using PooledList<int> list = [1, 2, 3, 4, 5];
list.ToPooledQueue(); // Convert to PooledQueue
list.ToPooledStack(); // Convert to PooledStack
Deque
using new PooledDeque<int> deque = [];
deque.EnququeHead(1);
deque.EnququeTail(2);
Construction based on Collection Expression
using PooledDeque<int> deque = [0];
using PooledDictionary<int, int> dict = [
(1, 1),
(2, 2),
(3, 3),
];
Installation
NuGet Package
dotnet add package Faster.Collections.Pooled
Build from Source
dotnet fsi build.fsx build
Performance
Sometimes, benchmark-dotnet or GC will allocate small amount of memory.
For exmaple, the benchmark below shows System.Collections.Generic.PriorityQueue.Dequeue allocates 0 B, but it may allocate a few bytes in some runs.
| Method | N | Mean | Error | StdDev | Median | Ratio | RatioSD | Allocated | Alloc Ratio |
|---|---|---|---|---|---|---|---|---|---|
| OriginPriorityQueueDequeue | 100 | 2,741.8 ns | 168.45 ns | 472.36 ns | 2,700.0 ns | 1.03 | 0.24 | 336 B | 1.00 |
| PooledPriorityQueueDequeue | 100 | 2,847.4 ns | 158.32 ns | 454.26 ns | 2,800.0 ns | 1.07 | 0.24 | - | 0.00 |
| OriginPriorityQueueDequeue | 1000 | 41,531.0 ns | 826.78 ns | 1,211.88 ns | 41,400.0 ns | 1.00 | 0.04 | - | NA |
| PooledPriorityQueueDequeue | 1000 | 42,242.9 ns | 783.69 ns | 694.72 ns | 42,250.0 ns | 1.02 | 0.03 | - | NA |
PooledList vs List
Add
Speed up 85%, no allocations.
Remove
Almost same speed, no allocations.
PooledDictionary vs Dictionary
Speed up 298%, no allocations.
Speed up 58%, no allocations.
PooledQueue vs Queue
Enqueue
Speed up 65%, no allocations.
Dequeue
Almost same speed, no allocations.
PooledStack vs Stack
Push
Speed up 86%, no allocations.
Pop
Almost same speed, no allocations.
PooledPriorityQueue vs PriorityQueue
Enqueue
Speed up 71%, no allocations.
Dequeue
Almost same speed, no allocations.
Roadmap
-
PooledHashset(based onFaster.Map.BlitzSet) -
ISerializableandIDeserializationCallbacksupport forPooledDictionary
Acknowledgments
Very special thanks to the following projects:
- Faster.Map - High-performance hashing algorithms
- Collections.Pooled - Pooled collection implementations
License
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- System.IO.Hashing (>= 10.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.