mutant-remix / mrxbuilder

Emoji pack builder in Rust with support for many formats
https://mutant.revolt.chat/
GNU Affero General Public License v3.0
4 stars 0 forks source link

chore: replace oxipng with crates.io version once it's published #1

Closed wait-what closed 10 months ago

wait-what commented 1 year ago

src/encode Putting it inside a rayon par_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

wait-what commented 1 year 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}");
    });
}
wait-what commented 1 year ago

Seems to be an upstream issue https://github.com/shssoichiro/oxipng/issues/517