#thread-local #region #region-local

region_local

Isolated variable storage per memory region, similar to thread_local!

18 releases

Uses new Rust 2024

new 0.1.8 Apr 11, 2025
0.1.7 Apr 6, 2025
0.1.5 Mar 31, 2025
0.0.7 Mar 26, 2025

#282 in Hardware support

Download history 237/week @ 2025-03-05 119/week @ 2025-03-12 297/week @ 2025-03-19 1222/week @ 2025-03-26 318/week @ 2025-04-02

1,978 downloads per month

MIT license

440KB
6.5K SLoC

On many-processor systems with multiple memory regions, there is an extra cost associated with accessing data in physical memory modules that are in a different memory region than the current processor:

  • Cross-memory-region loads have higher latency (e.g. 100 ns local versus 200 ns remote).
  • Cross-memory-region loads have lower throughput (e.g. 50 Gbps local versus 10 Gbps remote).

This crate provides the capability to create static variables that maintain separate storage per memory region. This may be useful in circumstances where state needs to be shared but only within each memory region (e.g. because you intentionally want to avoid the overhead of cross-memory-region transfers and want to isolate the data sets).

Think of this as an equivalent of thread_local!, except operating on the memory region boundary instead of the thread boundary.

More details in the crate documentation.

This is part of the Folo project that provides mechanisms for high-performance hardware-aware programming in Rust.

Dependencies

~6–32MB
~454K SLoC