Skip to content

Commit

Permalink
Bug 1415625 - Use Telemetry::CanRecordPreReleaseData instead of toolk…
Browse files Browse the repository at this point in the history
…it.telemetry.enabled. Remove network.allow-experiments because it is not used. r=michal

Differential Revision: https://phabricator.services.mozilla.com/D12745

--HG--
extra : moz-landing-system : lando
  • Loading branch information
ddragana committed Dec 18, 2018
1 parent 7fd9558 commit 2ebce46
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 72 deletions.
5 changes: 0 additions & 5 deletions modules/libpref/init/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -1603,11 +1603,6 @@ pref("logging.config.clear_on_startup", true);
// prevents necko connecting to ports 1-5 unless the protocol
// overrides.

// Allow necko to do A/B testing. Will generally only happen if
// telemetry is also enabled as otherwise there is no way to report
// the results
pref("network.allow-experiments", true);

// Allow the network changed event to get sent when a network topology or
// setup change is noticed while running.
pref("network.notify.changed", true);
Expand Down
37 changes: 18 additions & 19 deletions netwerk/base/nsSocketTransportService2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ static Atomic<PRThread *, Relaxed> gSocketThread;
#define POLL_BUSY_WAIT_PERIOD "network.sts.poll_busy_wait_period"
#define POLL_BUSY_WAIT_PERIOD_TIMEOUT \
"network.sts.poll_busy_wait_period_timeout"
#define TELEMETRY_PREF "toolkit.telemetry.enabled"
#define MAX_TIME_FOR_PR_CLOSE_DURING_SHUTDOWN \
"network.sts.max_time_for_pr_close_during_shutdown"
#define POLLABLE_EVENT_TIMEOUT "network.sts.pollable_event_timeout"
Expand Down Expand Up @@ -142,7 +141,6 @@ nsSocketTransportService::nsSocketTransportService()
mPollableEventTimeout(TimeDuration::FromSeconds(6)),
mServingPendingQueue(false),
mMaxTimePerPollIter(100),
mTelemetryEnabledPref(false),
mMaxTimeForPrClosePref(PR_SecondsToInterval(5)),
mLastNetworkLinkChangeTime(0),
mNetworkLinkChangeBusyWaitPeriod(PR_SecondsToInterval(50)),
Expand Down Expand Up @@ -287,7 +285,7 @@ bool nsSocketTransportService::CanAttachSocket() {
uint32_t total = mActiveCount + mIdleCount;
bool rv = total < gMaxCount;

if (mTelemetryEnabledPref &&
if (Telemetry::CanRecordPrereleaseData() &&
(((total >= 900) || !rv) && !reported900FDLimit)) {
reported900FDLimit = true;
Telemetry::Accumulate(Telemetry::NETWORK_SESSION_AT_900FD, true);
Expand Down Expand Up @@ -538,7 +536,7 @@ int32_t nsSocketTransportService::Poll(TimeDuration *pollDuration,
}

TimeStamp pollStart;
if (mTelemetryEnabledPref) {
if (Telemetry::CanRecordPrereleaseData()) {
pollStart = TimeStamp::NowLoRes();
}

Expand All @@ -556,7 +554,7 @@ int32_t nsSocketTransportService::Poll(TimeDuration *pollDuration,
return PR_Poll(pollList, pollCount, pollTimeout);
}();

if (mTelemetryEnabledPref && !pollStart.IsNull()) {
if (Telemetry::CanRecordPrereleaseData() && !pollStart.IsNull()) {
*pollDuration = TimeStamp::NowLoRes() - pollStart;
}

Expand All @@ -581,7 +579,6 @@ static const char *gCallbackPrefs[] = {
KEEPALIVE_RETRY_INTERVAL_PREF,
KEEPALIVE_PROBE_COUNT_PREF,
MAX_TIME_BETWEEN_TWO_POLLS,
TELEMETRY_PREF,
MAX_TIME_FOR_PR_CLOSE_DURING_SHUTDOWN,
POLLABLE_EVENT_TIMEOUT,
ESNI_ENABLED,
Expand Down Expand Up @@ -961,20 +958,20 @@ nsSocketTransportService::Run() {

numberOfPendingEvents = 0;
numberOfPendingEventsLastCycle = 0;
if (mTelemetryEnabledPref) {
if (Telemetry::CanRecordPrereleaseData()) {
startOfCycleForLastCycleCalc = TimeStamp::NowLoRes();
startOfNextIteration = TimeStamp::NowLoRes();
}
pollDuration = nullptr;

do {
if (mTelemetryEnabledPref) {
if (Telemetry::CanRecordPrereleaseData()) {
pollCycleStart = TimeStamp::NowLoRes();
}

DoPollIteration(&singlePollDuration);

if (mTelemetryEnabledPref && !pollCycleStart.IsNull()) {
if (Telemetry::CanRecordPrereleaseData() && !pollCycleStart.IsNull()) {
Telemetry::Accumulate(Telemetry::STS_POLL_BLOCK_TIME,
singlePollDuration.ToMilliseconds());
Telemetry::AccumulateTimeDelta(Telemetry::STS_POLL_CYCLE,
Expand All @@ -1001,7 +998,7 @@ nsSocketTransportService::Run() {
mServingPendingQueue = true;
}

if (mTelemetryEnabledPref) {
if (Telemetry::CanRecordPrereleaseData()) {
startOfIteration = startOfNextIteration;
// Everything that comes after this point will
// be served in the next iteration. If no even
Expand All @@ -1020,7 +1017,7 @@ nsSocketTransportService::Run() {
((TimeStamp::NowLoRes() - eventQueueStart).ToMilliseconds() <
mMaxTimePerPollIter));

if (mTelemetryEnabledPref && !mServingPendingQueue &&
if (Telemetry::CanRecordPrereleaseData() && !mServingPendingQueue &&
!startOfIteration.IsNull()) {
Telemetry::AccumulateTimeDelta(Telemetry::STS_POLL_AND_EVENTS_CYCLE,
startOfIteration + pollDuration,
Expand All @@ -1041,7 +1038,8 @@ nsSocketTransportService::Run() {
{
MutexAutoLock lock(mLock);
if (mShuttingDown) {
if (mTelemetryEnabledPref && !startOfCycleForLastCycleCalc.IsNull()) {
if (Telemetry::CanRecordPrereleaseData() &&
!startOfCycleForLastCycleCalc.IsNull()) {
Telemetry::Accumulate(
Telemetry::STS_NUMBER_OF_PENDING_EVENTS_IN_THE_LAST_CYCLE,
numberOfPendingEventsLastCycle);
Expand Down Expand Up @@ -1224,7 +1222,7 @@ nsresult nsSocketTransportService::DoPollIteration(TimeDuration *pollDuration) {
s.MaybeResetEpoch();
}
}
if (mTelemetryEnabledPref) {
if (Telemetry::CanRecordPrereleaseData()) {
Telemetry::Accumulate(Telemetry::STS_NUMBER_OF_ONSOCKETREADY_CALLS,
numberOfOnSocketReadyCalls);
}
Expand Down Expand Up @@ -1331,12 +1329,6 @@ nsresult nsSocketTransportService::UpdatePrefs() {
PR_SecondsToInterval(pollBusyWaitPeriodTimeout);
}

bool telemetryPref = false;
rv = Preferences::GetBool(TELEMETRY_PREF, &telemetryPref);
if (NS_SUCCEEDED(rv)) {
mTelemetryEnabledPref = telemetryPref;
}

int32_t maxTimeForPrClosePref;
rv = Preferences::GetInt(MAX_TIME_FOR_PR_CLOSE_DURING_SHUTDOWN,
&maxTimeForPrClosePref);
Expand Down Expand Up @@ -1646,6 +1638,13 @@ void nsSocketTransportService::GetSocketConnections(
AnalyzeConnection(data, &mIdleList[i], false);
}

bool
nsSocketTransportService::IsTelemetryEnabledAndNotSleepPhase()
{
return Telemetry::CanRecordPrereleaseData() &&
!mSleepPhase;
}

#if defined(XP_WIN)
void nsSocketTransportService::StartPollWatchdog() {
// Start off the timer from a runnable off of the main thread in order to
Expand Down
5 changes: 1 addition & 4 deletions netwerk/base/nsSocketTransportService2.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,7 @@ class nsSocketTransportService final : public nsPISocketTransportService,
// Returns true if keepalives are enabled in prefs.
bool IsKeepaliveEnabled() { return mKeepaliveEnabledPref; }

bool IsTelemetryEnabledAndNotSleepPhase() {
return mTelemetryEnabledPref && !mSleepPhase;
}
bool IsTelemetryEnabledAndNotSleepPhase();
PRIntervalTime MaxTimeForPrClosePref() { return mMaxTimeForPrClosePref; }

bool IsEsniEnabled() {
Expand Down Expand Up @@ -260,7 +258,6 @@ class nsSocketTransportService final : public nsPISocketTransportService,

Atomic<bool> mServingPendingQueue;
Atomic<int32_t, Relaxed> mMaxTimePerPollIter;
Atomic<bool, Relaxed> mTelemetryEnabledPref;
Atomic<PRIntervalTime, Relaxed> mMaxTimeForPrClosePref;
// Timestamp of the last network link change event, tracked
// also on child processes.
Expand Down
2 changes: 1 addition & 1 deletion netwerk/protocol/http/HttpBaseChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1243,7 +1243,7 @@ HttpBaseChannel::DoApplyContentConversions(nsIStreamListener* aNextListener,
}

LOG(("converter removed '%s' content-encoding\n", val));
if (gHttpHandler->IsTelemetryEnabled()) {
if (Telemetry::CanRecordPrereleaseData()) {
int mode = 0;
if (from.EqualsLiteral("gzip") || from.EqualsLiteral("x-gzip")) {
mode = 1;
Expand Down
4 changes: 2 additions & 2 deletions netwerk/protocol/http/nsHttpChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2133,7 +2133,7 @@ nsresult nsHttpChannel::ProcessResponse() {
mConnectionInfo->EndToEndSSL());
}

if (gHttpHandler->IsTelemetryEnabled()) {
if (Telemetry::CanRecordPrereleaseData()) {
// how often do we see something like Alt-Svc: "443:quic,p=1"
nsAutoCString alt_service;
Unused << mResponseHead->GetHeader(nsHttp::Alternate_Service, alt_service);
Expand Down Expand Up @@ -2502,7 +2502,7 @@ nsresult nsHttpChannel::ContinueProcessResponse2(nsresult rv) {
}
}

if (gHttpHandler->IsTelemetryEnabled()) {
if (Telemetry::CanRecordPrereleaseData()) {
CacheDisposition cacheDisposition;
if (!mDidReval) {
cacheDisposition = kCacheMissed;
Expand Down
4 changes: 2 additions & 2 deletions netwerk/protocol/http/nsHttpChannelAuthProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ nsresult nsHttpChannelAuthProvider::GetCredentialsForChallenge(

// Collect statistics on how frequently the various types of HTTP
// authentication are used over SSL and non-SSL connections.
if (gHttpHandler->IsTelemetryEnabled()) {
if (Telemetry::CanRecordPrereleaseData()) {
if (NS_LITERAL_CSTRING("basic").LowerCaseEqualsASCII(authType)) {
Telemetry::Accumulate(
Telemetry::HTTP_AUTH_TYPE_STATS,
Expand Down Expand Up @@ -943,7 +943,7 @@ bool nsHttpChannelAuthProvider::BlockPrompt(bool proxyAuth) {
}
}

if (gHttpHandler->IsTelemetryEnabled()) {
if (Telemetry::CanRecordPrereleaseData()) {
if (topDoc) {
Telemetry::Accumulate(Telemetry::HTTP_AUTH_DIALOG_STATS_3,
HTTP_AUTH_DIALOG_TOP_LEVEL_DOC);
Expand Down
30 changes: 0 additions & 30 deletions netwerk/protocol/http/nsHttpHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@
#define BROWSER_PREF_PREFIX "browser.cache."
#define DONOTTRACK_HEADER_ENABLED "privacy.donottrackheader.enabled"
#define H2MANDATORY_SUITE "security.ssl3.ecdhe_rsa_aes_128_gcm_sha256"
#define TELEMETRY_ENABLED "toolkit.telemetry.enabled"
#define ALLOW_EXPERIMENTS "network.allow-experiments"
#define SAFE_HINT_HEADER_VALUE "safeHint.enabled"
#define SECURITY_PREFIX "security."

Expand Down Expand Up @@ -245,8 +243,6 @@ nsHttpHandler::nsHttpHandler()
mSafeHintEnabled(false),
mParentalControlEnabled(false),
mHandlerActive(false),
mTelemetryEnabled(false),
mAllowExperiments(true),
mDebugObservations(false),
mEnableSpdy(false),
mHttp2Enabled(true),
Expand Down Expand Up @@ -430,7 +426,6 @@ static const char *gCallbackPrefs[] = {
INTL_ACCEPT_LANGUAGES,
BROWSER_PREF("disk_cache_ssl"),
DONOTTRACK_HEADER_ENABLED,
TELEMETRY_ENABLED,
H2MANDATORY_SUITE,
HTTP_PREF("tcp_keepalive.short_lived_connections"),
HTTP_PREF("tcp_keepalive.long_lived_connections"),
Expand Down Expand Up @@ -1762,19 +1757,6 @@ void nsHttpHandler::PrefsChanged(const char *pref) {
// includes telemetry and allow-experiments because of the abtest profile
bool requestTokenBucketUpdated = false;

//
// Telemetry
//

if (PREF_CHANGED(TELEMETRY_ENABLED)) {
cVar = false;
requestTokenBucketUpdated = true;
rv = Preferences::GetBool(TELEMETRY_ENABLED, &cVar);
if (NS_SUCCEEDED(rv)) {
mTelemetryEnabled = cVar;
}
}

// "security.ssl3.ecdhe_rsa_aes_128_gcm_sha256" is the required h2 interop
// suite.

Expand All @@ -1786,18 +1768,6 @@ void nsHttpHandler::PrefsChanged(const char *pref) {
}
}

//
// network.allow-experiments
//
if (PREF_CHANGED(ALLOW_EXPERIMENTS)) {
cVar = true;
requestTokenBucketUpdated = true;
rv = Preferences::GetBool(ALLOW_EXPERIMENTS, &cVar);
if (NS_SUCCEEDED(rv)) {
mAllowExperiments = cVar;
}
}

// network.http.debug-observations
if (PREF_CHANGED("network.http.debug-observations")) {
cVar = false;
Expand Down
10 changes: 1 addition & 9 deletions netwerk/protocol/http/nsHttpHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,7 @@ class nsHttpHandler final : public nsIHttpProtocolHandler,
bool IsPersistentHttpsCachingEnabled() {
return mEnablePersistentHttpsCaching;
}
bool IsTelemetryEnabled() { return mTelemetryEnabled; }
bool AllowExperiments() { return mTelemetryEnabled && mAllowExperiments; }


bool IsSpdyEnabled() { return mEnableSpdy; }
bool IsHttp2Enabled() { return mHttp2Enabled; }
bool EnforceHttp2TlsProfile() { return mEnforceHttp2TlsProfile; }
Expand Down Expand Up @@ -547,12 +545,6 @@ class nsHttpHandler final : public nsIHttpProtocolHandler,
// true in between init and shutdown states
Atomic<bool, Relaxed> mHandlerActive;

// Whether telemetry is reported or not
uint32_t mTelemetryEnabled : 1;

// The value of network.allow-experiments
uint32_t mAllowExperiments : 1;

// The value of 'hidden' network.http.debug-observations : 1;
uint32_t mDebugObservations : 1;

Expand Down

0 comments on commit 2ebce46

Please sign in to comment.