mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-06 11:35:45 +00:00
Added multithreading by default to zstd compression. Bumped zstd package version. Added num_cpus package to get core count.
This commit is contained in:
parent
4a323aeba8
commit
0ec7d4489d
@ -22,6 +22,8 @@ Categories Used:
|
|||||||
|
|
||||||
### New Features
|
### New Features
|
||||||
|
|
||||||
|
- Add multithreading support for `zstd` compression [\#688](https://github.com/ouch-org/ouch/pull/688) ([nalabrie](https://github.com/nalabrie))
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
- Fix output corrupted on parallel decompression [\#642](https://github.com/ouch-org/ouch/pull/642) ([AntoniosBarotsis](https://github.com/AntoniosBarotsis))
|
- Fix output corrupted on parallel decompression [\#642](https://github.com/ouch-org/ouch/pull/642) ([AntoniosBarotsis](https://github.com/AntoniosBarotsis))
|
||||||
|
5
Cargo.lock
generated
5
Cargo.lock
generated
@ -848,6 +848,7 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
"linked-hash-map",
|
"linked-hash-map",
|
||||||
"lz4_flex",
|
"lz4_flex",
|
||||||
|
"num_cpus",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"parse-display",
|
"parse-display",
|
||||||
"proptest",
|
"proptest",
|
||||||
@ -1796,9 +1797,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zstd"
|
name = "zstd"
|
||||||
version = "0.13.1"
|
version = "0.13.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2d789b1514203a1120ad2429eae43a7bd32b90976a7bb8a05f7ec02fa88cc23a"
|
checksum = "fcf2b778a664581e31e389454a7072dab1647606d44f7feea22cd5abb9c9f3f9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"zstd-safe",
|
"zstd-safe",
|
||||||
]
|
]
|
||||||
|
@ -23,6 +23,7 @@ ignore = "0.4.22"
|
|||||||
libc = "0.2.155"
|
libc = "0.2.155"
|
||||||
linked-hash-map = "0.5.6"
|
linked-hash-map = "0.5.6"
|
||||||
lz4_flex = "0.11.3"
|
lz4_flex = "0.11.3"
|
||||||
|
num_cpus = "1.16.0"
|
||||||
once_cell = "1.19.0"
|
once_cell = "1.19.0"
|
||||||
rayon = "1.10.0"
|
rayon = "1.10.0"
|
||||||
same-file = "1.0.6"
|
same-file = "1.0.6"
|
||||||
@ -34,7 +35,7 @@ time = { version = "0.3.36", default-features = false }
|
|||||||
unrar = { version = "0.5.3", optional = true }
|
unrar = { version = "0.5.3", optional = true }
|
||||||
xz2 = "0.1.7"
|
xz2 = "0.1.7"
|
||||||
zip = { version = "0.6.6", default-features = false, features = ["time"] }
|
zip = { version = "0.6.6", default-features = false, features = ["time"] }
|
||||||
zstd = { version = "0.13.1", default-features = false }
|
zstd = { version = "0.13.2", default-features = false, features = ["zstdmt"]}
|
||||||
|
|
||||||
[target.'cfg(not(unix))'.dependencies]
|
[target.'cfg(not(unix))'.dependencies]
|
||||||
is_executable = "1.0.1"
|
is_executable = "1.0.1"
|
||||||
|
@ -69,16 +69,18 @@ pub fn compress_files(
|
|||||||
.from_writer(encoder),
|
.from_writer(encoder),
|
||||||
),
|
),
|
||||||
Zstd => {
|
Zstd => {
|
||||||
let zstd_encoder = zstd::stream::write::Encoder::new(
|
let mut zstd_encoder = zstd::stream::write::Encoder::new(
|
||||||
encoder,
|
encoder,
|
||||||
level.map_or(zstd::DEFAULT_COMPRESSION_LEVEL, |l| {
|
level.map_or(zstd::DEFAULT_COMPRESSION_LEVEL, |l| {
|
||||||
(l as i32).clamp(zstd::zstd_safe::min_c_level(), zstd::zstd_safe::max_c_level())
|
(l as i32).clamp(zstd::zstd_safe::min_c_level(), zstd::zstd_safe::max_c_level())
|
||||||
}),
|
}),
|
||||||
);
|
)?;
|
||||||
|
// Use all available PHYSICAL cores for compression
|
||||||
|
zstd_encoder.multithread(num_cpus::get_physical() as u32)?;
|
||||||
// Safety:
|
// Safety:
|
||||||
// Encoder::new() can only fail if `level` is invalid, but the level
|
// Encoder::new() can only fail if `level` is invalid, but the level
|
||||||
// is `clamp`ed and therefore guaranteed to be valid
|
// is `clamp`ed and therefore guaranteed to be valid
|
||||||
Box::new(zstd_encoder.unwrap().auto_finish())
|
Box::new(zstd_encoder.auto_finish())
|
||||||
}
|
}
|
||||||
Tar | Zip | Rar | SevenZip => unreachable!(),
|
Tar | Zip | Rar | SevenZip => unreachable!(),
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user