Skip to content

Commit 7257c9f

Browse files
Gideon Glasskakaiu
authored andcommitted
Add server-side metrics for TLS handshakes on side threads and on the main thread.
Rename existing (just-added) metrics to indicate that they are client-side.
1 parent 3f8d880 commit 7257c9f

File tree

3 files changed

+43
-17
lines changed

3 files changed

+43
-17
lines changed

flow/Net2.actor.cpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -418,8 +418,10 @@ class Net2 final : public INetwork, public INetworkConnections {
418418
DoubleMetricHandle countLaunchTime;
419419
DoubleMetricHandle countReactTime;
420420
BoolMetricHandle awakeMetric;
421-
Int64MetricHandle countTLSHandshakesOnSideThreads;
422-
Int64MetricHandle countTLSHandshakesOnMainThread;
421+
Int64MetricHandle countClientTLSHandshakesOnSideThreads;
422+
Int64MetricHandle countClientTLSHandshakesOnMainThread;
423+
Int64MetricHandle countServerTLSHandshakesOnSideThreads;
424+
Int64MetricHandle countServerTLSHandshakesOnMainThread;
423425

424426
EventMetricHandle<SlowTask> slowTaskMetric;
425427

@@ -1062,8 +1064,11 @@ class SSLConnection final : public IConnection, ReferenceCounted<SSLConnection>
10621064
});
10631065

10641066
// If the background handshakers are not all busy, use one
1067+
1068+
// FIXME: see comment elsewhere about making this the only path.
10651069
if (FLOW_KNOBS->TLS_HANDSHAKE_ALWAYS_BACKGROUND ||
10661070
N2::g_net2->sslPoolHandshakesInProgress < N2::g_net2->sslHandshakerThreadsStarted) {
1071+
g_net2->countServerTLSHandshakesOnSideThreads++;
10671072
holder = Hold(&N2::g_net2->sslPoolHandshakesInProgress);
10681073
auto handshake =
10691074
new SSLHandshakerThread::Handshake(self->ssl_sock, boost::asio::ssl::stream_base::server);
@@ -1073,6 +1078,7 @@ class SSLConnection final : public IConnection, ReferenceCounted<SSLConnection>
10731078
N2::g_net2->sslHandshakerPool->post(handshake);
10741079
} else {
10751080
// Otherwise use flow network thread
1081+
g_net2->countServerTLSHandshakesOnMainThread++;
10761082
BindPromise p("N2_AcceptHandshakeError"_audit, self->id);
10771083
p.setPeerAddr(self->getPeerAddress());
10781084
onHandshook = p.getFuture();
@@ -1177,9 +1183,10 @@ class SSLConnection final : public IConnection, ReferenceCounted<SSLConnection>
11771183
// unpredictable system performance and reliability) is
11781184
// much, much higher than the cost a few hundred or
11791185
// thousand incremental threads.
1186+
11801187
if (FLOW_KNOBS->TLS_HANDSHAKE_ALWAYS_BACKGROUND ||
11811188
N2::g_net2->sslPoolHandshakesInProgress < N2::g_net2->sslHandshakerThreadsStarted) {
1182-
g_net2->countTLSHandshakesOnSideThreads++;
1189+
g_net2->countClientTLSHandshakesOnSideThreads++;
11831190
holder = Hold(&N2::g_net2->sslPoolHandshakesInProgress);
11841191
auto handshake =
11851192
new SSLHandshakerThread::Handshake(self->ssl_sock, boost::asio::ssl::stream_base::client);
@@ -1189,7 +1196,7 @@ class SSLConnection final : public IConnection, ReferenceCounted<SSLConnection>
11891196
N2::g_net2->sslHandshakerPool->post(handshake);
11901197
} else {
11911198
// Otherwise use flow network thread
1192-
g_net2->countTLSHandshakesOnMainThread++;
1199+
g_net2->countClientTLSHandshakesOnMainThread++;
11931200
BindPromise p("N2_ConnectHandshakeError"_audit, self->id);
11941201
p.setPeerAddr(self->getPeerAddress());
11951202
onHandshook = p.getFuture();
@@ -1622,8 +1629,10 @@ void Net2::initMetrics() {
16221629
slowTaskMetric.init("Net2.SlowTask"_sr);
16231630
countLaunchTime.init("Net2.CountLaunchTime"_sr);
16241631
countReactTime.init("Net2.CountReactTime"_sr);
1625-
countTLSHandshakesOnSideThreads.init("Net2.CountTLSHandshakesOnSideThreads"_sr);
1626-
countTLSHandshakesOnMainThread.init("Net2.CountTLSHandshakesOnMainThread"_sr);
1632+
countClientTLSHandshakesOnSideThreads.init("Net2.CountClientTLSHandshakesOnSideThreads"_sr);
1633+
countClientTLSHandshakesOnMainThread.init("Net2.CountClientTLSHandshakesOnMainThread"_sr);
1634+
countServerTLSHandshakesOnSideThreads.init("Net2.CountServerTLSHandshakesOnSideThreads"_sr);
1635+
countServerTLSHandshakesOnMainThread.init("Net2.CountServerTLSHandshakesOnMainThread"_sr);
16271636
taskQueue.initMetrics();
16281637
}
16291638

flow/SystemMonitor.cpp

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,23 @@ SystemStatistics customSystemMonitor(std::string const& eventName, StatisticsSta
182182
.detail("TLSPolicyFailures",
183183
(netData.countTLSPolicyFailures - statState->networkState.countTLSPolicyFailures) /
184184
currentStats.elapsed)
185-
.detail("TLSHandshakesOnSideThreads",
186-
(netData.countTLSHandshakesOnSideThreads -
187-
statState->networkState.countTLSHandshakesOnSideThreads) /
185+
.detail("ClientTLSHandshakesOnSideThreads",
186+
(netData.countClientTLSHandshakesOnSideThreads -
187+
statState->networkState.countClientTLSHandshakesOnSideThreads) /
188188
currentStats.elapsed)
189-
.detail(
190-
"TLSHandshakesOnMainThread",
191-
(netData.countTLSHandshakesOnMainThread - statState->networkState.countTLSHandshakesOnMainThread) /
192-
currentStats.elapsed)
189+
.detail("ClientTLSHandshakesOnMainThread",
190+
(netData.countClientTLSHandshakesOnMainThread -
191+
statState->networkState.countClientTLSHandshakesOnMainThread) /
192+
currentStats.elapsed)
193+
.detail("ServerTLSHandshakesOnSideThreads",
194+
(netData.countServerTLSHandshakesOnSideThreads -
195+
statState->networkState.countServerTLSHandshakesOnSideThreads) /
196+
currentStats.elapsed)
197+
.detail("ServerTLSHandshakesOnMainThread",
198+
(netData.countServerTLSHandshakesOnMainThread -
199+
statState->networkState.countServerTLSHandshakesOnMainThread) /
200+
currentStats.elapsed)
201+
193202
.trackLatest(eventName);
194203

195204
TraceEvent("MemoryMetrics")

flow/include/flow/SystemMonitor.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,10 @@ struct NetworkData {
9595
int64_t countTLSPolicyFailures;
9696
double countLaunchTime;
9797
double countReactTime;
98-
int64_t countTLSHandshakesOnSideThreads;
99-
int64_t countTLSHandshakesOnMainThread;
98+
int64_t countClientTLSHandshakesOnSideThreads;
99+
int64_t countClientTLSHandshakesOnMainThread;
100+
int64_t countServerTLSHandshakesOnSideThreads;
101+
int64_t countServerTLSHandshakesOnMainThread;
100102

101103
void init() {
102104
bytesSent = Int64Metric::getValueOrDefault("Net2.BytesSent"_sr);
@@ -139,8 +141,14 @@ struct NetworkData {
139141
countFilePageCacheHits = Int64Metric::getValueOrDefault("AsyncFile.CountCachePageReadsHit"_sr);
140142
countFilePageCacheMisses = Int64Metric::getValueOrDefault("AsyncFile.CountCachePageReadsMissed"_sr);
141143
countFilePageCacheEvictions = Int64Metric::getValueOrDefault("EvictablePageCache.CacheEvictions"_sr);
142-
countTLSHandshakesOnSideThreads = Int64Metric::getValueOrDefault("Net2.CountTLSHandshakesOnSideThreads"_sr);
143-
countTLSHandshakesOnMainThread = Int64Metric::getValueOrDefault("Net2.CountTLSHandshakesOnMainThread"_sr);
144+
countClientTLSHandshakesOnSideThreads =
145+
Int64Metric::getValueOrDefault("Net2.CountClientTLSHandshakesOnSideThreads"_sr);
146+
countClientTLSHandshakesOnMainThread =
147+
Int64Metric::getValueOrDefault("Net2.CountClientTLSHandshakesOnMainThread"_sr);
148+
countServerTLSHandshakesOnSideThreads =
149+
Int64Metric::getValueOrDefault("Net2.CountServerTLSHandshakesOnSideThreads"_sr);
150+
countServerTLSHandshakesOnMainThread =
151+
Int64Metric::getValueOrDefault("Net2.CountServerTLSHandshakesOnMainThread"_sr);
144152
}
145153
};
146154

0 commit comments

Comments
 (0)