[][src]Crate cuneiform

Cuneiform: Cache optimizations for Rust, revived from the slabs of Sumer.

Cuneiform

This crate provides a proc macro attribute to optimize CPU cache operations for user defined structs. Cuneiform can take various arguments at attribute position:

  • hermetic = true|false (default is true when #[cuneiform])
  • Hermetic enables cuneiform to detect cache sizes from OSes which have API to fetch.
  • Currently, hermetic argument works only Linux kernel 2.6.32 and above.
  • If system is different than supported systems it falls back to slabs.
  • slab = "board_or_architecture_name (e.g. #[cuneiform(slab = "powerpc_mpc8xx")])
    • Slabs are either embedded system boards or other specific architecture.
    • Slab checking have two stages:
      • First, it checks the given board/architecture if exist.
      • If not slabs fall back to Rust supported architectures.
      • Still architecture is not detected, it will fall back to default values.
  • force = u8 (e.g. #[cuneiform(force = 16)])
    • Forces a given cache alignment. Overrides all other systems mentioned above.
[dependencies]
cuneiform = "0.1"

Examples

Basic usage can be:

use cuneiform::*;

// Defaults to `hermetic = true`
#[cuneiform]
pub struct Varying {
    data: u8,
    data_2: u16,
}

Targeting specific architecture:

use cuneiform::*;

#[cuneiform(slab = "krait")]
pub struct SlabBased {
    data: u8,
    data_2: u16,
}

Overriding the default cache alignment:

use cuneiform::*;

#[cuneiform(force = 16)]
pub struct Forced {
    data: u8,
    data_2: u16,
}

Attribute Macros

cuneiform

Entry point for cuneiform proc macro attribute.