pessimize

Crates.iopessimize
lib.rspessimize
version2.0.0
sourcesrc
created_at2024-01-05 10:41:46.449346
updated_at2024-06-14 05:50:56.286563
descriptionMore efficient Rust compiler optimization barriers
homepage
repository
max_upload_size
id1089573
size205,746
Hadrien G. (HadrienG2)

documentation

README

pessimize - More efficient Rust compiler optimization barriers

MPL licensed Package on crates.io Documentation Continuous
Integration Requires rustc
1.79.0+

Microbenchmarking is a subtle exercise to begin with, and the lack of lightweight optimization barriers on stable Rust makes it even more difficult. This crate aims to improve upon the statu quo by providing an alternative to std::hint::black_box which is...

  • As lightweight as a library-based approach can be
  • Fine-grained, enabling precise intent statement and thus lower overhead
  • Reliable (no more "this might do nothing on some compiler targets", if it compiles then it should work as advertized).

In exchange, the price to pay is...

  • Reduced microbenchmark portability (currently 32-bit and 64-bit flavors of ARM, x86 and RISC-V, more can be envisioned on nightly / future stable Rust)
  • Lots of unsafe code in the implementation (we often need to convert an std type with safety invariants to a simpler data structure with less safety invariants, pass the members of this data structure through an optimization barrier that does nothing, then convert it back to the original type).
Commit count: 0

cargo fmt