Skip to content

Commit

Permalink
added a histogram plot for the bug hits
Browse files Browse the repository at this point in the history
  • Loading branch information
Bhaskar Bora committed Dec 18, 2024
1 parent f6d4360 commit 315d8ba
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/llfs/committable_page_cache_job.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,7 @@ Status commit(std::unique_ptr<PageCacheJob> job, const JobCommitParams& params,
Status commit(CommittablePageCacheJob committable_job, const JobCommitParams& params, u64 callers,
slot_offset_type prev_caller_slot, batt::Watch<slot_offset_type>* durable_caller_slot)
{
auto stat = committable_job.commit_impl(params, callers, prev_caller_slot, durable_caller_slot);
return stat;
return committable_job.commit_impl(params, callers, prev_caller_slot, durable_caller_slot);
}

//==#==========+==+=+=++=+++++++++++-+-+--+----- --- -- - - - -
Expand Down
27 changes: 27 additions & 0 deletions src/llfs/volume.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2137,6 +2137,22 @@ TEST_F(VolumeSimTest, DeadPageRefCountSimulation)
}
}

//==#==========+==+=+=++=+++++++++++-+-+--+----- --- -- - - - -
//
void display_histogram(u32 max_seeds, const std::vector<usize>& histogram)
{
std::string hist_str;
usize current_seed = 0;
const usize div = max_seeds / histogram.size();

for (const auto entry : histogram) {
hist_str += std::to_string(current_seed) + ":" + std::to_string(entry) + " ";
current_seed += div;
}

LOG(INFO) << "Histogram: " << hist_str;
}

//==#==========+==+=+=++=+++++++++++-+-+--+----- --- -- - - - -
//
TEST_F(VolumeSimTest, DeadPageRefCountVariantSimulation)
Expand All @@ -2153,20 +2169,31 @@ TEST_F(VolumeSimTest, DeadPageRefCountVariantSimulation)
std::uniform_int_distribution<usize> pick_value1{ranges[0].first, ranges[0].second};
std::uniform_int_distribution<usize> pick_value2{ranges[1].first, ranges[1].second};
usize yield_pre_halt = 0, yield_post_halt = 0;
std::vector<usize> histogram(10);
const usize div = max_seeds / histogram.size();

llfs::PageRecycler::metrics_export().page_id_deletion_reissue.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;

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;
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);

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);
Expand Down

0 comments on commit 315d8ba

Please sign in to comment.