From: Yingxin Cheng Date: Mon, 1 Apr 2019 14:05:42 +0000 (+0800) Subject: crimson/net: utilize lowres_system_clock with better performance X-Git-Tag: v15.1.0~3027^2~3 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=feddee4e5c5889a387a04d12dd61bd66b22085c9;p=ceph-ci.git crimson/net: utilize lowres_system_clock with better performance Signed-off-by: Yingxin Cheng --- diff --git a/src/crimson/net/ProtocolV2.cc b/src/crimson/net/ProtocolV2.cc index 6ac9caf3cc7..da096a68664 100644 --- a/src/crimson/net/ProtocolV2.cc +++ b/src/crimson/net/ProtocolV2.cc @@ -3,6 +3,8 @@ #include "ProtocolV2.h" +#include + #include "include/msgr.h" #include "include/random.h" @@ -1387,7 +1389,7 @@ seastar::future<> ProtocolV2::read_message(utime_t throttle_stamp) { return read_frame_payload() .then([this, throttle_stamp] { - utime_t recv_stamp = ceph_clock_now(); + utime_t recv_stamp{seastar::lowres_system_clock::now()}; // we need to get the size before std::moving segments data const size_t cur_msg_size = get_current_msg_size(); @@ -1429,7 +1431,7 @@ seastar::future<> ProtocolV2::read_message(utime_t throttle_stamp) message->set_throttle_stamp(throttle_stamp); message->set_recv_stamp(recv_stamp); - message->set_recv_complete_stamp(ceph_clock_now()); + message->set_recv_complete_stamp(utime_t{seastar::lowres_system_clock::now()}); // check received seq#. if it is old, drop the message. // note that incoming messages may skip ahead. this is convenient for the @@ -1512,7 +1514,7 @@ void ProtocolV2::execute_ready() return conn.policy.throttler_bytes->get(cur_msg_size); }).then([this] { // TODO: throttle_dispatch_queue() logic - utime_t throttle_stamp = ceph_clock_now(); + utime_t throttle_stamp{seastar::lowres_system_clock::now()}; return read_message(throttle_stamp); }); } @@ -1531,7 +1533,7 @@ void ProtocolV2::execute_ready() last_keepalive_ack_to_send = keepalive_frame.timestamp(); logger().debug("{} got KEEPALIVE2 {}", conn, last_keepalive_ack_to_send); - conn.last_keepalive = ceph_clock_now(); + conn.last_keepalive = utime_t{seastar::lowres_system_clock::now()}; notify_keepalive_ack(); }); case Tag::KEEPALIVE2_ACK: diff --git a/src/include/utime.h b/src/include/utime.h index bc9f6429a12..3d852b4587a 100644 --- a/src/include/utime.h +++ b/src/include/utime.h @@ -20,6 +20,10 @@ #include #include +#if defined(WITH_SEASTAR) +#include +#endif + #include "include/types.h" #include "include/timegm.h" #include "common/strtol.h" @@ -77,6 +81,15 @@ public: explicit utime_t(const std::chrono::time_point& t) : utime_t(Clock::to_timespec(t)) {} // forward to timespec ctor +#if defined(WITH_SEASTAR) + explicit utime_t(const seastar::lowres_system_clock::time_point& t) { + tv.tv_sec = std::time_t(std::chrono::duration_cast( + t.time_since_epoch()).count()); + tv.tv_nsec = std::chrono::duration_cast( + t.time_since_epoch() % std::chrono::seconds(1)).count(); + } +#endif + utime_t(const struct timeval &v) { set_from_timeval(&v); }