),
}
);
+
+ /**
+ * tree stats
+ */
+ auto tree_label = sm::label("tree");
+ auto onode_label = tree_label("ONODE");
+ stats.committed_onode_tree_stats = {};
+ stats.invalidated_onode_tree_stats = {};
+ metrics.add_group(
+ "cache",
+ {
+ sm::make_counter(
+ "tree_depth",
+ stats.committed_onode_tree_stats.depth,
+ sm::description("the depth of tree"),
+ {onode_label}
+ ),
+ sm::make_counter(
+ "tree_inserts_committed",
+ stats.committed_onode_tree_stats.num_inserts,
+ sm::description("total number of committed insert operations"),
+ {onode_label}
+ ),
+ sm::make_counter(
+ "tree_erases_committed",
+ stats.committed_onode_tree_stats.num_erases,
+ sm::description("total number of committed erase operations"),
+ {onode_label}
+ ),
+ sm::make_counter(
+ "tree_inserts_invalidated",
+ stats.invalidated_onode_tree_stats.num_inserts,
+ sm::description("total number of invalidated insert operations"),
+ {onode_label}
+ ),
+ sm::make_counter(
+ "tree_erases_invalidated",
+ stats.invalidated_onode_tree_stats.num_erases,
+ sm::description("total number of invalidated erase operations"),
+ {onode_label}
+ ),
+ }
+ );
+
+ auto lba_label = tree_label("LBA");
+ stats.committed_lba_tree_stats = {};
+ stats.invalidated_lba_tree_stats = {};
+ metrics.add_group(
+ "cache",
+ {
+ sm::make_counter(
+ "tree_depth",
+ stats.committed_lba_tree_stats.depth,
+ sm::description("the depth of tree"),
+ {lba_label}
+ ),
+ sm::make_counter(
+ "tree_inserts_committed",
+ stats.committed_lba_tree_stats.num_inserts,
+ sm::description("total number of committed insert operations"),
+ {lba_label}
+ ),
+ sm::make_counter(
+ "tree_erases_committed",
+ stats.committed_lba_tree_stats.num_erases,
+ sm::description("total number of committed erase operations"),
+ {lba_label}
+ ),
+ sm::make_counter(
+ "tree_inserts_invalidated",
+ stats.invalidated_lba_tree_stats.num_inserts,
+ sm::description("total number of invalidated insert operations"),
+ {lba_label}
+ ),
+ sm::make_counter(
+ "tree_erases_invalidated",
+ stats.invalidated_lba_tree_stats.num_erases,
+ sm::description("total number of invalidated erase operations"),
+ {lba_label}
+ ),
+ }
+ );
}
void Cache::add_extent(CachedExtentRef ref)
efforts.mutate.increment(i->get_length());
efforts.mutate_delta_bytes += i->get_delta().length();
}
+
+ stats.invalidated_onode_tree_stats.increment(t.onode_tree_stats);
+ stats.invalidated_lba_tree_stats.increment(t.lba_tree_stats);
} else {
// read transaction won't have non-read efforts
assert(t.retired_set.empty());
assert(t.fresh_block_list.empty());
assert(t.mutated_block_list.empty());
+ assert(t.onode_tree_stats.is_clear());
+ assert(t.lba_tree_stats.is_clear());
}
}
assert(t.retired_set.empty());
assert(t.fresh_block_list.empty());
assert(t.mutated_block_list.empty());
+ assert(t.onode_tree_stats.is_clear());
+ assert(t.lba_tree_stats.is_clear());
}
}
assert(!t.is_weak());
assert(t.get_src() != Transaction::src_t::READ);
+ stats.committed_onode_tree_stats.increment(t.onode_tree_stats);
+ stats.committed_lba_tree_stats.increment(t.lba_tree_stats);
++(get_by_src(stats.trans_committed_by_src, t.get_src()));
auto& efforts = get_by_src(stats.committed_efforts_by_src,
t.get_src());
uint64_t read_transactions_successful;
effort_t read_effort_successful;
uint64_t dirty_bytes;
+ Transaction::tree_stats_t committed_onode_tree_stats;
+ Transaction::tree_stats_t committed_lba_tree_stats;
+ Transaction::tree_stats_t invalidated_onode_tree_stats;
+ Transaction::tree_stats_t invalidated_lba_tree_stats;
} stats;
template <typename CounterT>
root_leaf->pin.set_range(meta);
croot->get_root().lba_root =
lba_root_t{root_leaf->get_paddr(), 1u};
+ t.get_lba_tree_stats().depth = 1u;
return mkfs_iertr::now();
}).handle_error_interruptible(
mkfs_iertr::pass_further{},
laddr_t laddr,
lba_map_val_t val)
{
+ ++(t.get_lba_tree_stats().num_inserts);
auto split = insert_mapping_iertr::future<LBANodeRef>(
interruptible::ready_future_marker{},
root);
L_ADDR_MIN,
root->get_paddr(),
nullptr);
+ auto new_depth = root->get_node_meta().depth + 1;
croot->get_root().lba_root = lba_root_t{
nroot->get_paddr(),
- root->get_node_meta().depth + 1
+ new_depth
};
+ t.get_lba_tree_stats().depth = new_depth;
return nroot->split_entry(
get_context(t),
laddr, nroot->begin(), root);
croot = mut_croot->cast<RootBlock>();
}
auto new_root_addr = begin()->get_val().maybe_relative_to(get_paddr());
+ auto new_depth = get_meta().depth - 1;
croot->get_root().lba_root = lba_root_t{
new_root_addr,
- get_meta().depth - 1};
+ new_depth};
+ c.trans.get_lba_tree_stats().depth = new_depth;
logger().debug(
"LBAInternalNode::merge_entry: collapsing root {} to addr {}",
*this,
interruptible::ready_future_marker{},
mutated);
} else {
+ ++(c.trans.get_lba_tree_stats().num_erases);
journal_remove(mutation_pt, maybe_get_delta_buffer());
return mutate_mapping_ret(
interruptible::ready_future_marker{},
{
_super->write_root_laddr(c, impl->laddr());
as_root(std::move(_super));
+ c.t.get_onode_tree_stats().depth = static_cast<uint64_t>(level()) + 1;
}
void Node::as_root(Super::URef&& _super)
Ref<Node> this_ref = this;
DEBUGT("erase {}'s pos({}), get_next={} ...",
c.t, get_name(), pos, get_next);
+ ++(c.t.get_onode_tree_stats().num_erases);
// get the next cursor
return eagain_iertr::now().si_then([c, &pos, get_next, this] {
DEBUGT("insert {} with insert_key={}, insert_value={}, insert_pos({}), "
"history={}, mstat({}) ...",
c.t, get_name(), key, vconf, pos, history, mstat);
+ ++(c.t.get_onode_tree_stats().num_inserts);
search_position_t insert_pos = pos;
auto [insert_stage, insert_size] = impl->evaluate_insert(
key, vconf, history, mstat, insert_pos);
fresh_block_list.clear();
mutated_block_list.clear();
retired_set.clear();
+ onode_tree_stats = {};
+ lba_tree_stats = {};
to_release = NULL_SEG_ID;
conflicted = false;
if (!has_reset) {
return has_reset;
}
+ struct tree_stats_t {
+ uint64_t depth = 0;
+ uint64_t num_inserts = 0;
+ uint64_t num_erases = 0;
+
+ bool is_clear() const {
+ return (depth == 0 &&
+ num_inserts == 0 &&
+ num_erases == 0);
+ }
+ void increment(const tree_stats_t& incremental) {
+ if (incremental.depth != 0) {
+ // depth is an absolute value
+ depth = incremental.depth;
+ }
+ num_inserts += incremental.num_inserts;
+ num_erases += incremental.num_erases;
+ }
+ };
+ tree_stats_t& get_onode_tree_stats() {
+ return onode_tree_stats;
+ }
+ tree_stats_t& get_lba_tree_stats() {
+ return lba_tree_stats;
+ }
+
private:
friend class Cache;
friend Ref make_test_transaction();
pextent_set_t retired_set; ///< list of extents mutated by this transaction
+ tree_stats_t onode_tree_stats;
+ tree_stats_t lba_tree_stats;
+
///< if != NULL_SEG_ID, release this segment after completion
segment_id_t to_release = NULL_SEG_ID;