Skip to content

Commit

Permalink
Measure connect latency in microseconds instead of milliseconds
Browse files Browse the repository at this point in the history
Summary:
Just to make sure I don't break anything: zbgsed `conn_lat_ms` https://fburl.com/code/tb1z7zvy and I don't see anything.

NOTE: I'm going to make post in traffeed.

This will later be used to define new latency metrics more accurately where latency metric will be everything minus connection creation time.

While this change might looks huge it's just simple move from millis to micros

Reviewed By: kwaugh

Differential Revision: D59735786

fbshipit-source-id: 2d2ed585c64ed848e39850ee48431d19dbaf593d
  • Loading branch information
Giorgi Papakerashvili authored and facebook-github-bot committed Jul 17, 2024
1 parent 1e3d9ae commit 89fb0b3
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
6 changes: 3 additions & 3 deletions proxygen/lib/http/HQConnector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ using namespace fizz::client;

namespace proxygen {

std::chrono::milliseconds HQConnector::timeElapsed() {
std::chrono::microseconds HQConnector::timeElapsed() {
if (timePointInitialized(connectStart_)) {
return millisecondsSince(connectStart_);
return microsecondsSince(connectStart_);
}
return std::chrono::milliseconds(0);
return std::chrono::microseconds(0);
}

void HQConnector::reset() {
Expand Down
2 changes: 1 addition & 1 deletion proxygen/lib/http/HQConnector.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class HQConnector : public HQSession::ConnectCallback {
std::shared_ptr<quic::QuicTransportStatsCallback>
quicTransportStatsCallback = nullptr);

std::chrono::milliseconds timeElapsed();
std::chrono::microseconds timeElapsed();

bool isBusy() const {
return (session_ != nullptr);
Expand Down
6 changes: 3 additions & 3 deletions proxygen/lib/http/HTTPConnector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ void HTTPConnector::connectSSL(EventBase* eventBase,
this, connectAddr, timeoutMs.count(), socketOptions, bindAddr);
}

std::chrono::milliseconds HTTPConnector::timeElapsed() {
std::chrono::microseconds HTTPConnector::timeElapsed() {
if (timePointInitialized(connectStart_)) {
return millisecondsSince(connectStart_);
return microsecondsSince(connectStart_);
}
return std::chrono::milliseconds(0);
return std::chrono::microseconds(0);
}

// Callback interface
Expand Down
2 changes: 1 addition & 1 deletion proxygen/lib/http/HTTPConnector.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class HTTPConnector : protected folly::AsyncSocket::ConnectCallback {
* @returns the number of milliseconds since connecting began, or
* zero if connecting hasn't started yet.
*/
std::chrono::milliseconds timeElapsed();
std::chrono::microseconds timeElapsed();

/**
* @returns true iff this connector is busy setting up a connection. If
Expand Down
6 changes: 6 additions & 0 deletions proxygen/lib/utils/Time.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ inline std::chrono::milliseconds millisecondsSince(
return millisecondsBetween(getCurrentTime<ClockType>(), t);
}

template <typename ClockType = SteadyClock>
inline std::chrono::microseconds microsecondsSince(
std::chrono::time_point<ClockType> t) {
return microsecondsBetween(getCurrentTime<ClockType>(), t);
}

template <typename ClockType = SteadyClock>
inline std::chrono::seconds secondsSince(std::chrono::time_point<ClockType> t) {
return secondsBetween(getCurrentTime<ClockType>(), t);
Expand Down

0 comments on commit 89fb0b3

Please sign in to comment.