feat(bin): report freelist in db stats (#5355)

This commit is contained in:
Alexey Shekhirin
2023-11-08 13:05:55 +00:00
committed by GitHub
parent 5daaa7fe27
commit aa9a8dcad8
2 changed files with 16 additions and 2 deletions

View File

@ -13,7 +13,7 @@ use eyre::WrapErr;
use human_bytes::human_bytes;
use reth_db::{
database::Database,
open_db, open_db_read_only,
mdbx, open_db, open_db_read_only,
version::{get_db_version, DatabaseVersionError, DB_VERSION},
Tables,
};
@ -166,6 +166,19 @@ impl Command {
.add_cell(Cell::new(human_bytes(total_size as f64)));
stats_table.add_row(row);
let freelist = tx.inner.env().freelist()?;
let freelist_size = freelist *
tx.inner.db_stat(&mdbx::Database::freelist_db())?.page_size() as usize;
let mut row = Row::new();
row.add_cell(Cell::new("Freelist size"))
.add_cell(Cell::new(freelist))
.add_cell(Cell::new(""))
.add_cell(Cell::new(""))
.add_cell(Cell::new(""))
.add_cell(Cell::new(human_bytes(freelist_size as f64)));
stats_table.add_row(row);
Ok::<(), eyre::Report>(())
})??;

View File

@ -39,7 +39,8 @@ impl<'txn> Database<'txn> {
Self { dbi, _marker: PhantomData }
}
pub(crate) fn freelist_db() -> Self {
/// Opens the freelist database with DBI `0`.
pub fn freelist_db() -> Self {
Database { dbi: 0, _marker: PhantomData }
}