mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 15:23:51 +00:00
Bug 1390881 - Improve the TFO telemetry. r=mcmanus
This commit is contained in:
parent
279495a829
commit
b274c67092
@ -19,10 +19,20 @@ namespace net {
|
||||
* layer do.
|
||||
**/
|
||||
|
||||
#define TFO_NOT_TRIED 0
|
||||
#define TFO_TRIED 1
|
||||
#define TFO_DATA_SENT 2
|
||||
#define TFO_FAILED 3
|
||||
typedef enum {
|
||||
TFO_NOT_TRIED,
|
||||
TFO_TRIED,
|
||||
TFO_DATA_SENT,
|
||||
TFO_FAILED_CONNECTION_REFUSED,
|
||||
TFO_FAILED_NET_TIMEOUT,
|
||||
TFO_FAILED_UNKNOW_ERROR,
|
||||
TFO_FAILED_BACKUP_CONNECTION,
|
||||
TFO_FAILED_CONNECTION_REFUSED_NO_TFO_FAILED_TOO,
|
||||
TFO_FAILED_NET_TIMEOUT__NO_TFO_FAILED_TOO,
|
||||
TFO_FAILED_UNKNOW_ERROR_NO_TFO_FAILED_TOO,
|
||||
TFO_FAILED_BACKUP_CONNECTION_NO_TFO_FAILED_TOO,
|
||||
TFO_FAILED
|
||||
} TFOResult;
|
||||
|
||||
nsresult AttachTCPFastOpenIOLayer(PRFileDesc *fd);
|
||||
|
||||
|
@ -271,4 +271,6 @@ interface nsISocketTransport : nsITransport
|
||||
in long keepaliveRetryInterval);
|
||||
|
||||
[noscript] void setFastOpenCallback(in TCPFastOpenPtr aFastOpen);
|
||||
|
||||
readonly attribute nsresult firstRetryError;
|
||||
};
|
||||
|
@ -801,6 +801,7 @@ nsSocketTransport::nsSocketTransport()
|
||||
, mFastOpenCallback(nullptr)
|
||||
, mFastOpenLayerHasBufferedData(false)
|
||||
, mFastOpenStatus(TFO_NOT_TRIED)
|
||||
, mFirstRetryError(NS_OK)
|
||||
, mDoNotRetryToConnect(false)
|
||||
{
|
||||
SOCKET_LOG(("creating nsSocketTransport @%p\n", this));
|
||||
@ -1776,8 +1777,13 @@ nsSocketTransport::RecoverFromError()
|
||||
mFastOpenCallback->SetFastOpenConnected(mCondition, true);
|
||||
}
|
||||
mFastOpenCallback = nullptr;
|
||||
|
||||
} else {
|
||||
|
||||
// This is only needed for telemetry.
|
||||
if (NS_SUCCEEDED(mFirstRetryError)) {
|
||||
mFirstRetryError = mCondition;
|
||||
}
|
||||
if ((mState == STATE_CONNECTING) && mDNSRecord &&
|
||||
mSocketTransportService->IsTelemetryEnabledAndNotSleepPhase()) {
|
||||
if (mNetAddr.raw.family == AF_INET) {
|
||||
@ -3602,5 +3608,12 @@ nsSocketTransport::SetFastOpenCallback(TCPFastOpen *aFastOpen)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSocketTransport::GetFirstRetryError(nsresult *aFirstRetryError)
|
||||
{
|
||||
*aFirstRetryError = mFirstRetryError;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace net
|
||||
} // namespace mozilla
|
||||
|
@ -479,6 +479,7 @@ private:
|
||||
TCPFastOpen *mFastOpenCallback;
|
||||
bool mFastOpenLayerHasBufferedData;
|
||||
uint8_t mFastOpenStatus;
|
||||
nsresult mFirstRetryError;
|
||||
|
||||
bool mDoNotRetryToConnect;
|
||||
};
|
||||
|
@ -1525,6 +1525,12 @@ SocketTransportShim::Bind(NetAddr *aLocalAddr)
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SocketTransportShim::GetFirstRetryError(nsresult *aFirstRetryError)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
#define FWD_TS_PTR(fx, ts) NS_IMETHODIMP \
|
||||
SocketTransportShim::fx(ts *arg) { return mWrapped->fx(arg); }
|
||||
|
||||
|
@ -125,7 +125,20 @@ nsHttpConnection::~nsHttpConnection()
|
||||
mForceSendTimer = nullptr;
|
||||
}
|
||||
|
||||
Telemetry::Accumulate(Telemetry::TCP_FAST_OPEN, mFastOpenStatus);
|
||||
if ((mFastOpenStatus != TFO_FAILED) &&
|
||||
((mFastOpenStatus != TFO_NOT_TRIED) ||
|
||||
#if defined(_WIN64) && defined(WIN95)
|
||||
(gHttpHandler->UseFastOpen() &&
|
||||
gSocketTransportService &&
|
||||
gSocketTransportService->HasFileDesc2PlatformOverlappedIOHandleFunc()))) {
|
||||
#else
|
||||
gHttpHandler->UseFastOpen())) {
|
||||
#endif
|
||||
// TFO_FAILED will be reported in the replacement connection with more
|
||||
// details.
|
||||
// Otherwise report only if TFO is enabled and supported.
|
||||
Telemetry::Accumulate(Telemetry::TCP_FAST_OPEN_2, mFastOpenStatus);
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -2393,6 +2406,19 @@ nsHttpConnection::SetFastOpen(bool aFastOpen)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHttpConnection::SetFastOpenStatus(uint8_t tfoStatus) {
|
||||
mFastOpenStatus = tfoStatus;
|
||||
if ((mFastOpenStatus >= TFO_FAILED_CONNECTION_REFUSED) &&
|
||||
mSocketTransport) {
|
||||
nsresult firstRetryError;
|
||||
if (NS_SUCCEEDED(mSocketTransport->GetFirstRetryError(&firstRetryError)) &&
|
||||
(NS_FAILED(firstRetryError))) {
|
||||
mFastOpenStatus = tfoStatus + 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHttpConnection::BootstrapTimings(TimingStruct times)
|
||||
{
|
||||
|
@ -233,9 +233,7 @@ public:
|
||||
bool TestJoinConnection(const nsACString &hostname, int32_t port);
|
||||
bool JoinConnection(const nsACString &hostname, int32_t port);
|
||||
|
||||
void SetFastOpenStatus(uint8_t tfoStatus) {
|
||||
mFastOpenStatus = tfoStatus;
|
||||
}
|
||||
void SetFastOpenStatus(uint8_t tfoStatus);
|
||||
|
||||
private:
|
||||
// Value (set in mTCPKeepaliveConfig) indicates which set of prefs to use.
|
||||
|
@ -3726,6 +3726,7 @@ nsHalfOpenSocket::nsHalfOpenSocket(nsConnectionEntry *ent,
|
||||
, mFreeToUse(true)
|
||||
, mPrimaryStreamStatus(NS_OK)
|
||||
, mFastOpenInProgress(false)
|
||||
, mFastOpenStatus(TFO_NOT_TRIED)
|
||||
, mEnt(ent)
|
||||
{
|
||||
MOZ_ASSERT(ent && trans, "constructor with null arguments");
|
||||
@ -4176,6 +4177,7 @@ nsHalfOpenSocket::OnOutputStreamReady(nsIAsyncOutputStream *out)
|
||||
|
||||
mFastOpenInProgress = false;
|
||||
mConnectionNegotiatingFastOpen = nullptr;
|
||||
mFastOpenStatus = TFO_FAILED_BACKUP_CONNECTION;
|
||||
}
|
||||
|
||||
nsresult rv = SetupConn(out, false);
|
||||
@ -4358,6 +4360,7 @@ nsHalfOpenSocket::SetFastOpenConnected(nsresult aError, bool aWillRetry)
|
||||
// work around.
|
||||
(aError == NS_ERROR_FAILURE) ||
|
||||
#endif
|
||||
(aError == NS_ERROR_PROXY_CONNECTION_REFUSED) ||
|
||||
(aError == NS_ERROR_NET_TIMEOUT))) {
|
||||
if (mEnt->mUseFastOpen) {
|
||||
gHttpHandler->IncrementFastOpenConsecutiveFailureCounter();
|
||||
@ -4397,6 +4400,14 @@ nsHalfOpenSocket::SetFastOpenConnected(nsresult aError, bool aWillRetry)
|
||||
mSocketTransport->SetSecurityCallbacks(this);
|
||||
mStreamIn->AsyncWait(nullptr, 0, 0, nullptr);
|
||||
|
||||
if (aError == NS_ERROR_CONNECTION_REFUSED) {
|
||||
mFastOpenStatus = TFO_FAILED_CONNECTION_REFUSED;
|
||||
} else if (aError == NS_ERROR_NET_TIMEOUT) {
|
||||
mFastOpenStatus = TFO_FAILED_NET_TIMEOUT;
|
||||
} else {
|
||||
mFastOpenStatus = TFO_FAILED_UNKNOW_ERROR;
|
||||
}
|
||||
|
||||
} else {
|
||||
// On success or other error we proceed with connection, we just need
|
||||
// to close backup timer and halfOpenSock.
|
||||
@ -4658,6 +4669,8 @@ nsHalfOpenSocket::SetupConn(nsIAsyncOutputStream *out,
|
||||
} else {
|
||||
conn->SetFastOpen(false);
|
||||
}
|
||||
} else {
|
||||
conn->SetFastOpenStatus(mFastOpenStatus);
|
||||
}
|
||||
|
||||
// If this halfOpenConn was speculative, but at the ende the conn got a
|
||||
|
@ -473,6 +473,7 @@ private:
|
||||
|
||||
bool mFastOpenInProgress;
|
||||
RefPtr<nsHttpConnection> mConnectionNegotiatingFastOpen;
|
||||
uint8_t mFastOpenStatus;
|
||||
|
||||
RefPtr<nsConnectionEntry> mEnt;
|
||||
nsCOMPtr<nsITimer> mSynTimer;
|
||||
|
@ -2299,6 +2299,16 @@ nsHttpHandler::Observe(nsISupports *subject,
|
||||
} else {
|
||||
Telemetry::Accumulate(Telemetry::DNT_USAGE, 1);
|
||||
}
|
||||
|
||||
if (UseFastOpen()) {
|
||||
Telemetry::Accumulate(Telemetry::TCP_FAST_OPEN_STATUS, 0);
|
||||
} else if (!mFastOpenSupported) {
|
||||
Telemetry::Accumulate(Telemetry::TCP_FAST_OPEN_STATUS, 1);
|
||||
} else if (!mUseFastOpen) {
|
||||
Telemetry::Accumulate(Telemetry::TCP_FAST_OPEN_STATUS, 2);
|
||||
} else {
|
||||
Telemetry::Accumulate(Telemetry::TCP_FAST_OPEN_STATUS, 3);
|
||||
}
|
||||
} else if (!strcmp(topic, "profile-change-net-restore")) {
|
||||
// initialize connection manager
|
||||
rv = InitConnectionMgr();
|
||||
|
@ -2545,14 +2545,23 @@
|
||||
"description": "Stats about success rate of HTTP OMT request in content process, keyed by content policy.",
|
||||
"labels": ["success", "successMainThread", "failListener", "failListenerChain", "notRequested"]
|
||||
},
|
||||
"TCP_FAST_OPEN": {
|
||||
"TCP_FAST_OPEN_2": {
|
||||
"record_in_processes": ["main", "content"],
|
||||
"expires_in_version": "61",
|
||||
"kind": "enumerated",
|
||||
"n_values": 16,
|
||||
"description": "When a http connection is closed, track whether or not TCP Fast Open was used: 0=TFO_NOT_TRIED(There was no http connection and it was not TLS), 1=TFO_TRIED_NEGOTIATING, 2=TFO_DATA_SENT, 3=TFO_FAILED_CONNECTION_REFUSED, 4=TFO_FAILED_NET_TIMEOUT, 5=TFO_FAILED_UNKNOW_ERROR, 6=TFO_FAILED_BACKUP_CONNECTION, 7=TFO_FAILED_CONNECTION_REFUSED_NO_TFO_FAILED_TOO, 8=TFO_FAILED_NET_TIMEOUT__NO_TFO_FAILED_TOO, 9=TFO_FAILED_UNKNOW_ERROR_NO_TFO_FAILED_TOO, 10=TFO_FAILED_BACKUP_CONNECTION_NO_TFO_FAILED_TOO.",
|
||||
"alert_emails": ["necko@mozilla.com", "ddamjanovic@mozilla.com"],
|
||||
"bug_numbers": [1390881]
|
||||
},
|
||||
"TCP_FAST_OPEN_STATUS": {
|
||||
"record_in_processes": ["main", "content"],
|
||||
"expires_in_version": "61",
|
||||
"kind": "enumerated",
|
||||
"n_values": 8,
|
||||
"description": "When a http connection is closed, track whether or not TCP Fast Open was used: 0=TFO_NOT_TRIED, 1=TFO_TRIED_NEGOTIATING, 2=TFO_DATA_SENT, 3=TFO_FAILED.",
|
||||
"alert_emails": ["necko@mozilla.com"],
|
||||
"bug_numbers": [1352271]
|
||||
"description": "TCP Fast Open was: 0=enabled during the session, 1=not available or disabled in the os, 2=disabled by the pref, 3=disabled based on the too many connection failures.",
|
||||
"alert_emails": ["necko@mozilla.com", "ddamjanovic@mozilla.com"],
|
||||
"bug_numbers": [1390881]
|
||||
},
|
||||
"TLS_EARLY_DATA_NEGOTIATED": {
|
||||
"record_in_processes": ["main", "content"],
|
||||
|
Loading…
Reference in New Issue
Block a user