benchmark: use compressable data to get more realistic result

And add a benchmatrk to test chunk verify speed (decompress+sha256).
This commit is contained in:
Dietmar Maurer 2020-09-24 08:55:48 +02:00
parent 09a1da25ed
commit baae780c99

View File

@ -21,6 +21,8 @@ use proxmox_backup::backup::{
load_and_decrypt_key, load_and_decrypt_key,
CryptConfig, CryptConfig,
KeyDerivationConfig, KeyDerivationConfig,
DataBlob,
DataChunkBuilder,
}; };
use proxmox_backup::client::*; use proxmox_backup::client::*;
@ -60,6 +62,9 @@ struct Speed {
"aes256_gcm": { "aes256_gcm": {
type: Speed, type: Speed,
}, },
"verify": {
type: Speed,
},
}, },
)] )]
#[derive(Copy, Clone, Serialize)] #[derive(Copy, Clone, Serialize)]
@ -75,9 +80,10 @@ struct BenchmarkResult {
decompress: Speed, decompress: Speed,
/// AES256 GCM encryption speed /// AES256 GCM encryption speed
aes256_gcm: Speed, aes256_gcm: Speed,
/// Verify speed
verify: Speed,
} }
static BENCHMARK_RESULT_2020_TOP: BenchmarkResult = BenchmarkResult { static BENCHMARK_RESULT_2020_TOP: BenchmarkResult = BenchmarkResult {
tls: Speed { tls: Speed {
speed: None, speed: None,
@ -85,19 +91,23 @@ static BENCHMARK_RESULT_2020_TOP: BenchmarkResult = BenchmarkResult {
}, },
sha256: Speed { sha256: Speed {
speed: None, speed: None,
top: 1_000_000.0 * 2120.0, // AMD Ryzen 7 2700X top: 1_000_000.0 * 2022.0, // AMD Ryzen 7 2700X
}, },
compress: Speed { compress: Speed {
speed: None, speed: None,
top: 1_000_000.0 * 2158.0, // AMD Ryzen 7 2700X top: 1_000_000.0 * 752.0, // AMD Ryzen 7 2700X
}, },
decompress: Speed { decompress: Speed {
speed: None, speed: None,
top: 1_000_000.0 * 8062.0, // AMD Ryzen 7 2700X top: 1_000_000.0 * 1198.0, // AMD Ryzen 7 2700X
}, },
aes256_gcm: Speed { aes256_gcm: Speed {
speed: None, speed: None,
top: 1_000_000.0 * 3803.0, // AMD Ryzen 7 2700X top: 1_000_000.0 * 3645.0, // AMD Ryzen 7 2700X
},
verify: Speed {
speed: None,
top: 1_000_000.0 * 758.0, // AMD Ryzen 7 2700X
}, },
}; };
@ -194,7 +204,10 @@ fn render_result(
.column(ColumnConfig::new("decompress") .column(ColumnConfig::new("decompress")
.header("ZStd level 1 decompression speed") .header("ZStd level 1 decompression speed")
.right_align(false).renderer(render_speed)) .right_align(false).renderer(render_speed))
.column(ColumnConfig::new("aes256_gcm") .column(ColumnConfig::new("verify")
.header("Chunk verification speed")
.right_align(false).renderer(render_speed))
.column(ColumnConfig::new("aes256_gcm")
.header("AES256 GCM encryption speed") .header("AES256 GCM encryption speed")
.right_align(false).renderer(render_speed)); .right_align(false).renderer(render_speed));
@ -257,7 +270,17 @@ fn test_crypt_speed(
let crypt_config = CryptConfig::new(testkey)?; let crypt_config = CryptConfig::new(testkey)?;
let random_data = proxmox::sys::linux::random_data(1024*1024)?; //let random_data = proxmox::sys::linux::random_data(1024*1024)?;
let mut random_data = vec![];
// generate pseudo random byte sequence
for i in 0..256*1024 {
for j in 0..4 {
let byte = ((i >> (j<<3))&0xff) as u8;
random_data.push(byte);
}
}
assert_eq!(random_data.len(), 1024*1024);
let start_time = std::time::Instant::now(); let start_time = std::time::Instant::now();
@ -322,5 +345,23 @@ fn test_crypt_speed(
eprintln!("AES256/GCM speed: {:.2} MB/s", speed/1_000_000_.0); eprintln!("AES256/GCM speed: {:.2} MB/s", speed/1_000_000_.0);
let start_time = std::time::Instant::now();
let (chunk, digest) = DataChunkBuilder::new(&random_data)
.compress(true)
.build()?;
let mut bytes = 0;
loop {
chunk.verify_unencrypted(random_data.len(), &digest)?;
bytes += random_data.len();
if start_time.elapsed().as_micros() > 1_000_000 { break; }
}
let speed = (bytes as f64)/start_time.elapsed().as_secs_f64();
benchmark_result.verify.speed = Some(speed);
eprintln!("Verify speed: {:.2} MB/s", speed/1_000_000_.0);
Ok(()) Ok(())
} }