Skip to content

Commit a2c657d

Browse files
committed
crimson/os/seastore: track shard io stats below transaction manager
Including background transactions. Signed-off-by: Yingxin Cheng <[email protected]>
1 parent 28f59f9 commit a2c657d

File tree

9 files changed

+99
-15
lines changed

9 files changed

+99
-15
lines changed

src/crimson/os/seastore/async_cleaner.cc

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,14 @@ JournalTrimmerImpl::trim_alloc()
598598
{
599599
LOG_PREFIX(JournalTrimmerImpl::trim_alloc);
600600
assert(background_callback->is_ready());
601-
return repeat_eagain([this, FNAME] {
601+
602+
auto& shard_stats = extent_callback->get_shard_stats();
603+
++(shard_stats.trim_alloc_num);
604+
++(shard_stats.pending_bg_num);
605+
606+
return repeat_eagain([this, FNAME, &shard_stats] {
607+
++(shard_stats.repeat_trim_alloc_num);
608+
602609
return extent_callback->with_transaction_intr(
603610
Transaction::src_t::TRIM_ALLOC,
604611
"trim_alloc",
@@ -622,8 +629,11 @@ JournalTrimmerImpl::trim_alloc()
622629
return seastar::now();
623630
});
624631
});
625-
}).safe_then([this, FNAME] {
632+
}).finally([this, FNAME, &shard_stats] {
626633
DEBUG("finish, alloc_tail={}", journal_alloc_tail);
634+
635+
assert(shard_stats.pending_bg_num);
636+
--(shard_stats.pending_bg_num);
627637
});
628638
}
629639

@@ -632,7 +642,14 @@ JournalTrimmerImpl::trim_dirty()
632642
{
633643
LOG_PREFIX(JournalTrimmerImpl::trim_dirty);
634644
assert(background_callback->is_ready());
635-
return repeat_eagain([this, FNAME] {
645+
646+
auto& shard_stats = extent_callback->get_shard_stats();
647+
++(shard_stats.trim_dirty_num);
648+
++(shard_stats.pending_bg_num);
649+
650+
return repeat_eagain([this, FNAME, &shard_stats] {
651+
++(shard_stats.repeat_trim_dirty_num);
652+
636653
return extent_callback->with_transaction_intr(
637654
Transaction::src_t::TRIM_DIRTY,
638655
"trim_dirty",
@@ -662,8 +679,11 @@ JournalTrimmerImpl::trim_dirty()
662679
return extent_callback->submit_transaction_direct(t);
663680
});
664681
});
665-
}).safe_then([this, FNAME] {
682+
}).finally([this, FNAME, &shard_stats] {
666683
DEBUG("finish, dirty_tail={}", journal_dirty_tail);
684+
685+
assert(shard_stats.pending_bg_num);
686+
--(shard_stats.pending_bg_num);
667687
});
668688
}
669689

@@ -1073,6 +1093,14 @@ SegmentCleaner::do_reclaim_space(
10731093
std::size_t &reclaimed,
10741094
std::size_t &runs)
10751095
{
1096+
auto& shard_stats = extent_callback->get_shard_stats();
1097+
if (is_cold) {
1098+
++(shard_stats.cleaner_cold_num);
1099+
} else {
1100+
++(shard_stats.cleaner_main_num);
1101+
}
1102+
++(shard_stats.pending_bg_num);
1103+
10761104
// Extents satisfying any of the following requirements
10771105
// are considered DEAD:
10781106
// 1. can't find the corresponding mapping in both the
@@ -1082,13 +1110,17 @@ SegmentCleaner::do_reclaim_space(
10821110
// tree doesn't match the extent's paddr
10831111
// 3. the extent is physical and doesn't exist in the
10841112
// lba tree, backref tree or backref cache;
1085-
return repeat_eagain([this, &backref_extents,
1113+
return repeat_eagain([this, &backref_extents, &shard_stats,
10861114
&pin_list, &reclaimed, &runs] {
10871115
reclaimed = 0;
10881116
runs++;
1089-
auto src = Transaction::src_t::CLEANER_MAIN;
1117+
transaction_type_t src;
10901118
if (is_cold) {
10911119
src = Transaction::src_t::CLEANER_COLD;
1120+
++(shard_stats.repeat_cleaner_cold_num);
1121+
} else {
1122+
src = Transaction::src_t::CLEANER_MAIN;
1123+
++(shard_stats.repeat_cleaner_main_num);
10921124
}
10931125
return extent_callback->with_transaction_intr(
10941126
src,
@@ -1167,6 +1199,9 @@ SegmentCleaner::do_reclaim_space(
11671199
return extent_callback->submit_transaction_direct(t);
11681200
});
11691201
});
1202+
}).finally([&shard_stats] {
1203+
assert(shard_stats.pending_bg_num);
1204+
--(shard_stats.pending_bg_num);
11701205
});
11711206
}
11721207

@@ -1202,6 +1237,7 @@ SegmentCleaner::clean_space_ret SegmentCleaner::clean_space()
12021237
std::pair<std::vector<CachedExtentRef>, backref_pin_list_t>(),
12031238
[this](auto &weak_read_ret) {
12041239
return repeat_eagain([this, &weak_read_ret] {
1240+
// Note: not tracked by shard_stats_t intentionally.
12051241
return extent_callback->with_transaction_intr(
12061242
Transaction::src_t::READ,
12071243
"retrieve_from_backref_tree",

src/crimson/os/seastore/async_cleaner.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,8 @@ class ExtentCallbackInterface {
277277

278278
virtual ~ExtentCallbackInterface() = default;
279279

280+
virtual shard_stats_t& get_shard_stats() = 0;
281+
280282
/// Creates empty transaction
281283
/// weak transaction should be type READ
282284
virtual TransactionRef create_transaction(

src/crimson/os/seastore/seastore.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2469,7 +2469,7 @@ void SeaStore::Shard::init_managers()
24692469
shard_stats = {};
24702470

24712471
transaction_manager = make_transaction_manager(
2472-
device, secondaries, is_test);
2472+
device, secondaries, shard_stats, is_test);
24732473
collection_manager = std::make_unique<collection_manager::FlatCollectionManager>(
24742474
*transaction_manager);
24752475
onode_manager = std::make_unique<crimson::os::seastore::onode::FLTreeOnodeManager>(

src/crimson/os/seastore/seastore_types.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2383,6 +2383,17 @@ struct shard_stats_t {
23832383
uint64_t repeat_read_num = 0;
23842384
uint64_t pending_read_num = 0;
23852385

2386+
// transaction_type_t::TRIM_DIRTY~CLEANER_COLD
2387+
uint64_t pending_bg_num = 0;
2388+
uint64_t trim_alloc_num = 0;
2389+
uint64_t repeat_trim_alloc_num = 0;
2390+
uint64_t trim_dirty_num = 0;
2391+
uint64_t repeat_trim_dirty_num = 0;
2392+
uint64_t cleaner_main_num = 0;
2393+
uint64_t repeat_cleaner_main_num = 0;
2394+
uint64_t cleaner_cold_num = 0;
2395+
uint64_t repeat_cleaner_cold_num = 0;
2396+
23862397
uint64_t flush_num = 0;
23872398
uint64_t pending_flush_num = 0;
23882399
};

src/crimson/os/seastore/transaction_manager.cc

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,17 @@ TransactionManager::TransactionManager(
2929
CacheRef _cache,
3030
LBAManagerRef _lba_manager,
3131
ExtentPlacementManagerRef &&_epm,
32-
BackrefManagerRef&& _backref_manager)
32+
BackrefManagerRef&& _backref_manager,
33+
shard_stats_t& _shard_stats)
3334
: cache(std::move(_cache)),
3435
lba_manager(std::move(_lba_manager)),
3536
journal(std::move(_journal)),
3637
epm(std::move(_epm)),
3738
backref_manager(std::move(_backref_manager)),
3839
full_extent_integrity_check(
3940
crimson::common::get_conf<bool>(
40-
"seastore_full_integrity_check"))
41+
"seastore_full_integrity_check")),
42+
shard_stats(_shard_stats)
4143
{
4244
epm->set_extent_callback(this);
4345
journal->set_write_pipeline(&write_pipeline);
@@ -55,6 +57,12 @@ TransactionManager::mkfs_ertr::future<> TransactionManager::mkfs()
5557
journal->get_trimmer().set_journal_head(start_seq);
5658
return epm->open_for_write();
5759
}).safe_then([this, FNAME]() {
60+
++(shard_stats.io_num);
61+
++(shard_stats.pending_io_num);
62+
// For submit_transaction_direct()
63+
++(shard_stats.processing_inlock_io_num);
64+
++(shard_stats.repeat_io_num);
65+
5866
return with_transaction_intr(
5967
Transaction::src_t::MUTATE,
6068
"mkfs_tm",
@@ -76,7 +84,13 @@ TransactionManager::mkfs_ertr::future<> TransactionManager::mkfs()
7684
return mkfs_ertr::now();
7785
}),
7886
mkfs_ertr::pass_further{}
79-
);
87+
).finally([this] {
88+
assert(shard_stats.pending_io_num);
89+
--(shard_stats.pending_io_num);
90+
// XXX: it's wrong to assume no failure,
91+
// but failure leads to fatal error
92+
--(shard_stats.processing_postlock_io_num);
93+
});
8094
}).safe_then([this] {
8195
return close();
8296
}).safe_then([FNAME] {
@@ -419,6 +433,10 @@ TransactionManager::do_submit_transaction(
419433
journal->get_trimmer().get_dirty_tail());
420434

421435
tref.get_handle().maybe_release_collection_lock();
436+
if (tref.get_src() == Transaction::src_t::MUTATE) {
437+
--(shard_stats.processing_inlock_io_num);
438+
++(shard_stats.processing_postlock_io_num);
439+
}
422440

423441
SUBTRACET(seastore_t, "submitting record", tref);
424442
return journal->submit_record(std::move(record), tref.get_handle()
@@ -734,6 +752,7 @@ TransactionManager::~TransactionManager() {}
734752
TransactionManagerRef make_transaction_manager(
735753
Device *primary_device,
736754
const std::vector<Device*> &secondary_devices,
755+
shard_stats_t& shard_stats,
737756
bool is_test)
738757
{
739758
auto epm = std::make_unique<ExtentPlacementManager>();
@@ -873,7 +892,8 @@ TransactionManagerRef make_transaction_manager(
873892
std::move(cache),
874893
std::move(lba_manager),
875894
std::move(epm),
876-
std::move(backref_manager));
895+
std::move(backref_manager),
896+
shard_stats);
877897
}
878898

879899
}

src/crimson/os/seastore/transaction_manager.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ class TransactionManager : public ExtentCallbackInterface {
6565
CacheRef cache,
6666
LBAManagerRef lba_manager,
6767
ExtentPlacementManagerRef &&epm,
68-
BackrefManagerRef&& backref_manager);
68+
BackrefManagerRef&& backref_manager,
69+
shard_stats_t& shard_stats);
6970

7071
/// Writes initial metadata to disk
7172
using mkfs_ertr = base_ertr;
@@ -662,6 +663,10 @@ class TransactionManager : public ExtentCallbackInterface {
662663
* ExtentCallbackInterface
663664
*/
664665

666+
shard_stats_t& get_shard_stats() {
667+
return shard_stats;
668+
}
669+
665670
/// weak transaction should be type READ
666671
TransactionRef create_transaction(
667672
Transaction::src_t src,
@@ -834,6 +839,8 @@ class TransactionManager : public ExtentCallbackInterface {
834839

835840
bool full_extent_integrity_check = true;
836841

842+
shard_stats_t& shard_stats;
843+
837844
rewrite_extent_ret rewrite_logical_extent(
838845
Transaction& t,
839846
LogicalCachedExtentRef extent);
@@ -1010,5 +1017,6 @@ using TransactionManagerRef = std::unique_ptr<TransactionManager>;
10101017
TransactionManagerRef make_transaction_manager(
10111018
Device *primary_device,
10121019
const std::vector<Device*> &secondary_devices,
1020+
shard_stats_t& shard_stats,
10131021
bool is_test);
10141022
}

src/crimson/tools/store_nbd/tm_driver.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,13 @@ seastar::future<bufferlist> TMDriver::read(
139139

140140
void TMDriver::init()
141141
{
142+
shard_stats = {};
143+
142144
std::vector<Device*> sec_devices;
143145
#ifndef NDEBUG
144-
tm = make_transaction_manager(device.get(), sec_devices, true);
146+
tm = make_transaction_manager(device.get(), sec_devices, shard_stats, true);
145147
#else
146-
tm = make_transaction_manager(device.get(), sec_devices, false);
148+
tm = make_transaction_manager(device.get(), sec_devices, shard_stats, false);
147149
#endif
148150
}
149151

src/crimson/tools/store_nbd/tm_driver.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ class TMDriver final : public BlockDriver {
4141
using TransactionManagerRef = crimson::os::seastore::TransactionManagerRef;
4242
TransactionManagerRef tm;
4343

44+
using shard_stats_t = crimson::os::seastore::shard_stats_t;
45+
shard_stats_t shard_stats;
46+
4447
seastar::future<> mkfs();
4548
void init();
4649
void clear();

src/test/crimson/seastore/transaction_manager_test_state.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ class TMTestState : public EphemeralTestState {
273273
Cache* cache;
274274
ExtentPlacementManager *epm;
275275
uint64_t seq = 0;
276+
shard_stats_t shard_stats;
276277

277278
TMTestState() : EphemeralTestState(1, 0) {}
278279

@@ -292,7 +293,8 @@ class TMTestState : public EphemeralTestState {
292293
"seastore_full_integrity_check", "false");
293294
}
294295
#endif
295-
tm = make_transaction_manager(p_dev, sec_devices, true);
296+
shard_stats = {};
297+
tm = make_transaction_manager(p_dev, sec_devices, shard_stats, true);
296298
epm = tm->get_epm();
297299
lba_manager = tm->get_lba_manager();
298300
cache = tm->get_cache();

0 commit comments

Comments
 (0)