Crates.io | cuneiform-fields |
lib.rs | cuneiform-fields |
version | 0.1.1 |
source | src |
created_at | 2019-12-29 18:54:35.725024 |
updated_at | 2021-02-03 21:24:11.65848 |
description | Field level [no_std] cache optimizations for Rust. |
homepage | https://github.com/vertexclique/cuneiform-fields |
repository | https://github.com/vertexclique/cuneiform-fields |
max_upload_size | |
id | 193299 |
size | 23,780 |
This crate provides cache line size fitting optimizations to fields in structs.
This crate aligns fields with #[repr(align(COHERENCE_LINE_SIZE))]
to decrease the time between prefetch signals for data.
COHERENCE_LINE_SIZE
can be detected or decided based on the architecture by cuneiform
itself.
[dependencies]
cuneiform-fields = "0.1"
Align by hermetic cache line size detection mentioned in cuneiform readme:
use cuneiform_fields::prelude::*;
pub struct Hermetic {
data: HermeticPadding<u8>,
data_2: u16,
}
In the example above data
will be aligned by hermetic alignment but field data_2
isn't going to be alignment optimized.
Align by cache line size detected by current Rust compiler architecture. If architecture isn't detected in known architectures it will fall back to default alignment:
use cuneiform_fields::prelude::*;
pub struct ArchSpecific {
data: ArchPadding<u8>,
data_2: u16,
}
In the example above data
will be aligned by architecture alignment but field data_2
isn't going to be alignment optimized.
NOTE: Alignment values are not randomly chosen or incorporated directly. Values are considered and incorporated inside with the mindset of preventing false sharing or creating less warp points in exclusive caching.
For design choices, architecture and board systems and more information. Please visit Cuneiform GitHub.