Closed wait-what closed 10 months ago
Using this code as an example. My CPU has 12 threads. This works perfectly well with 11, but as soon as I uncomment 12, none of them finish, there is no CPU activity and the program just hangs. On an 8 thread CPU, it works with 7, but hangs with 8, etc.
use rayon::prelude::*;
use oxipng::{optimize_from_memory, Options, Deflaters};
fn main() {
let buffer = include_bytes!("sample.png").as_slice();
let options = Options {
deflate: Deflaters::Libdeflater { compression: 12 },
..Default::default()
};
vec![
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
// 12,
].par_iter().for_each(|x| {
println!("Optimizing {x}");
optimize_from_memory(&buffer, &options).unwrap();
println!("Done {x}");
});
}
Seems to be an upstream issue https://github.com/shssoichiro/oxipng/issues/517
src/encode
Putting it inside a rayonpar_iter
makes it hang, presumably because it already uses rayon. Since oxipng is really, really slow, it's important to make it multithreaded.Once fixed, also update docs/input-manifest.md