backhand icon indicating copy to clipboard operation
backhand copied to clipboard

FilesystemWriter::write on multiple threads

Open flxo opened this issue 2 years ago • 3 comments

Hello,

I'm evaluation backhand as a replacement for calling external squashfs tools. There's a significant drop in performance when creating a fs due to the lack of parallelism. My application spends most of its time somewhere in a compression implementation which is executed within a single thread.

Is there currently any change to utilise more threads for the compression?

Thanks

@flxo

flxo avatar Jul 21 '23 12:07 flxo

You are right, we currently don't have any methods that spawn multiple threads for writing a new filesystem. You would just need a new lock on the writer in this method, with a rayon::par_iter or something in this spot: https://github.com/wcampbell0x2a/backhand/blob/9fdf0cf8192155b04da9c3b5e34ba6c8047d8e16/src/filesystem/writer.rs#L440.

wcampbell0x2a avatar Jul 22 '23 14:07 wcampbell0x2a

Thanks for the update. Probably this needs some refactoring because the compression happens in data_writer.add_bytes(...) and files is borrowed from self.

flxo avatar Jul 27 '23 14:07 flxo

Thanks for the update. Probably this needs some refactoring because the compression happens in data_writer.add_bytes(...) and files is borrowed from self.

Feel free to submit a MR, I'm quite busy at the moment to do this!

wcampbell0x2a avatar Jul 27 '23 16:07 wcampbell0x2a