Skip to content

Commit b9c2fb7

Browse files
committed
crimson/os/seastore: cleanup periodical reporting
Consolidate time into a single place per SeaStore::Shard. Signed-off-by: Yingxin Cheng <[email protected]>
1 parent 800b352 commit b9c2fb7

File tree

5 files changed

+37
-34
lines changed

5 files changed

+37
-34
lines changed

src/crimson/os/seastore/extent_placement_manager.cc

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,8 @@ void ExtentPlacementManager::set_primary_device(Device *device)
277277
device_stats_t
278278
ExtentPlacementManager::get_device_stats(
279279
const writer_stats_t &journal_stats,
280-
bool report_detail) const
280+
bool report_detail,
281+
double seconds) const
281282
{
282283
LOG_PREFIX(ExtentPlacementManager::get_device_stats);
283284

@@ -345,16 +346,7 @@ ExtentPlacementManager::get_device_stats(
345346
cold_stats.add(cold_writer_stats.back());
346347
}
347348

348-
auto now = seastar::lowres_clock::now();
349-
if (last_tp == seastar::lowres_clock::time_point::min()) {
350-
last_tp = now;
351-
return {};
352-
}
353-
std::chrono::duration<double> duration_d = now - last_tp;
354-
double seconds = duration_d.count();
355-
last_tp = now;
356-
357-
if (report_detail) {
349+
if (report_detail && seconds != 0) {
358350
std::ostringstream oss;
359351
auto report_writer_stats = [seconds, &oss](
360352
const char* name,

src/crimson/os/seastore/extent_placement_manager.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,8 @@ class ExtentPlacementManager {
303303

304304
device_stats_t get_device_stats(
305305
const writer_stats_t &journal_stats,
306-
bool report_detail) const;
306+
bool report_detail,
307+
double seconds) const;
307308

308309
using mount_ertr = crimson::errorator<
309310
crimson::ct_error::input_output_error>;
@@ -1098,9 +1099,6 @@ class ExtentPlacementManager {
10981099
SegmentSeqAllocatorRef ool_segment_seq_allocator;
10991100
extent_len_t max_data_allocation_size = 0;
11001101

1101-
mutable seastar::lowres_clock::time_point last_tp =
1102-
seastar::lowres_clock::time_point::min();
1103-
11041102
friend class ::transaction_manager_test_t;
11051103
};
11061104

src/crimson/os/seastore/seastore.cc

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -592,14 +592,16 @@ seastar::future<> SeaStore::report_stats()
592592
shard_io_stats.resize(seastar::smp::count);
593593
return shard_stores.invoke_on_all([this](const Shard &local_store) {
594594
bool report_detail = false;
595+
double seconds = 0;
595596
if (seastar::this_shard_id() == 0) {
596597
// avoid too verbose logs, only report detail in a particular shard
597598
report_detail = true;
599+
seconds = local_store.reset_report_interval();
598600
}
599601
shard_device_stats[seastar::this_shard_id()] =
600-
local_store.get_device_stats(report_detail);
602+
local_store.get_device_stats(report_detail, seconds);
601603
shard_io_stats[seastar::this_shard_id()] =
602-
local_store.get_io_stats(report_detail);
604+
local_store.get_io_stats(report_detail, seconds);
603605
}).then([this] {
604606
LOG_PREFIX(SeaStore);
605607
auto now = seastar::lowres_clock::now();
@@ -2530,27 +2532,33 @@ void SeaStore::Shard::init_managers()
25302532
*transaction_manager);
25312533
}
25322534

2533-
device_stats_t SeaStore::Shard::get_device_stats(bool report_detail) const
2534-
{
2535-
return transaction_manager->get_device_stats(report_detail);
2536-
}
2537-
2538-
shard_stats_t SeaStore::Shard::get_io_stats(bool report_detail) const
2535+
double SeaStore::Shard::reset_report_interval() const
25392536
{
2537+
double seconds;
25402538
auto now = seastar::lowres_clock::now();
25412539
if (last_tp == seastar::lowres_clock::time_point::min()) {
2542-
last_tp = now;
2543-
last_shard_stats = shard_stats;
2544-
return {};
2540+
seconds = 0;
2541+
} else {
2542+
std::chrono::duration<double> duration_d = now - last_tp;
2543+
seconds = duration_d.count();
25452544
}
2546-
std::chrono::duration<double> duration_d = now - last_tp;
2547-
double seconds = duration_d.count();
25482545
last_tp = now;
2546+
return seconds;
2547+
}
25492548

2549+
device_stats_t SeaStore::Shard::get_device_stats(
2550+
bool report_detail, double seconds) const
2551+
{
2552+
return transaction_manager->get_device_stats(report_detail, seconds);
2553+
}
2554+
2555+
shard_stats_t SeaStore::Shard::get_io_stats(
2556+
bool report_detail, double seconds) const
2557+
{
25502558
shard_stats_t ret = shard_stats;
25512559
ret.minus(last_shard_stats);
2552-
last_shard_stats = shard_stats;
2553-
if (report_detail) {
2560+
2561+
if (report_detail && seconds != 0) {
25542562
LOG_PREFIX(SeaStore::get_io_stats);
25552563
auto calc_conflicts = [](uint64_t ios, uint64_t repeats) {
25562564
return (double)(repeats-ios)/ios;
@@ -2586,6 +2594,8 @@ shard_stats_t SeaStore::Shard::get_io_stats(bool report_detail) const
25862594
ret.pending_bg_num,
25872595
ret.pending_flush_num);
25882596
}
2597+
2598+
last_shard_stats = shard_stats;
25892599
return ret;
25902600
}
25912601

src/crimson/os/seastore/seastore.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,11 @@ class SeaStore final : public FuturizedStore {
204204

205205
void init_managers();
206206

207-
device_stats_t get_device_stats(bool report_detail) const;
207+
double reset_report_interval() const;
208208

209-
shard_stats_t get_io_stats(bool report_detail) const;
209+
device_stats_t get_device_stats(bool report_detail, double seconds) const;
210+
211+
shard_stats_t get_io_stats(bool report_detail, double seconds) const;
210212

211213
private:
212214
struct internal_context_t {

src/crimson/os/seastore/transaction_manager.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,10 @@ class TransactionManager : public ExtentCallbackInterface {
8080
using close_ertr = base_ertr;
8181
close_ertr::future<> close();
8282

83-
device_stats_t get_device_stats(bool report_detail) const {
83+
device_stats_t get_device_stats(
84+
bool report_detail, double seconds) const {
8485
writer_stats_t journal_stats = journal->get_writer_stats();
85-
return epm->get_device_stats(journal_stats, report_detail);
86+
return epm->get_device_stats(journal_stats, report_detail, seconds);
8687
}
8788

8889
/// Resets transaction

0 commit comments

Comments
 (0)