change database logs to human readable forms (#8389)

This commit is contained in:
Alfredo Garcia 2024-04-11 07:41:52 -03:00 committed by GitHub
parent 49fca309cf
commit 339a42f86d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 21 additions and 8 deletions

View File

@ -1958,6 +1958,12 @@ version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
[[package]]
name = "human_bytes"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "91f255a4535024abf7640cb288260811fc14794f62b063652ed349f9a6c2348e"
[[package]]
name = "humantime"
version = "2.1.0"
@ -6091,6 +6097,7 @@ dependencies = [
"hex",
"hex-literal",
"howudoin",
"human_bytes",
"humantime-serde",
"indexmap 2.2.5",
"insta",

View File

@ -53,6 +53,7 @@ futures = "0.3.30"
hex = "0.4.3"
hex-literal = "0.4.1"
humantime-serde = "1.1.1"
human_bytes = { version = "0.4.3", default-features = false }
indexmap = "2.2.5"
itertools = "0.12.1"
lazy_static = "1.4.0"

View File

@ -542,24 +542,29 @@ impl DiskDb {
.unwrap_or(Some(0));
total_size_in_mem += mem_table_size.unwrap_or(0);
// TODO: Consider displaying the disk and memory sizes in a human-readable format - #8380.
write!(
column_families_log_string,
"{} (Disk: {} bytes, Memory: {} bytes)",
"{} (Disk: {}, Memory: {})",
cf_name,
cf_disk_size,
mem_table_size.unwrap_or(0)
human_bytes::human_bytes(cf_disk_size as f64),
human_bytes::human_bytes(mem_table_size.unwrap_or(0) as f64)
)
.unwrap();
}
debug!("{}", column_families_log_string);
info!("Total Database Disk Size: {} bytes", total_size_on_disk);
info!(
"Total Live Data Disk Size: {} bytes",
total_live_size_on_disk
"Total Database Disk Size: {}",
human_bytes::human_bytes(total_size_on_disk as f64)
);
info!(
"Total Live Data Disk Size: {}",
human_bytes::human_bytes(total_live_size_on_disk as f64)
);
info!(
"Total Database Memory Size: {}",
human_bytes::human_bytes(total_size_in_mem as f64)
);
info!("Total Database Memory Size: {} bytes", total_size_in_mem);
}
/// Returns a forward iterator over the items in `cf` in `range`.