Closed
Description
Between rustc 1.14.0-nightly (5665bdf3e 2016-11-02)
and rustc 1.14.0-nightly (cae6ab1c4 2016-11-05)
all of my serialization benchmarks showed a ~50% regression. It affected all the libraries (Serde, json-rust, rustc-serialize). Deserialization was not affected. So far I have narrowed it down to the following code:
#![feature(test)]
extern crate test;
#[bench]
fn bench(b: &mut test::Bencher) {
const N: usize = 65536;
let mut buf = Vec::with_capacity(N);
b.iter(|| {
buf.clear();
for _ in 0..N {
w(&mut buf, b'[').unwrap();
}
});
}
#[inline(never)]
fn w(buf: &mut Vec<u8>, b: u8) -> Result<(), ::std::io::Error> {
buf.extend_from_slice(&[b]);
Ok(())
}
On my linux laptop this regressed from 160μs to 220μs, on my mac laptop 215μs to 300μs.
cc @bluss who seems to know about extend_from_slice
.