#memory-cache #memory-region #processor #shared-data #l3 #physical-memory #hardware-aware #memory-data

region_cached

Adds a logical layer of caching between processor L3 cache and main memory

33 releases

Uses new Rust 2024

new 0.1.24 Jul 23, 2025
0.1.23 Jul 14, 2025
0.1.19 Jun 29, 2025
0.1.11 May 8, 2025
0.0.6 Mar 26, 2025

#96 in Caching

Download history 319/week @ 2025-04-02 145/week @ 2025-04-09 288/week @ 2025-04-16 26/week @ 2025-04-23 10/week @ 2025-04-30 140/week @ 2025-05-07 53/week @ 2025-05-14 128/week @ 2025-06-04 127/week @ 2025-06-11 227/week @ 2025-06-18 569/week @ 2025-06-25 363/week @ 2025-07-02 174/week @ 2025-07-09 25/week @ 2025-07-16

1,143 downloads per month

MIT license

580KB
8K 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 cache frequently accessed shared data sets in the local memory region, speeding up reads when the data is not already in the local processor caches. You can think of it as an extra level of caching between L3 processor caches and main memory.

// `RegionCachedExt` provides required extension methods on region-cached
// static variables, such as `with_cached()` and `set_global()`.
use region_cached::{RegionCachedExt, region_cached};

region_cached!(static FAVORITE_COLOR: String = "blue".to_string());

FAVORITE_COLOR.with_cached(|color| {
    println!("My favorite color is {color}");
});

FAVORITE_COLOR.set_global("red".to_string());

More details in the package documentation.

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

Dependencies

~2–25MB
~335K SLoC