Skip to content

Commit

Permalink
page_tracer test case fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Bhaskar Bora committed Jan 8, 2025
1 parent 8f92645 commit 4b68e88
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
31 changes: 24 additions & 7 deletions src/llfs/page_recycler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,23 +72,40 @@ StatusOr<SlotRange> refresh_recycler_info_slot(TypedSlotWriter<PageRecycleEvent>
//
/*static*/ u64 PageRecycler::calculate_log_size(const PageRecyclerOptions& options,
Optional<PageCount> max_buffered_page_count)
{
const usize log_size_raw = calculate_log_size_no_padding(options, max_buffered_page_count);
const usize padding_bytes = 1 * kKiB;

return round_up_to_page_size_multiple(log_size_raw + padding_bytes);
}

//==#==========+==+=+=++=+++++++++++-+-+--+----- --- -- - - - -
//
/*static*/ u64 PageRecycler::calculate_log_size_no_padding(
const PageRecyclerOptions& options, Optional<PageCount> max_buffered_page_count)
{
static const PackedPageRecyclerInfo info = {};

return round_up_to_page_size_multiple(
options.total_page_grant_size() *
(1 + max_buffered_page_count.value_or(
PageRecycler::default_max_buffered_page_count(options))) +
options.recycle_task_target() + packed_sizeof_slot(info) * (options.info_refresh_rate() + 1) +
1 * kKiB);
const usize bytes_per_buffered_page = options.total_page_grant_size();

const usize minimum_required_buffered_pages =
1 + max_buffered_page_count.value_or(PageRecycler::default_max_buffered_page_count(options));

const usize bytes_for_minimum_required_buffered_pages =
bytes_per_buffered_page * minimum_required_buffered_pages;

const usize fixed_size_overhead_bytes =
options.recycle_task_target() + packed_sizeof_slot(info) * (options.info_refresh_rate() + 1);

return bytes_for_minimum_required_buffered_pages + fixed_size_overhead_bytes;
}

//==#==========+==+=+=++=+++++++++++-+-+--+----- --- -- - - - -
//
/*static*/ PageCount PageRecycler::calculate_max_buffered_page_count(
const PageRecyclerOptions& options, u64 log_size)
{
const u64 required_log_size = PageRecycler::calculate_log_size(options, PageCount{0});
const u64 required_log_size = PageRecycler::calculate_log_size_no_padding(options, PageCount{0});
if (log_size <= required_log_size) {
return PageCount{0};
}
Expand Down
3 changes: 3 additions & 0 deletions src/llfs/page_recycler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ class PageRecycler
static u64 calculate_log_size(const PageRecyclerOptions& options,
Optional<PageCount> max_buffered_page_count = None);

static u64 calculate_log_size_no_padding(const PageRecyclerOptions& options,
Optional<PageCount> max_buffered_page_count = None);

static PageCount calculate_max_buffered_page_count(const PageRecyclerOptions& options,
u64 log_size);

Expand Down
2 changes: 1 addition & 1 deletion src/llfs/page_recycler_options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class PageRecyclerOptions
public:
static constexpr usize kDefaultInfoRefreshRate = 4;
static constexpr usize kDefaultMaxRefsPerPage = 1 * kMiB;
static constexpr usize kDefaultBatchSize = 20;
static constexpr usize kDefaultBatchSize = 24;
static constexpr usize kDefaultRefreshFactor = 2;

//+++++++++++-+-+--+----- --- -- - - - -
Expand Down

0 comments on commit 4b68e88

Please sign in to comment.