8000 N43: blink-alloc (#1298) · ChapliaS/rust-gamedev.github.io@a59acbe · GitHub
[go: up one dir, main page]

Skip to content

Commit a59acbe

Browse files
authored
N43: blink-alloc (rust-gamedev#1298)
1 parent a9e63cf commit a59acbe

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

content/news/043/index.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,57 @@ generated Metal/GLSL preview.
314314
[web demo]: https://not-fl3.github.io/miniquad-samples/shadertoy_cross.html
315315
[macroquad-shadertoy]: https://github.com/not-fl3/macroquad/blob/master/examples/shadertoy.rs
316316

317+
### [blink-alloc]
318+
319+
[blink-alloc] is a brand new arena-allocator with bunch of improvements
320+
over existing solutions that is
321+
tested with [Miri] and follows ["Strict Provenance Rules"][strict-provenance].
322+
323+
> Arena-allocators offer extremely fast allocations and deallocations.
324+
> Allocation is just a few pointer arithmetic operations.
325+
> And deallocation is nearly no-op.
326+
> In exchange arena-allocator requires a point in time when all
327+
> previous allocations are unused to reset state.\
328+
> Rust's borrow-checker ensures the requirement for reset making
329+
> it 100% safe to use.
330+
>
331+
> TL;DR great for games, servers, cli tools and more.
332+
333+
blink-alloc provides thread-local and multi-threaded allocators -
334+
`BlinkAlloc` and `SyncBlinkAlloc`.
335+
Single-threaded version [performs many times faster than `bumpalo`][blink-bench].
336+
The author couldn't find another implementation to compare
337+
the multi-threaded version's performance.
338+
339+
It also provided ouf-of-the-box to fetch `BlinkAlloc` in task/thread
340+
and return it back when done, keeping multiple `BlinkAlloc` instanced warmed.
341+
342+
On top of raw allocations blink-alloc provides `Blink` type
343+
that works as safe allocator adaptor.
344+
`Blink` can allocate memory and initialize it with values provided by user.
345+
User may provide values as-is, as closures or iterators.
346+
`Blink`'s API is safe with few exception for niche use cases.
347+
348+
Those familiar with `bumpalo` may think of `Blink` as of `bumpalo::Bump`.
349+
Though `Blink`
350+
351+
- drops all placed values on reset,
352+
which makes it usable with any kind of types without resource leaks.
353+
- Accepts any iterator type, not just `ExactSizeIterator` implementations.
354+
- Is configurable to use any `BlinkAllocator` implementation, thus not
355+
tied to `Global`.
356+
357+
Currently Rust's standard collection types may use custom allocators
358+
only one nightly and with `allocator_api` feature enabled.
359+
blink-alloc uses `allocator-api2` crate to work on both stable and nightly.
360+
Integration with other crates is simple and doesn't require depending on
361+
blink-alloc, only on `allocator-api2`.
362+
363+
[blink-alloc]: https://github.com/zakarumych/blink-alloc
364+
[blink-bench]: https://github.com/zakarumych/blink-alloc/blob/main/BENCHMARKS.md
365+
[Miri]: https://github.com/rust-lang/miri
366+
[strict-provenance]: https://github.com/rust-lang/rust/issues/95228
367+
317368
## Popular Workgroup Issues in Github
318369

319370
<!-- Up to 10 links to interesting issues -->

0 commit comments

Comments
 (0)
0