src/backup/chunk_store.rs: use zstd compression insteadf of lz4

Provides better compressionm rate, and is still fast.
This commit is contained in:
Dietmar Maurer 2019-03-07 11:42:59 +01:00
parent d2690f74bb
commit 141f062e08
3 changed files with 6 additions and 8 deletions

View File

@ -41,7 +41,7 @@ md5 = "0.6"
base64 = "0.10" base64 = "0.10"
pam-sys = "0.5" pam-sys = "0.5"
pam = "0.7" pam = "0.7"
lz4 = "1.23" zstd = "0.4"
xdg = "2.2" xdg = "2.2"
[patch.crates-io] [patch.crates-io]

4
debian/control vendored
View File

@ -6,7 +6,7 @@ Build-Depends: bash-completion,
debhelper (>= 10), debhelper (>= 10),
python3-docutils, python3-docutils,
python3-sphinx, python3-sphinx,
liblz4-dev, libzstd-dev,
libpam0g-dev, libpam0g-dev,
pkg-config, pkg-config,
Standards-Version: 3.9.5 Standards-Version: 3.9.5
@ -18,6 +18,6 @@ Depends: ${shlibs:Depends}, ${misc:Depends},
libjs-extjs (>= 6.0.1), libjs-extjs (>= 6.0.1),
fonts-font-awesome, fonts-font-awesome,
proxmox-widget-toolkit, proxmox-widget-toolkit,
liblz4-1, libzstd1,
Description: Proxmox Backup Server Description: Proxmox Backup Server
This is experimental code used to test Rust. This is experimental code used to test Rust.

View File

@ -183,7 +183,7 @@ impl ChunkStore {
buffer.clear(); buffer.clear();
let f = std::fs::File::open(&chunk_path)?; let f = std::fs::File::open(&chunk_path)?;
let mut decoder = lz4::Decoder::new(f)?; let mut decoder = zstd::stream::Decoder::new(f)?;
decoder.read_to_end(buffer)?; decoder.read_to_end(buffer)?;
@ -333,12 +333,10 @@ impl ChunkStore {
let f = std::fs::File::create(&tmp_path)?; let f = std::fs::File::create(&tmp_path)?;
// fixme: what is the fasted lz4 encoder available (see lzbench)? let mut encoder = zstd::stream::Encoder::new(f, 1)?;
let mut encoder = lz4::EncoderBuilder::new().level(1).build(f)?;
encoder.write_all(chunk)?; encoder.write_all(chunk)?;
let (f, encode_result) = encoder.finish(); let f = encoder.finish()?;
encode_result?;
if let Err(err) = std::fs::rename(&tmp_path, &chunk_path) { if let Err(err) = std::fs::rename(&tmp_path, &chunk_path) {
if let Err(_) = std::fs::remove_file(&tmp_path) { /* ignore */ } if let Err(_) = std::fs::remove_file(&tmp_path) { /* ignore */ }