Skip to content

Commit 7c30042

Browse files
committed
crimson/osd/pg: record client requests' metrics in DynamicPerfStats
Signed-off-by: Xuehan Xu <[email protected]>
1 parent 89d7934 commit 7c30042

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

src/crimson/osd/ops_executer.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@ class OpsExecuter {
169169
IOInterruptCondition, osd_op_errorator>;
170170

171171
object_stat_sum_t delta_stats;
172+
173+
size_t get_bytes_written() {
174+
return txn.get_num_bytes();
175+
}
172176
private:
173177
// with_effect can be used to schedule operations to be performed
174178
// at commit time. effects will be discarded if the operation does

src/crimson/osd/osd_operations/client_request.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ ClientRequest::ClientRequest(
6363
: shard_services(&_shard_services),
6464
l_conn(std::move(conn)),
6565
m(std::move(m)),
66+
begin_time(std::chrono::steady_clock::now()),
6667
instance_handle(new instance_handle_t)
6768
{}
6869

@@ -525,6 +526,7 @@ ClientRequest::do_process(
525526
co_return;
526527
}
527528

529+
size_t inb = 0, outb = 0;
528530
{
529531
auto all_completed = interruptor::now();
530532
if (ret) {
@@ -540,6 +542,7 @@ ClientRequest::do_process(
540542
// simply return the error below, leaving all_completed alone
541543
} else {
542544
auto submitted = interruptor::now();
545+
inb = ox.get_bytes_written();
543546
std::tie(submitted, all_completed) = co_await pg->submit_executer(
544547
std::move(ox), m->ops);
545548
co_await std::move(submitted);
@@ -573,9 +576,15 @@ ClientRequest::do_process(
573576
reply->set_result(osdop.rval);
574577
break;
575578
}
579+
outb += osdop.outdata.length();
576580
}
577581
}
578582

583+
pg->add_client_request_lat(
584+
*this,
585+
inb,
586+
outb,
587+
utime_t{std::chrono::steady_clock::now() - begin_time});
579588
reply->set_enoent_reply_versions(
580589
pg->peering_state.get_info().last_update,
581590
pg->peering_state.get_info().last_user_version);

src/crimson/osd/osd_operations/client_request.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,25 @@ class ClientRequest final : public PhasedOperationT<ClientRequest>,
4141
OpInfo op_info;
4242
seastar::promise<> on_complete;
4343
unsigned instance_id = 0;
44+
std::chrono::time_point<std::chrono::steady_clock> begin_time;
4445

4546
public:
4647
epoch_t get_epoch_sent_at() const {
4748
return m->get_map_epoch();
4849
}
4950

51+
bool may_write() const { return op_info.may_write(); }
52+
bool may_cache() const { return op_info.may_cache(); }
53+
bool may_read() const { return op_info.may_read(); }
54+
template <typename T>
55+
T* get_req() const {
56+
static_assert(std::is_same_v<T, MOSDOp>);
57+
return m.get();
58+
}
59+
const crimson::net::ConnectionRef &get_connection() const {
60+
return l_conn;
61+
}
62+
5063
/**
5164
* instance_handle_t
5265
*

src/crimson/osd/pg.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "crimson/osd/object_context.h"
2222
#include "osd/PeeringState.h"
2323
#include "osd/SnapMapper.h"
24+
#include "osd/DynamicPerfStats.h"
2425

2526
#include "crimson/common/interruptible_future.h"
2627
#include "crimson/common/log.h"
@@ -765,8 +766,16 @@ class PG : public boost::intrusive_ref_counter<
765766

766767
private:
767768
std::optional<pg_stat_t> pg_stats;
769+
DynamicPerfStats dp_stats;
768770

769771
public:
772+
void add_client_request_lat(
773+
const ClientRequest& req,
774+
size_t inb,
775+
size_t outb,
776+
const utime_t &lat) {
777+
dp_stats.add(pg_whoami.osd, get_info(), req, inb, outb, lat);
778+
}
770779
OSDriver &get_osdriver() final {
771780
return osdriver;
772781
}

0 commit comments

Comments
 (0)