]>
git.proxmox.com Git - ceph.git/blob - ceph/src/tools/crimson/perf_staged_fltree.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:nil -*-
2 // vim: ts=8 sw=2 smarttab
4 #include <boost/program_options.hpp>
6 #include <seastar/core/app-template.hh>
7 #include <seastar/core/thread.hh>
9 #include "crimson/common/config_proxy.h"
10 #include "crimson/common/log.h"
11 #include "crimson/common/perf_counters_collection.h"
12 #include "crimson/os/seastore/onode_manager/staged-fltree/tree_utils.h"
13 #include "crimson/os/seastore/onode_manager/staged-fltree/node_extent_manager.h"
15 #include "test/crimson/seastore/onode_tree/test_value.h"
16 #include "test/crimson/seastore/transaction_manager_test_state.h"
18 using namespace crimson::os::seastore::onode
;
19 namespace bpo
= boost::program_options
;
21 seastar::logger
& logger() {
22 return crimson::get_logger(ceph_subsys_test
);
26 class PerfTree
: public TMTestState
{
28 PerfTree(bool is_dummy
) : is_dummy
{is_dummy
} {}
30 seastar::future
<> run(KVPool
<test_item_t
>& kvs
, double erase_ratio
) {
31 return tm_setup().then([this, &kvs
, erase_ratio
] {
32 return seastar::async([this, &kvs
, erase_ratio
] {
33 auto tree
= std::make_unique
<TreeBuilder
<TRACK
, ExtendedValue
>>(kvs
,
34 (is_dummy
? NodeExtentManager::create_dummy(true)
35 : NodeExtentManager::create_seastore(*tm
)));
37 auto t
= create_mutate_transaction();
38 with_trans_intr(*t
, [&](auto &tr
){
39 return tree
->bootstrap(tr
);
41 submit_transaction(std::move(t
));
44 auto t
= create_mutate_transaction();
45 with_trans_intr(*t
, [&](auto &tr
){
46 return tree
->insert(tr
);
48 auto start_time
= mono_clock::now();
49 submit_transaction(std::move(t
));
50 std::chrono::duration
<double> duration
= mono_clock::now() - start_time
;
51 logger().warn("submit_transaction() done! {}s", duration
.count());
54 // Note: create_weak_transaction() can also work, but too slow.
55 auto t
= create_read_transaction();
56 with_trans_intr(*t
, [&](auto &tr
){
57 return tree
->get_stats(tr
);
60 with_trans_intr(*t
, [&](auto &tr
){
61 return tree
->validate(tr
);
65 auto t
= create_mutate_transaction();
66 with_trans_intr(*t
, [&](auto &tr
){
67 return tree
->erase(tr
, kvs
.size() * erase_ratio
);
69 submit_transaction(std::move(t
));
72 auto t
= create_read_transaction();
73 with_trans_intr(*t
, [&](auto &tr
){
74 return tree
->get_stats(tr
);
77 with_trans_intr(*t
, [&](auto &tr
){
78 return tree
->validate(tr
);
93 seastar::future
<> run(const bpo::variables_map
& config
) {
94 return seastar::async([&config
] {
95 auto backend
= config
["backend"].as
<std::string
>();
97 if (backend
== "dummy") {
99 } else if (backend
== "seastore") {
102 ceph_abort(false && "invalid backend");
104 auto ns_sizes
= config
["ns-sizes"].as
<std::vector
<size_t>>();
105 auto oid_sizes
= config
["oid-sizes"].as
<std::vector
<size_t>>();
106 auto onode_sizes
= config
["onode-sizes"].as
<std::vector
<size_t>>();
107 auto range2
= config
["range2"].as
<std::vector
<int>>();
108 ceph_assert(range2
.size() == 2);
109 auto range1
= config
["range1"].as
<std::vector
<unsigned>>();
110 ceph_assert(range1
.size() == 2);
111 auto range0
= config
["range0"].as
<std::vector
<unsigned>>();
112 ceph_assert(range0
.size() == 2);
113 auto erase_ratio
= config
["erase-ratio"].as
<double>();
114 ceph_assert(erase_ratio
>= 0);
115 ceph_assert(erase_ratio
<= 1);
117 using crimson::common::sharded_conf
;
118 sharded_conf().start(EntityName
{}, std::string_view
{"ceph"}).get();
119 seastar::engine().at_exit([] {
120 return sharded_conf().stop();
123 using crimson::common::sharded_perf_coll
;
124 sharded_perf_coll().start().get();
125 seastar::engine().at_exit([] {
126 return sharded_perf_coll().stop();
129 auto kvs
= KVPool
<test_item_t
>::create_raw_range(
130 ns_sizes
, oid_sizes
, onode_sizes
,
131 {range2
[0], range2
[1]},
132 {range1
[0], range1
[1]},
133 {range0
[0], range0
[1]});
134 PerfTree
<TRACK
> perf
{is_dummy
};
135 perf
.run(kvs
, erase_ratio
).get0();
140 int main(int argc
, char** argv
)
142 seastar::app_template app
;
144 ("backend", bpo::value
<std::string
>()->default_value("dummy"),
145 "tree backend: dummy, seastore")
146 ("tracked", bpo::value
<bool>()->default_value(false),
147 "track inserted cursors")
148 ("ns-sizes", bpo::value
<std::vector
<size_t>>()->default_value(
149 {8, 11, 64, 128, 255, 256}),
150 "sizes of ns strings")
151 ("oid-sizes", bpo::value
<std::vector
<size_t>>()->default_value(
152 {8, 13, 64, 512, 2035, 2048}),
153 "sizes of oid strings")
154 ("onode-sizes", bpo::value
<std::vector
<size_t>>()->default_value(
155 {8, 16, 128, 576, 992, 1200}),
157 ("range2", bpo::value
<std::vector
<int>>()->default_value(
159 "range of shard-pool-crush [a, b)")
160 ("range1", bpo::value
<std::vector
<unsigned>>()->default_value(
162 "range of ns-oid strings [a, b)")
163 ("range0", bpo::value
<std::vector
<unsigned>>()->default_value(
165 "range of snap-gen [a, b)")
166 ("erase-ratio", bpo::value
<double>()->default_value(
168 "erase-ratio of all the inserted onodes");
169 return app
.run(argc
, argv
, [&app
] {
170 auto&& config
= app
.configuration();
171 auto tracked
= config
["tracked"].as
<bool>();
173 return run
<true>(config
);
175 return run
<false>(config
);