Skip to content
This repository was archived by the owner on Aug 11, 2020. It is now read-only.

Commit cdac96d

Browse files
committed
quic: additional QuicStream tracking stats
PR-URL: #294 Reviewed-By: Anna Henningsen <[email protected]>
1 parent 9136b2d commit cdac96d

File tree

5 files changed

+39
-21
lines changed

5 files changed

+39
-21
lines changed

doc/api/quic.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1973,6 +1973,16 @@ added: REPLACEME
19731973

19741974
The numeric identifier of the `QuicStream`.
19751975

1976+
#### quicstream.maxAcknowledgedOffset
1977+
<!-- YAML
1978+
added: REPLACEME
1979+
-->
1980+
1981+
* Type: {BigInt}
1982+
1983+
A `BigInt` representing the highest acknowledged data offset received
1984+
for this `QuicStream`.
1985+
19761986
#### quicstream.maxExtendedOffset
19771987
<!-- YAML
19781988
added: REPLACEME
@@ -1983,6 +1993,15 @@ added: REPLACEME
19831993
A `BigInt` representing the maximum extended data offset that has been
19841994
reported to the connected peer.
19851995

1996+
#### quicstream.maxReceivedOffset
1997+
<!-- YAML
1998+
added: REPLACEME
1999+
-->
2000+
2001+
* Type: {BigInt}
2002+
2003+
A `BigInt` representing the maximum received offset for this `QuicStream`.
2004+
19862005
#### quicstream.pending
19872006
<!-- YAML
19882007
added: REPLACEME

lib/internal/quic/core.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ const {
148148
IDX_QUIC_STREAM_STATS_BYTES_SENT,
149149
IDX_QUIC_STREAM_STATS_MAX_OFFSET,
150150
IDX_QUIC_STREAM_STATS_FINAL_SIZE,
151+
IDX_QUIC_STREAM_STATS_MAX_OFFSET_ACK,
152+
IDX_QUIC_STREAM_STATS_MAX_OFFSET_RECV,
151153
IDX_QUIC_SOCKET_STATS_CREATED_AT,
152154
IDX_QUIC_SOCKET_STATS_BOUND_AT,
153155
IDX_QUIC_SOCKET_STATS_LISTEN_AT,
@@ -2857,6 +2859,16 @@ class QuicStream extends Duplex {
28572859
const stats = this.#stats || this[kHandle].stats;
28582860
return stats[IDX_QUIC_STREAM_STATS_FINAL_SIZE];
28592861
}
2862+
2863+
get maxAcknowledgedOffset() {
2864+
const stats = this.#stats || this[kHandle].stats;
2865+
return stats[IDX_QUIC_STREAM_STATS_MAX_OFFSET_ACK];
2866+
}
2867+
2868+
get maxReceivedOffset() {
2869+
const stats = this.#stats || this[kHandle].stats;
2870+
return stats[IDX_QUIC_STREAM_STATS_MAX_OFFSET_RECV];
2871+
}
28602872
}
28612873

28622874
function createSocket(options) {

src/quic/node_quic_stream-inl.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,6 @@ bool QuicStream::is_write_finished() const {
8080
streambuf_.length() == 0;
8181
}
8282

83-
void QuicStream::IncrementAvailableOutboundLength(size_t amount) {
84-
available_outbound_length_ += amount;
85-
}
86-
87-
void QuicStream::DecrementAvailableOutboundLength(size_t amount) {
88-
available_outbound_length_ -= amount;
89-
}
90-
9183
bool QuicStream::SubmitInformation(v8::Local<v8::Array> headers) {
9284
return session_->SubmitInformation(stream_id_, headers);
9385
}

src/quic/node_quic_stream.cc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ void QuicStream::Acknowledge(uint64_t offset, size_t datalen) {
8585
// ngtcp2 guarantees that offset must always be greater
8686
// than the previously received offset, but let's just
8787
// make sure that holds.
88-
CHECK_GE(offset, max_offset_ack_);
89-
max_offset_ack_ = offset;
88+
CHECK_GE(offset, GetStat(&QuicStreamStats::max_offset_ack));
89+
SetStat(&QuicStreamStats::max_offset_ack, offset);
9090

9191
Debug(this, "Acknowledging %d bytes", datalen);
9292

@@ -216,7 +216,6 @@ int QuicStream::DoWrite(
216216

217217
session()->ResumeStream(stream_id_);
218218

219-
// IncrementAvailableOutboundLength(len);
220219
return 0;
221220
}
222221

@@ -310,8 +309,8 @@ void QuicStream::ReceiveData(
310309

311310
// ngtcp2 guarantees that offset is always greater than the previously
312311
// received offset. Let's just make sure.
313-
CHECK_GE(offset, max_offset_);
314-
max_offset_ = offset;
312+
CHECK_GE(offset, GetStat(&QuicStreamStats::max_offset_received));
313+
SetStat(&QuicStreamStats::max_offset_received, offset);
315314

316315
if (datalen > 0) {
317316
// IncrementStats will update the data_rx_rate_ and data_rx_size_

src/quic/node_quic_stream.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ enum QuicStreamHeadersKind : int {
4848
V(BYTES_RECEIVED, bytes_received, "Bytes Received") \
4949
V(BYTES_SENT, bytes_sent, "Bytes Sent") \
5050
V(MAX_OFFSET, max_offset, "Max Offset") \
51+
V(MAX_OFFSET_ACK, max_offset_ack, "Max Acknowledged Offset") \
52+
V(MAX_OFFSET_RECV, max_offset_received, "Max Received Offset") \
5153
V(FINAL_SIZE, final_size, "Final Size")
5254

5355
#define V(name, _, __) IDX_QUIC_STREAM_STATS_##name,
@@ -280,9 +282,6 @@ class QuicStream : public AsyncWrap,
280282
size_t nbufs,
281283
uv_stream_t* send_handle) override;
282284

283-
inline void IncrementAvailableOutboundLength(size_t amount);
284-
inline void DecrementAvailableOutboundLength(size_t amount);
285-
286285
// Returns false if the header cannot be added. This will
287286
// typically only happen if a maximimum number of headers
288287
// has been reached.
@@ -367,14 +366,11 @@ class QuicStream : public AsyncWrap,
367366
void IncrementStats(size_t datalen);
368367

369368
BaseObjectWeakPtr<QuicSession> session_;
369+
QuicBuffer streambuf_;
370+
370371
int64_t stream_id_ = 0;
371372
int64_t push_id_ = 0;
372-
uint64_t max_offset_ = 0;
373-
uint64_t max_offset_ack_ = 0;
374373
uint32_t flags_ = QUICSTREAM_FLAG_INITIAL;
375-
376-
QuicBuffer streambuf_;
377-
size_t available_outbound_length_ = 0;
378374
size_t inbound_consumed_data_while_paused_ = 0;
379375

380376
std::vector<std::unique_ptr<QuicHeader>> headers_;

0 commit comments

Comments
 (0)