Skip to content

Commit bfc3535

Browse files
committed
quic: consolidate stats collecting in QuicSession
PR-URL: #34741 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent 94aa291 commit bfc3535

File tree

3 files changed

+15
-22
lines changed

3 files changed

+15
-22
lines changed

src/quic/node_quic_http3_application.cc

+4-5
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,10 @@ Http3Application::Http3Application(
7979
// Push streams in HTTP/3 are a bit complicated.
8080
// First, it's important to know that only an HTTP/3 server can
8181
// create a push stream.
82-
// Second, it's important to recognize that a push stream is
83-
// essentially an *assumed* request. For instance, if a client
84-
// requests a webpage that has links to css and js files, and
85-
// the server expects the client to send subsequent requests
86-
// for those css and js files, the server can shortcut the
82+
// Second, a push stream is essentially an *assumed* request. For
83+
// instance, if a client requests a webpage that has links to css
84+
// and js files, and the server expects the client to send subsequent
85+
// requests for those css and js files, the server can shortcut the
8786
// process by opening a push stream for each additional resource
8887
// it assumes the client to make.
8988
// Third, a push stream can only be opened within the context

src/quic/node_quic_session.cc

+7-14
Original file line numberDiff line numberDiff line change
@@ -2098,7 +2098,6 @@ bool QuicSession::Receive(
20982098
UpdateIdleTimer();
20992099

21002100
SendPendingData();
2101-
UpdateRecoveryStats();
21022101
Debug(this, "Successfully processed received packet");
21032102
return true;
21042103
}
@@ -2893,19 +2892,6 @@ void QuicSessionOnCertDone(const FunctionCallbackInfo<Value>& args) {
28932892
}
28942893
} // namespace
28952894

2896-
// Recovery stats are used to allow user code to keep track of
2897-
// important round-trip timing statistics that are updated through
2898-
// the lifetime of a connection. Effectively, these communicate how
2899-
// much time (from the perspective of the local peer) is being taken
2900-
// to exchange data reliably with the remote peer.
2901-
// TODO(@jasnell): Revisit
2902-
void QuicSession::UpdateRecoveryStats() {
2903-
ngtcp2_conn_stat stat;
2904-
ngtcp2_conn_get_conn_stat(connection(), &stat);
2905-
SetStat(&QuicSessionStats::min_rtt, stat.min_rtt);
2906-
SetStat(&QuicSessionStats::latest_rtt, stat.latest_rtt);
2907-
SetStat(&QuicSessionStats::smoothed_rtt, stat.smoothed_rtt);
2908-
}
29092895

29102896
// Data stats are used to allow user code to keep track of important
29112897
// statistics such as amount of data in flight through the lifetime
@@ -2918,6 +2904,13 @@ void QuicSession::UpdateDataStats() {
29182904
ngtcp2_conn_stat stat;
29192905
ngtcp2_conn_get_conn_stat(connection(), &stat);
29202906

2907+
SetStat(&QuicSessionStats::latest_rtt, stat.latest_rtt);
2908+
SetStat(&QuicSessionStats::min_rtt, stat.min_rtt);
2909+
SetStat(&QuicSessionStats::smoothed_rtt, stat.smoothed_rtt);
2910+
SetStat(&QuicSessionStats::receive_rate, stat.recv_rate_sec);
2911+
SetStat(&QuicSessionStats::send_rate, stat.delivery_rate_sec);
2912+
SetStat(&QuicSessionStats::cwnd, stat.cwnd);
2913+
29212914
state_->bytes_in_flight = stat.bytes_in_flight;
29222915
// The max_bytes_in_flight is a highwater mark that can be used
29232916
// in performance analysis operations.

src/quic/node_quic_session.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,10 @@ enum QuicSessionStateFields {
204204
V(BLOCK_COUNT, block_count, "Block Count") \
205205
V(MIN_RTT, min_rtt, "Minimum RTT") \
206206
V(LATEST_RTT, latest_rtt, "Latest RTT") \
207-
V(SMOOTHED_RTT, smoothed_rtt, "Smoothed RTT")
207+
V(SMOOTHED_RTT, smoothed_rtt, "Smoothed RTT") \
208+
V(CWND, cwnd, "Cwnd") \
209+
V(RECEIVE_RATE, receive_rate, "Receive Rate / Sec") \
210+
V(SEND_RATE, send_rate, "Send Rate Sec")
208211

209212
#define V(name, _, __) IDX_QUIC_SESSION_STATS_##name,
210213
enum QuicSessionStatsIdx : int {
@@ -1272,8 +1275,6 @@ class QuicSession final : public AsyncWrap,
12721275

12731276
bool WritePackets(const char* diagnostic_label = nullptr);
12741277

1275-
void UpdateRecoveryStats();
1276-
12771278
void UpdateConnectionID(
12781279
int type,
12791280
const QuicCID& cid,

0 commit comments

Comments
 (0)