0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-29 02:02:38 +01:00

ircd::db: Move computed properties from console into info struct.

This commit is contained in:
Jason Volk 2020-09-29 07:12:41 -07:00
parent 1051e740cc
commit ca7b7b0c61
3 changed files with 39 additions and 34 deletions

View file

@ -38,12 +38,16 @@ struct ircd::db::database::sst::info
uint64_t format {0};
uint64_t cfid {0};
uint64_t size {0};
uint64_t head_size {0}; // index_size + filter_size
uint64_t data_size {0};
uint64_t index_size {0};
uint64_t top_index_size {0};
uint64_t file_size {0}; // head_size + data_size
uint64_t index_root_size {0};
uint64_t index_data_size {0};
uint64_t index_size {0}; // index_root_size + index_data_size
uint64_t filter_size {0};
uint64_t keys_size {0};
uint64_t values_size {0};
uint64_t blocks_size {0}; // keys_size + values_size
uint64_t index_parts {0};
uint64_t data_blocks {0};
uint64_t entries {0};
@ -60,6 +64,7 @@ struct ircd::db::database::sst::info
time_t created {0};
time_t oldest_key {0};
bool delta_encoding {false};
float compression_pct {0.0};
info(const database &, const string_view &filename);
info() = default;

View file

@ -4120,8 +4120,8 @@ ircd::db::database::sst::info::operator=(rocksdb::TableProperties &&tp)
format = std::move(tp.format_version);
cfid = std::move(tp.column_family_id);
data_size = std::move(tp.data_size);
index_size = std::move(tp.index_size);
top_index_size = std::move(tp.top_level_index_size);
index_data_size = std::move(tp.index_size);
index_root_size = std::move(tp.top_level_index_size);
filter_size = std::move(tp.filter_size);
keys_size = std::move(tp.raw_key_size);
values_size = std::move(tp.raw_value_size);
@ -4133,6 +4133,17 @@ ircd::db::database::sst::info::operator=(rocksdb::TableProperties &&tp)
created = std::move(tp.creation_time);
oldest_key = std::move(tp.oldest_key_time);
delta_encoding = std::move(tp.index_value_is_delta_encoded);
blocks_size = keys_size + values_size;
index_size = index_data_size + index_root_size;
head_size = index_size + filter_size;
file_size = head_size + data_size;
const long double _blocks_size(std::max(blocks_size, 1UL));
compression_pct = compression != "NoCompression"?
(100 - 100.0L * (data_size / _blocks_size)):
0.0;
return *this;
}

View file

@ -4416,12 +4416,6 @@ _print_sst_info(opt &out,
0UL
};
const auto blocks_size{f.keys_size + f.values_size};
const auto compression_pct
{
100 - 100.0L * (f.data_size / double(blocks_size))
};
char tmbuf[64], pbuf[48];
out << std::left << std::setfill(' ')
<< std::setw(12) << f.name
@ -4429,7 +4423,7 @@ _print_sst_info(opt &out,
<< " " << std::setw(1) << std::left << (!f.filter.empty()? 'F' : '-')
<< std::setw(1) << std::left << (f.delta_encoding? 'D' : '-')
<< std::setw(1) << std::left << (true? '-' : '-')
<< " " << std::setw(6) << std::right << std::fixed << std::setprecision(2) << compression_pct << '%'
<< " " << std::setw(6) << std::right << std::fixed << std::setprecision(2) << f.compression_pct << '%'
<< " " << std::setw(5) << std::left << trunc(f.compression, 5)
<< " " << std::setw(24) << std::left << pretty(pbuf, iec(f.size))
;
@ -4522,29 +4516,24 @@ _print_sst_info_full(opt &out,
close_auto("range deletes", f.range_deletes);
close_auto("", "");
const auto blocks_size{f.keys_size + f.values_size};
const auto index_size{f.index_size + f.top_index_size};
const auto overhead_size{index_size + f.filter_size};
const auto file_size{overhead_size + f.data_size};
close_size("size", file_size);
close_size("head size", overhead_size);
close_size("size", f.file_size);
close_size("head size", f.head_size);
close_size("data size", f.data_size);
close_size("data blocks average size", f.data_size / double(f.data_blocks));
close_auto("data compression percent", 100 - 100.0L * (f.data_size / double(blocks_size)));
close_auto("data compression percent", 100 - 100.0L * (f.data_size / double(f.blocks_size)));
close_auto("", "");
close_size("index size", index_size);
close_size("index root size", f.top_index_size);
close_size("index size", f.index_size);
close_size("index root size", f.index_root_size);
close_size("index data size", f.index_data_size);
close_auto("index data blocks", f.index_parts);
close_size("index data size", f.index_size);
close_size("index data block average size", f.index_size / double(f.index_parts));
close_size("index data average per-key", f.index_size / double(f.entries));
close_size("index data average per-block", f.index_size / double(f.data_blocks));
close_auto("index root percent of index", 100.0 * (f.top_index_size / double(f.index_size)));
close_auto("index data percent of keys", 100.0 * (f.index_size / double(f.keys_size)));
close_auto("index data percent of values", 100.0 * (f.index_size / double(f.values_size)));
close_auto("index data percent of data", 100.0 * (f.index_size / double(f.data_size)));
close_size("index data block average size", f.index_data_size / double(f.index_parts));
close_size("index data average per-key", f.index_data_size / double(f.entries));
close_size("index data average per-block", f.index_data_size / double(f.data_blocks));
close_auto("index root percent of index", 100.0 * (f.index_root_size / double(f.index_data_size)));
close_auto("index data percent of keys", 100.0 * (f.index_data_size / double(f.keys_size)));
close_auto("index data percent of values", 100.0 * (f.index_data_size / double(f.values_size)));
close_auto("index data percent of data", 100.0 * (f.index_data_size / double(f.data_size)));
close_auto("", "");
close_auto("filter", f.filter);
@ -4554,14 +4543,14 @@ _print_sst_info_full(opt &out,
close_auto("", "");
close_auto("blocks", f.data_blocks);
close_size("blocks size", blocks_size);
close_size("blocks average size", blocks_size / double(f.data_blocks));
close_size("blocks size", f.blocks_size);
close_size("blocks average size", f.blocks_size / double(f.data_blocks));
close_auto("", "");
close_auto("keys", f.entries);
close_size("keys size", f.keys_size);
close_size("keys average size", f.keys_size / double(f.entries));
close_auto("keys percent of blocks", 100.0 * (f.keys_size / double(blocks_size)));
close_auto("keys percent of blocks", 100.0 * (f.keys_size / double(f.blocks_size)));
close_auto("", "");
close_auto("values", f.entries);
@ -4734,8 +4723,8 @@ try
{
total.size += info.size;
total.data_size += info.data_size;
total.index_size += info.index_size;
total.top_index_size += info.top_index_size;
total.index_data_size += info.index_data_size;
total.index_root_size += info.index_root_size;
total.filter_size += info.filter_size;
total.keys_size += info.keys_size;
total.values_size += info.values_size;