-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compression #14
Comments
Ideally, also need to provide several types of compression to choose from |
In isolation, I'd say zstd would probably serve almost every purpose you'd need: you can spend a lot of time compressing very well, or a tiny amount of time to get a decent amount of compression. The one reason to support multiple compression algorithms: if a program already needs a specific algorithm for some other purpose, it'd be nice to use the same one and avoid having two decompression libraries present. |
One of my goals for the project is to not pull in unnecessary dependencies, so this lines up well. However, one thing I'd like to ensure is that the Without having read the We've wasted more engineering hours than I'd care to admit at work just because of C build systems 😞 |
https://crates.io/crates/snap might also be a good choice. Problem area might be the license. |
I used the lz4_compression crate. It seems lightweight and it's written in pure Rust (which I presume means it will run on multiple targets). Even if this isn't the library you want to go with @Michael-F-Bryan , I thought I'd get the ball rolling. |
My few thoughts on this:
In pseudo-Rust, this becomes pub struct Dir<'a, C: Compression> { /* ... */ }
pub struct File<'a, C: Compression> { /* ... */ }
pub enum DirEntry<'a, C: Compression> { /* ... */ }
pub trait Compression {
// using a `Cow<[u8]>` benefits the performance of `compress::None`
fn decompress(data: &[u8]) -> Cow<[u8]>;
}
pub mod compress {
pub enum None {}
impl Compression for None { /* ... */ }
#[cfg(feature = "compress-foo")]
pub enum Foo {}
#[cfg(feature = "compress-foo")]
impl Compression for Foo { /* ... */ }
}
pub include_dir!;
#[cfg(feature = "compress-foo")]
pub include_dir_foo!; It may be possible to do An unrelated open question is whether to compress each file as one unit (presumably better compression for directories with many small files) or individually (presumably better seek performance), or even leaving it to |
To avoid bloating binaries too much, let's introduce a feature flag which will allow data to be compressed when it is embedded in the binary, then lazily decompressed when it is accessed.
I imagine this feature flag would alter the
include_dir::File
type from this...include_dir/include_dir/src/file.rs
Lines 8 to 13 in 0536fd6
... to something like this:
Some things that need to be considered are:
&self
and interior mutability)The text was updated successfully, but these errors were encountered: