Thruster
A fast and efficient implementation of a MemoryPool<T>.
Install / Use
/learn @Scooletz/ThrusterREADME
This project is dicontinued. Although it was able to be faster than the default shared implementation, it's not faster than Kestrel's pool. More reasoning: https://blog.scooletz.com/2018/08/14/thruster-building-a-not-so-fast-memory-pool/
![]()
Thruster
Thruster is a fast and efficient implementation of a MemoryPool<T>
Design principles
Thruster is based on (some) understanding on nowadays CPUs and low level APIs provided by .NET. The most important desing principles are:
- padding - expanding an object or an array, to reduce a possibility of using the same CPU cache line by threads being run on different CPUs
- region memory mangagement - leasing chunks of memory from a specific region, which allows use of in-region addressing (offset, region number)
- no locks - for claiming and releasing memory when no resize is needed
- efficient data encoding - bitmasks used for leasing, are designed to use 1
CASoperation for renting (when no collisions) and one, branchless unconditionalInterlocked.Addto release
Benchmarks
Some single threaded benchmarks run with awesome BenchmarkDotNet. The nesting level represents multiple .Rent operations.
BenchmarkDotNet=v0.11.0, OS=Windows 10.0.16299.547 (1709/FallCreatorsUpdate/Redstone3)
Intel Core i7-6700HQ CPU 2.60GHz (Max: 2.20GHz) (Skylake), 1 CPU, 8 logical and 4 physical cores
Frequency=2531250 Hz, Resolution=395.0617 ns, Timer=TSC
.NET Core SDK=2.1.302
[Host] : .NET Core 2.1.2 (CoreCLR 4.6.26628.05, CoreFX 4.6.26629.01), 64bit RyuJIT
DefaultJob : .NET Core 2.1.2 (CoreCLR 4.6.26628.05, CoreFX 4.6.26629.01), 64bit RyuJIT
| Method | Mean | Error | StdDev | |---------------------- |----------:|---------:|---------:| | Thruster_1_Rent | 74.54 ns | 1.557 ns | 4.048 ns | |Thruster_2_nested_Rents | 139.32 ns | 2.765 ns | 2.958 ns | |Thruster_3_nested_Rents | 207.78 ns | 3.479 ns | 3.255 ns | | Shared_1_Rent | 91.73 ns | 1.547 ns | 1.447 ns | | Shared_2_nested_Rents | 287.89 ns | 5.087 ns | 4.510 ns | | Shared_3_nested_Rents | 408.50 ns | 7.217 ns | 6.751 ns |
Multi threaded app depends on the nesting level even more. If there's no nesting, results are comparable. Any nesting will drastically point towards using Thruster.
Icon
Rocket Ship designed by Joy Thomas from The Noun Project
Related Skills
node-connect
345.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
104.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
345.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
345.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
