Minimal workspace to reproduce intra-crate vs cross-crate optimization differences for buffered I/O style loops with dyn Write vs generic Write.
It contains:
crates/intra_single_crate: single binary crate with two functions:write_bytes_dyn(&mut dyn Write, &[u8])(trait object, same crate)write_bytes_generic<W: Write>(W, &[u8])(monomorphized generic)
crates/inter_two_crates/writerlib: library crate exportingwrite_bytes_dyn_libthat takes&mut dyn Write.crates/inter_two_crates/app: binary crate that calls into the library.
The goal: compare code generation and runtime between:
- Intra‑crate
dynvs generic in one crate. - Cross‑crate
dyn(lib + app) with LTO off vs ThinLTO vs codegen‑units=1.
Use cargo-show-asm invoked as cargo asm to get the assembly readouts. Try toggling LTO=off, ThinLTO, codegen-units=1, etc.