Skip to content

Commit

Permalink
updated variable name
Browse files Browse the repository at this point in the history
  • Loading branch information
Bhaskar Bora committed Feb 1, 2025
1 parent 985bd25 commit 2785b7f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
10 changes: 5 additions & 5 deletions src/llfs/page_recycler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,10 @@ PageRecycler::PageRecycler(batt::TaskScheduler& scheduler, const std::string& na
* flows. This is static metric infrastructure so that any user level code could access it.
*
*/
auto PageRecycler::metrics_export() -> MetricsExported&
auto PageRecycler::metrics_global() -> MetricsGlobal&
{
static MetricsExported& metrics_ = [&]() -> MetricsExported& {
static MetricsExported metrics_;
static MetricsGlobal& metrics_ = [&]() -> MetricsGlobal& {
static MetricsGlobal metrics_;

LLFS_VLOG(1) << "Registering PageRecycler metrics...";
const auto metric_name = [](std::string_view property) {
Expand All @@ -246,7 +246,7 @@ auto PageRecycler::metrics_export() -> MetricsExported&

#define ADD_METRIC_(n) global_metric_registry().add(metric_name(#n), metrics_.n)

ADD_METRIC_(page_id_deletion_reissue);
ADD_METRIC_(page_id_deletion_reissue_count);

#undef ADD_METRIC_

Expand Down Expand Up @@ -347,7 +347,7 @@ bool PageRecycler::is_page_recycling_allowed(const Slice<const PageId>& page_ids
// Look like this is a repost of some old request thus update metric and do not allow recycle.
//
else {
this->metrics_export().page_id_deletion_reissue.fetch_add(1);
this->metrics_global().page_id_deletion_reissue_count.fetch_add(1);
return false;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/llfs/page_recycler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ class PageRecycler
CountMetric<u64> page_drop_error_count{0};
};

struct MetricsExported {
CountMetric<u32> page_id_deletion_reissue{0};
struct MetricsGlobal {
CountMetric<u32> page_id_deletion_reissue_count{0};
};
static MetricsExported& metrics_export();
static MetricsGlobal& metrics_global();

//+++++++++++-+-+--+----- --- -- - - - -

Expand Down
10 changes: 5 additions & 5 deletions src/llfs/volume.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2172,31 +2172,31 @@ TEST_F(VolumeSimTest, DeadPageRefCountVariantSimulation)
std::vector<usize> histogram(10);
const usize div = max_seeds / histogram.size();

llfs::PageRecycler::metrics_export().page_id_deletion_reissue.set(0);
llfs::PageRecycler::metrics_global().page_id_deletion_reissue_count.set(0);

for (u32 current_seed = 0; current_seed < max_seeds; ++current_seed) {
LOG_EVERY_N(INFO, 100) << BATT_INSPECT(current_seed) << BATT_INSPECT(max_seeds);

yield_pre_halt = (yield_pre_halt % 2) ? pick_value1(rng) : pick_value2(rng);
yield_post_halt = (yield_post_halt % 2) ? pick_value1(rng) : pick_value2(rng);

usize last_value = llfs::PageRecycler::metrics_export().page_id_deletion_reissue;
usize last_value = llfs::PageRecycler::metrics_global().page_id_deletion_reissue_count;

ASSERT_NO_FATAL_FAILURE(
this->run_dead_page_recovery_test_variant(current_seed, yield_pre_halt, yield_post_halt));

last_value = llfs::PageRecycler::metrics_export().page_id_deletion_reissue - last_value;
last_value = llfs::PageRecycler::metrics_global().page_id_deletion_reissue_count - last_value;
histogram[current_seed / div] += last_value;
}

LOG(INFO) << "Ran DeadPageRefCountVariant test for " << max_seeds << " iterations..."
<< BATT_INSPECT(llfs::PageRecycler::metrics_export().page_id_deletion_reissue);
<< BATT_INSPECT(llfs::PageRecycler::metrics_global().page_id_deletion_reissue_count);

display_histogram(max_seeds, histogram);

// We need to have atleast one iteration hitting the issue.
//
ASSERT_GE(llfs::PageRecycler::metrics_export().page_id_deletion_reissue, 0);
ASSERT_GE(llfs::PageRecycler::metrics_global().page_id_deletion_reissue_count, 0);
}

//==#==========+==+=+=++=+++++++++++-+-+--+----- --- -- - - - -
Expand Down

0 comments on commit 2785b7f

Please sign in to comment.