Skip to content

Commit

Permalink
Add network path model update events to qlog
Browse files Browse the repository at this point in the history
Summary: Several "Network Path Model" parameters are described in Sec. 2.9 of the BBRv2 IETF draft. These quantities evolve throughout the connection and they are useful to analyze BBRv2 performance. This diff adds inflight_hi, inflight_lo, bandwidth_hi, and bandwidth_lo to the qlog.

Reviewed By: mjoras

Differential Revision: D61414936

fbshipit-source-id: 2862db2a6aab336fd8a60e4ae5b358e9ab5588b4
  • Loading branch information
ritengupta authored and facebook-github-bot committed Aug 26, 2024
1 parent 93bb817 commit 5f74df1
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 3 deletions.
9 changes: 9 additions & 0 deletions quic/congestion_control/Bbr2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,15 @@ void Bbr2CongestionController::onPacketAckOrLoss(
getCongestionWindow(),
kCongestionPacketAck,
bbr2StateToString(state_));
conn_.qLogger->addNetworkPathModelUpdate(
inflightHi_.value_or(0),
inflightLo_.value_or(0),
bandwidthHi_.has_value() ? bandwidthHi_->units : 0,
bandwidthHi_.has_value() ? bandwidthHi_->interval
: std::chrono::microseconds(1),
bandwidthLo_.has_value() ? bandwidthLo_->units : 0,
bandwidthLo_.has_value() ? bandwidthLo_->interval
: std::chrono::microseconds(1));
}
if (ackEvent) {
subtractAndCheckUnderflow(
Expand Down
19 changes: 19 additions & 0 deletions quic/logging/FileQLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,25 @@ void FileQLogger::addL4sWeightUpdate(
l4sWeight, newEct1, newCe, refTime));
}

void FileQLogger::addNetworkPathModelUpdate(
uint64_t inflightHi,
uint64_t inflightLo,
uint64_t bandwidthHiBytes,
std::chrono::microseconds bandwidthHiInterval,
uint64_t bandwidthLoBytes,
std::chrono::microseconds bandwidthLoInterval) {
auto refTime = std::chrono::duration_cast<std::chrono::microseconds>(
std::chrono::steady_clock::now().time_since_epoch());
handleEvent(std::make_unique<quic::QLogNetworkPathModelUpdateEvent>(
inflightHi,
inflightLo,
bandwidthHiBytes,
bandwidthHiInterval,
bandwidthLoBytes,
bandwidthLoInterval,
refTime));
}

void FileQLogger::outputLogsToFile(const std::string& path, bool prettyJson) {
if (streaming_) {
return;
Expand Down
8 changes: 7 additions & 1 deletion quic/logging/FileQLogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,13 @@ class FileQLogger : public BaseQLogger {
bool incremental) override;
void addL4sWeightUpdate(double l4sWeight, uint32_t newEct1, uint32_t newCe)
override;

void addNetworkPathModelUpdate(
uint64_t inflightHi,
uint64_t inflightLo,
uint64_t bandwidthHiBytes,
std::chrono::microseconds bandwidthHiInterval,
uint64_t bandwidthLoBytes,
std::chrono::microseconds bandwidthLoInterval) override;
void outputLogsToFile(const std::string& path, bool prettyJson);
folly::dynamic toDynamic() const;
folly::dynamic toDynamicBase() const;
Expand Down
8 changes: 7 additions & 1 deletion quic/logging/QLogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,13 @@ class QLogger {
bool incremental) = 0;
virtual void
addL4sWeightUpdate(double l4sWeight, uint32_t newEct1, uint32_t newCe) = 0;

virtual void addNetworkPathModelUpdate(
uint64_t inflightHi,
uint64_t inflightLo,
uint64_t bandwidthHiBytes,
std::chrono::microseconds bandwidthHiInterval,
uint64_t bandwidthLoBytes,
std::chrono::microseconds bandwidthLoInterval) = 0;
virtual void setDcid(Optional<ConnectionId> connID) = 0;
virtual void setScid(Optional<ConnectionId> connID) = 0;
};
Expand Down
36 changes: 36 additions & 0 deletions quic/logging/QLoggerTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,40 @@ folly::dynamic QLogL4sWeightUpdateEvent::toDynamic() const {
return d;
}

QLogNetworkPathModelUpdateEvent::QLogNetworkPathModelUpdateEvent(
uint64_t inflightHi,
uint64_t inflightLo,
uint64_t bandwidthHiBytes,
std::chrono::microseconds bandwidthHiInterval,
uint64_t bandwidthLoBytes,
std::chrono::microseconds bandwidthLoInterval,
std::chrono::microseconds refTimeIn)
: inflightHi_(inflightHi),
inflightLo_(inflightLo),
bandwidthHiBytes_(bandwidthHiBytes),
bandwidthHiInterval_(bandwidthHiInterval),
bandwidthLoBytes_(bandwidthLoBytes),
bandwidthLoInterval_(bandwidthLoInterval) {
eventType = QLogEventType::NetworkPathModelUpdate;
refTime = refTimeIn;
}

folly::dynamic QLogNetworkPathModelUpdateEvent::toDynamic() const {
folly::dynamic d = folly::dynamic::array(
folly::to<std::string>(refTime.count()),
"metric_update",
toString(eventType));
folly::dynamic data = folly::dynamic::object();
data["inflight_hi"] = inflightHi_;
data["inflight_lo"] = inflightLo_;
data["bandwidth_hi_bytes"] = bandwidthHiBytes_;
data["bandwidth_hi_interval"] = bandwidthHiInterval_.count();
data["bandwidth_lo_bytes"] = bandwidthLoBytes_;
data["bandwidth_lo_interval"] = bandwidthLoInterval_.count();
d.push_back(std::move(data));
return d;
}

folly::StringPiece toString(QLogEventType type) {
switch (type) {
case QLogEventType::PacketSent:
Expand Down Expand Up @@ -1030,6 +1064,8 @@ folly::StringPiece toString(QLogEventType type) {
return "priority";
case QLogEventType::L4sWeightUpdate:
return "l4s_weight_update";
case QLogEventType::NetworkPathModelUpdate:
return "network_path_model_update";
}
folly::assume_unreachable();
}
Expand Down
25 changes: 24 additions & 1 deletion quic/logging/QLoggerTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,8 @@ enum class QLogEventType : uint32_t {
ConnectionMigration,
PathValidation,
PriorityUpdate,
L4sWeightUpdate
L4sWeightUpdate,
NetworkPathModelUpdate
};

folly::StringPiece toString(QLogEventType type);
Expand Down Expand Up @@ -778,4 +779,26 @@ class QLogL4sWeightUpdateEvent : public QLogEvent {
uint32_t newCEEchoed_;
};

class QLogNetworkPathModelUpdateEvent : public QLogEvent {
public:
explicit QLogNetworkPathModelUpdateEvent(
uint64_t inflightHi,
uint64_t inflightLo,
uint64_t bandwidthHiBytes,
std::chrono::microseconds bandwidthHiInterval,
uint64_t bandwidthLoBytes,
std::chrono::microseconds bandwidthLoInterval,
std::chrono::microseconds refTimeIn);
~QLogNetworkPathModelUpdateEvent() override = default;

FOLLY_NODISCARD folly::dynamic toDynamic() const override;

uint64_t inflightHi_;
uint64_t inflightLo_;
uint64_t bandwidthHiBytes_;
std::chrono::microseconds bandwidthHiInterval_;
uint64_t bandwidthLoBytes_;
std::chrono::microseconds bandwidthLoInterval_;
};

} // namespace quic
9 changes: 9 additions & 0 deletions quic/logging/test/Mocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,14 @@ class MockQLogger : public QLogger {
void,
addL4sWeightUpdate,
(double l4sWeight, uint32_t newEct1, uint32_t newCe));
MOCK_METHOD(
void,
addNetworkPathModelUpdate,
(uint64_t inflightHi,
uint64_t inflightLo,
uint64_t bandwidthHiBytes,
std::chrono::microseconds bandwidthHiInterval,
uint64_t bandwidthLoBytes,
std::chrono::microseconds bandwidthLoInterval));
};
} // namespace quic::test

0 comments on commit 5f74df1

Please sign in to comment.