clf 0.2.0

flush the cpu cache line by __builtin_clear_cache()
Documentation

clf

crate Docs Rust Version Apache2/MIT licensed Test ubu Test mac Test win

Flush the data cache line.

This crate can be used when you do benchmarks that are not dependent on the cpu cache.

Supports

  • x86_64, aarch64 (native implementation)
  • mips64el, powerpc64le ... etc (fallback to __builtin_clear_cache)
  • minimum support rustc 1.70.0 (due to core::arch and asm!)

Examples

Easy to use:

let a = vec![1, 2, 3, 4, 5, 6, 7, 8, 9];
clf::cache_line_flush_with_slice(&a);

or

let a = vec![1, 2, 3, 4, 5, 6, 7, 8, 9];
let begin_ptr = a.as_ptr();
let end_ptr = unsafe { begin_ptr.add(a.len()) };
unsafe { clf::cache_line_flush_with_ptr(begin_ptr, end_ptr) };

References

CPU cache

Benchmarking

To measure the effectiveness of the cache flushing, you can run the included benchmarks:

make bench

This will compare the access time of "warm" data versus "flushed" data.

Changelogs

This crate's changelog here.

License

This project is licensed under either of

at your option.