Use clock_gettime()
parent
7eac7b6d55
commit
20125db181
2
osd.cpp
2
osd.cpp
|
@ -349,7 +349,7 @@ void osd_t::stop_client(int peer_fd)
|
|||
|
||||
void osd_t::exec_op(osd_op_t *cur_op)
|
||||
{
|
||||
gettimeofday(&cur_op->tv_begin, NULL);
|
||||
clock_gettime(CLOCK_REALTIME, &cur_op->tv_begin);
|
||||
if (stopping)
|
||||
{
|
||||
// Throw operation away
|
||||
|
|
6
osd.h
6
osd.h
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -93,8 +93,8 @@ struct osd_primary_op_data_t;
|
|||
|
||||
struct osd_op_t
|
||||
{
|
||||
timeval tv_begin;
|
||||
timeval tv_send;
|
||||
timespec tv_begin;
|
||||
timespec tv_send;
|
||||
int op_type = OSD_OP_IN;
|
||||
int peer_fd;
|
||||
osd_any_op_t req;
|
||||
|
|
|
@ -92,12 +92,12 @@ void osd_t::handle_read(ring_data_t *data, int peer_fd)
|
|||
cl.read_reply_id = 0;
|
||||
cl.read_state = 0;
|
||||
// Measure subop latency
|
||||
timeval tv_end;
|
||||
gettimeofday(&tv_end, NULL);
|
||||
timespec tv_end;
|
||||
clock_gettime(CLOCK_REALTIME, &tv_end);
|
||||
subop_stat_count[request->req.hdr.opcode]++;
|
||||
subop_stat_sum[request->req.hdr.opcode] += (
|
||||
(tv_end.tv_sec - request->tv_begin.tv_sec)*1000000 +
|
||||
tv_end.tv_usec - request->tv_begin.tv_usec
|
||||
(tv_end.tv_nsec - request->tv_begin.tv_nsec)/1000
|
||||
);
|
||||
request->callback(request);
|
||||
}
|
||||
|
@ -192,12 +192,12 @@ void osd_t::handle_reply_hdr(osd_client_t *cl)
|
|||
cl->read_state = 0;
|
||||
cl->sent_ops.erase(req_it);
|
||||
// Measure subop latency
|
||||
timeval tv_end;
|
||||
gettimeofday(&tv_end, NULL);
|
||||
timespec tv_end;
|
||||
clock_gettime(CLOCK_REALTIME, &tv_end);
|
||||
subop_stat_count[op->req.hdr.opcode]++;
|
||||
subop_stat_sum[op->req.hdr.opcode] += (
|
||||
(tv_end.tv_sec - op->tv_begin.tv_sec)*1000000 +
|
||||
tv_end.tv_usec - op->tv_begin.tv_usec
|
||||
(tv_end.tv_nsec - op->tv_begin.tv_nsec)/1000
|
||||
);
|
||||
op->callback(op);
|
||||
}
|
||||
|
|
16
osd_send.cpp
16
osd_send.cpp
|
@ -5,7 +5,7 @@ void osd_t::outbox_push(osd_client_t & cl, osd_op_t *cur_op)
|
|||
assert(cur_op->peer_fd);
|
||||
if (cur_op->op_type == OSD_OP_OUT)
|
||||
{
|
||||
gettimeofday(&cur_op->tv_begin, NULL);
|
||||
clock_gettime(CLOCK_REALTIME, &cur_op->tv_begin);
|
||||
}
|
||||
cl.outbox.push_back(cur_op);
|
||||
if (cl.write_op || cl.outbox.size() > 1 || !try_send(cl))
|
||||
|
@ -36,17 +36,17 @@ bool osd_t::try_send(osd_client_t & cl)
|
|||
cl.write_state = CL_WRITE_REPLY;
|
||||
if (cl.write_op->op_type == OSD_OP_OUT)
|
||||
{
|
||||
gettimeofday(&cl.write_op->tv_send, NULL);
|
||||
clock_gettime(CLOCK_REALTIME, &cl.write_op->tv_send);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Measure execution latency
|
||||
timeval tv_end;
|
||||
gettimeofday(&tv_end, NULL);
|
||||
timespec tv_end;
|
||||
clock_gettime(CLOCK_REALTIME, &tv_end);
|
||||
op_stat_count[cl.write_op->req.hdr.opcode]++;
|
||||
op_stat_sum[cl.write_op->req.hdr.opcode] += (
|
||||
(tv_end.tv_sec - cl.write_op->tv_begin.tv_sec)*1000000 +
|
||||
tv_end.tv_usec - cl.write_op->tv_begin.tv_usec
|
||||
(tv_end.tv_nsec - cl.write_op->tv_begin.tv_nsec)/1000
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -115,12 +115,12 @@ void osd_t::handle_send(ring_data_t *data, int peer_fd)
|
|||
if (cur_op->req.hdr.opcode == OSD_OP_SECONDARY_STABILIZE ||
|
||||
cur_op->req.hdr.opcode == OSD_OP_SECONDARY_WRITE)
|
||||
{
|
||||
timeval tv_end;
|
||||
gettimeofday(&tv_end, NULL);
|
||||
timespec tv_end;
|
||||
clock_gettime(CLOCK_REALTIME, &tv_end);
|
||||
send_stat_count++;
|
||||
send_stat_sum += (
|
||||
(tv_end.tv_sec - cl.write_op->tv_send.tv_sec)*1000000 +
|
||||
tv_end.tv_usec - cl.write_op->tv_send.tv_usec
|
||||
(tv_end.tv_nsec - cl.write_op->tv_send.tv_nsec)/1000
|
||||
);
|
||||
}
|
||||
cl.sent_ops[cl.write_op->req.hdr.id] = cl.write_op;
|
||||
|
|
Loading…
Reference in New Issue