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

View File

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

View File

@ -542,24 +542,29 @@ impl DiskDb {
.unwrap_or(Some(0)); .unwrap_or(Some(0));
total_size_in_mem += mem_table_size.unwrap_or(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!( write!(
column_families_log_string, column_families_log_string,
"{} (Disk: {} bytes, Memory: {} bytes)", "{} (Disk: {}, Memory: {})",
cf_name, cf_name,
cf_disk_size, human_bytes::human_bytes(cf_disk_size as f64),
mem_table_size.unwrap_or(0) human_bytes::human_bytes(mem_table_size.unwrap_or(0) as f64)
) )
.unwrap(); .unwrap();
} }
debug!("{}", column_families_log_string); debug!("{}", column_families_log_string);
info!("Total Database Disk Size: {} bytes", total_size_on_disk);
info!( info!(
"Total Live Data Disk Size: {} bytes", "Total Database Disk Size: {}",
total_live_size_on_disk 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`. /// Returns a forward iterator over the items in `cf` in `range`.