}
);
+ metrics.add_group("cache", {
+ sm::make_counter("write_hit_hot", stats.write_hit_hot, sm::description("")),
+ sm::make_counter("write_hit_cold", stats.write_hit_cold, sm::description("")),
+ sm::make_counter("read_hit_hot", stats.read_hit_hot, sm::description("")),
+ sm::make_counter("read_hit_cold", stats.read_hit_cold, sm::description("")),
+ });
+
{
/*
* efforts discarded/committed
i->set_invalid(t);
}
}
+
+ stats.write_hit_hot += t.write_hit_hot;
+ stats.write_hit_cold += t.write_hit_cold;
}
void Cache::init()
return epm.is_pure_rbm();
}
+ void update_read_ratio(Transaction &t) {
+ stats.read_hit_hot += t.read_hit_hot;
+ stats.read_hit_cold += t.read_hit_cold;
+ }
+
private:
using get_extent_ertr = base_ertr;
template <typename T>
std::array<uint64_t, NUM_SRC_COMB> trans_conflicts_by_srcs;
counter_by_src_t<uint64_t> trans_conflicts_by_unknown;
+ uint64_t write_hit_hot;
+ uint64_t write_hit_cold;
+ uint64_t read_hit_hot;
+ uint64_t read_hit_cold;
+
rewrite_stats_t trim_rewrites;
rewrite_stats_t reclaim_rewrites;
} stats;
read_len,
pin_start,
pin_len);
+
rpins.emplace_back(
pin, read_start_aligned, read_len_aligned,
unalign_start_offset, read_len);
}
auto paddr = maybe_indirect_extent.extent->get_paddr();
all_cold &= ctx.tm.is_cold_device(paddr.get_device_id());
+
+ if (paddr.is_absolute()) {
+ ctx.tm.update_read_ratio(ctx.t, paddr.get_device_id());
+ }
+
}
if (!all_cold) {
assert(ctx.tm.is_prefix_cached(prefix));
ctx.tm.update_logical_bucket_for_read(prefix);
}
+ ctx.tm.submit_read_ratio(ctx.t);
co_return std::move(ret);
}
friend class crimson::os::seastore::SeaStore;
friend class TransactionConflictCondition;
+ uint64_t write_hit_hot = 0;
+ uint64_t write_hit_cold = 0;
+ uint64_t read_hit_hot = 0;
+ uint64_t read_hit_cold = 0;
+
void reset_preserve_handle() {
+ write_hit_hot = 0;
+ write_hit_cold = 0;
+ read_hit_hot = 0;
+ read_hit_cold = 0;
root.reset();
offset = 0;
delayed_temp_offset = 0;
}
};
+ void update_hit_ratio(Transaction& t, device_id_t id) {
+ if (epm->is_cold_device(id)) {
+ t.write_hit_cold++;
+ } else {
+ t.write_hit_hot++;
+ }
+ }
+
+ void update_read_ratio(Transaction& t, device_id_t id) {
+ if (epm->is_cold_device(id)) {
+ t.read_hit_cold++;
+ } else {
+ t.read_hit_hot++;
+ }
+ }
+
+ void submit_read_ratio(Transaction& t) {
+ if (cache) {
+ cache->update_read_ratio(t);
+ }
+ }
+
template <typename T>
using lextent_init_func_t = std::function<void (T&)>;
/**
return cut_mapping<T>(
t, (laddr + aligned_len).checked_to_laddr(), std::move(mapping), false);
} else {
+ if (mapping.is_linked_direct() && mapping.get_val().is_absolute()) {
+ update_hit_ratio(t, mapping.get_val().get_device_id());
+ }
return remove(t, std::move(mapping)
).handle_error_interruptible(
punch_mappings_iertr::pass_further{},