Releases: gogpu/galloc
Releases · gogpu/galloc
Release list
v0.1.0 — O(1) Offset Allocator for Go
What's New
First release of galloc — O(1) offset allocator for GPU memory sub-allocation. Pure Go port of Sebastian Aaltonen's OffsetAllocator (C++, MIT, 1,051 stars). First Go implementation of this algorithm.
Features
- O(1) allocate and free — two-level bitfield bin lookup via
math/bits.TrailingZeros32 - 256 size classes — SmallFloat encoding (3-bit mantissa + 5-bit exponent), max 12.5% overhead
- Automatic coalescing — adjacent free regions merge on free via doubly-linked neighbor list
- Zero heap allocations on hot path — all node storage pre-allocated in
New() - Thread-safe wrapper —
SyncAllocatorwithsync.Mutex - Pure Go — no unsafe, no CGO, no assembly, stdlib only
Performance
| Benchmark | ns/op | allocs/op |
|---|---|---|
| Allocate | ~44 | 0 |
| Free | ~40 | 0 |
| AllocFree | ~39 | 0 |
Use Cases
- GPU buffer sub-allocation (VkBuffer, ID3D12Resource heaps)
- Ring buffer management (staging belts)
- Any contiguous-range sub-allocation needing O(1) performance
Credits
Based on OffsetAllocator by Sebastian Aaltonen. Also informed by offset-allocator (Rust port by Patrick Walton, used in Bevy).
Part of the GoGPU ecosystem.