Open onur-ozkan opened 1 year ago
I dumped a payload used in a real swap operation, and write a simple example:
use compress_demo::PAYLOAD_DUMP;
use lz4_flex::{compress_prepend_size, decompress_size_prepended};
fn main() {
let compressed = compress_prepend_size(PAYLOAD_DUMP);
println!(
"compressed: {}, original: {}",
compressed.len(),
PAYLOAD_DUMP.len()
);
let uncompressed = decompress_size_prepended(&compressed).unwrap();
assert_eq!(uncompressed, PAYLOAD_DUMP);
}
which outputs the following:
~/devspace/.other/compress-demo stable $ perf stat ./target/release/compress-demo
compressed: 3508, original: 7183
Performance counter stats for './target/release/compress-demo':
0.31 msec task-clock:u # 0.665 CPUs utilized
0 context-switches:u # 0.000 K/sec
0 cpu-migrations:u # 0.000 K/sec
73 page-faults:u # 0.239 M/sec
358,384 cycles:u # 1.171 GHz (92.14%)
991 stalled-cycles-frontend:u # 0.28% frontend cycles idle
22,654 stalled-cycles-backend:u # 6.32% backend cycles idle
429,716 instructions:u # 1.20 insn per cycle
# 0.05 stalled cycles per insn
94,596 branches:u # 309.077 M/sec
0 branch-misses:u # 0.00% of all branches (7.86%)
0.000460520 seconds time elapsed
0.000476000 seconds user
0.000000000 seconds sys
Reduce the network overhead by doing compressions on the data blocks.