bug 850968 - backout cache experiment for causing 858588 r=backout

This commit is contained in:
Patrick McManus 2013-04-05 15:50:31 -04:00
parent 0be6cad5ea
commit 9496e70780
7 changed files with 6 additions and 182 deletions

View File

@ -4399,7 +4399,6 @@ nsHttpChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *context)
// that to complete would mean we don't include proxy resolution in the
// timing.
mAsyncOpenTime = TimeStamp::Now();
mCacheEffectExperimentAsyncOpenTime = mAsyncOpenTime;
// the only time we would already know the proxy information at this
// point would be if we were proxying a non-http protocol like ftp
@ -5105,15 +5104,7 @@ nsHttpChannel::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult st
CleanRedirectCacheChainIfNecessary();
ReleaseListeners();
// If enabled, record the cache effect experiment data
if (NS_SUCCEEDED(status) && contentComplete && !mCanceled) {
Telemetry::ID telemID = gHttpHandler->mCacheEffectExperimentTelemetryID;
if (telemID != nsHttpHandler::kNullTelemetryID) {
Telemetry::AccumulateTimeDelta(telemID,
mCacheEffectExperimentAsyncOpenTime);
}
}
return NS_OK;
}

View File

@ -365,10 +365,6 @@ private:
void PushRedirectAsyncFunc(nsContinueRedirectionFunc func);
void PopRedirectAsyncFunc(nsContinueRedirectionFunc func);
// perform experiment to determine efficiency of cache strategy
// vs pure network
mozilla::TimeStamp mCacheEffectExperimentAsyncOpenTime;
protected:
virtual void DoNotifyListenerCleanup();

View File

@ -2662,7 +2662,7 @@ nsHttpConnectionMgr::nsHalfOpenSocket::SetupPrimaryStreams()
getter_AddRefs(mStreamIn),
getter_AddRefs(mStreamOut),
false);
LOG(("nsHalfOpenSocket::SetupPrimaryStreams [this=%p ent=%s rv=%x]",
LOG(("nsHalfOpenSocket::SetupPrimaryStream [this=%p ent=%s rv=%x]",
this, mEnt->mConnInfo->Host(), rv));
if (NS_FAILED(rv)) {
if (mStreamOut)
@ -2811,17 +2811,13 @@ nsHalfOpenSocket::OnOutputStreamReady(nsIAsyncOutputStream *out)
nsCOMPtr<nsIInterfaceRequestor> callbacks;
mTransaction->GetSecurityCallbacks(getter_AddRefs(callbacks));
if (out == mStreamOut) {
if (static_cast<uint32_t>(mPrimarySynRTT.ToMilliseconds()) <= 125)
gHttpHandler->mCacheEffectExperimentFastConn++;
else
gHttpHandler->mCacheEffectExperimentSlowConn++;
TimeDuration rtt = TimeStamp::Now() - mPrimarySynStarted;
rv = conn->Init(mEnt->mConnInfo,
gHttpHandler->ConnMgr()->mMaxRequestDelay,
mSocketTransport, mStreamIn, mStreamOut,
callbacks,
PR_MillisecondsToInterval(
static_cast<uint32_t>(mPrimarySynRTT.ToMilliseconds())));
static_cast<uint32_t>(rtt.ToMilliseconds())));
if (NS_SUCCEEDED(mSocketTransport->GetPeerAddr(&peeraddr)))
mEnt->RecordIPFamilyPreference(peeraddr.raw.family);
@ -2931,7 +2927,6 @@ nsHttpConnectionMgr::nsHalfOpenSocket::OnTransportStatus(nsITransport *trans,
if (mTransaction)
mTransaction->OnTransportStatus(trans, status, progress);
// Do not process status events for the backup transport
if (trans != mSocketTransport)
return NS_OK;
@ -2980,21 +2975,14 @@ nsHttpConnectionMgr::nsHalfOpenSocket::OnTransportStatus(nsITransport *trans,
// nsHttpConnectionMgr::Shutdown and nsSocketTransportService::Shutdown
// where the first abandones all half open socket instances and only
// after that the second stops the socket thread.
if (mEnt) {
// update timestamp to get a more accurate rtt
mPrimarySynStarted = TimeStamp::Now();
if (!mBackupTransport && !mSynTimer)
SetupBackupTimer();
}
if (mEnt && !mBackupTransport && !mSynTimer)
SetupBackupTimer();
break;
case NS_NET_STATUS_CONNECTED_TO:
// TCP connection's up, now transfer or SSL negotiantion starts,
// no need for backup socket
CancelBackupTimer();
if (mEnt && !mPrimarySynStarted.IsNull())
mPrimarySynRTT = TimeStamp::Now() - mPrimarySynStarted;
break;
default:

View File

@ -451,7 +451,6 @@ private:
bool mSpeculative;
mozilla::TimeStamp mPrimarySynStarted;
mozilla::TimeDuration mPrimarySynRTT;
mozilla::TimeStamp mBackupSynStarted;
// for syn retry

View File

@ -37,7 +37,6 @@
#include "nsAlgorithm.h"
#include "ASpdySession.h"
#include "mozIApplicationClearPrivateDataParams.h"
#include "nsIRandomGenerator.h"
#include "nsIXULAppInfo.h"
@ -188,10 +187,6 @@ nsHttpHandler::nsHttpHandler()
, mConnectTimeout(90000)
, mParallelSpeculativeConnectLimit(6)
, mCritialRequestPrioritization(true)
, mCacheEffectExperimentTelemetryID(kNullTelemetryID)
, mCacheEffectExperimentOnce(false)
, mCacheEffectExperimentSlowConn(0)
, mCacheEffectExperimentFastConn(0)
{
#if defined(PR_LOGGING)
gHttpLog = PR_NewLogModule("nsHttp");
@ -221,10 +216,6 @@ nsHttpHandler::~nsHttpHandler()
mPipelineTestTimer->Cancel();
mPipelineTestTimer = nullptr;
}
if (mCacheEffectExperimentTimer) {
mCacheEffectExperimentTimer->Cancel();
mCacheEffectExperimentTimer = nullptr;
}
gHttpHandler = nullptr;
}
@ -1247,23 +1238,6 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref)
if (NS_SUCCEEDED(rv)) {
mAllowExperiments = cVar;
}
if (!mCacheEffectExperimentOnce) {
mCacheEffectExperimentOnce = true;
// Start the Cache Efficacy Experiment for testing channels
#ifdef MOZ_TELEMETRY_ON_BY_DEFAULT
if (mAllowExperiments) {
if (mCacheEffectExperimentTimer)
mCacheEffectExperimentTimer->Cancel();
mCacheEffectExperimentTimer = do_CreateInstance("@mozilla.org/timer;1");
if (mCacheEffectExperimentTimer)
mCacheEffectExperimentTimer->InitWithFuncCallback(
StartCacheExperiment, this, kExperimentStartupDelay,
nsITimer::TYPE_ONE_SHOT);
}
#endif
}
}
//
@ -1313,82 +1287,6 @@ nsHttpHandler::TimerCallback(nsITimer * aTimer, void * aClosure)
thisObject->mCapabilities &= ~NS_HTTP_ALLOW_PIPELINING;
}
void
nsHttpHandler::FinishCacheExperiment(nsITimer * aTimer, void * aClosure)
{
nsRefPtr<nsHttpHandler> self = static_cast<nsHttpHandler*>(aClosure);
self->mCacheEffectExperimentTimer = nullptr;
// The experiment is over.
self->mCacheEffectExperimentTelemetryID = kNullTelemetryID;
self->mUseCache = true;
LOG(("Cache Effect Experiment Complete\n"));
}
// The Cache Effect Experiment selects 1 of 16 sessions and divides them
// into equal groups of cache enabled and cache disabled for a few minutes.
// Sessions that already have their cache disabled are not selected.
// During the time of the experiment we measure transaction times from the time
// of channel::AsyncOpen() to the time OnStopRequest() is called. Results are
// recorded for the matrix of {cacheEnabled, Fast/Slow-Connection}. We
// intentionally don't record whether the cache was hit for a particular
// transaction - just whether or not it was enabled in order to get a
// feel for whether or not the cache helps overall performance.
//
void
nsHttpHandler::StartCacheExperiment(nsITimer * aTimer, void * aClosure)
{
nsRefPtr<nsHttpHandler> self = static_cast<nsHttpHandler*>(aClosure);
if (!self->AllowExperiments())
return;
if (!self->mUseCache)
return;
if (!(self->mCacheEffectExperimentFastConn + self->mCacheEffectExperimentSlowConn))
return;
bool selected = false;
bool disableCache = false;
uint8_t *buffer;
nsCOMPtr<nsIRandomGenerator> randomGenerator =
do_GetService("@mozilla.org/security/random-generator;1");
if (randomGenerator &&
NS_SUCCEEDED(randomGenerator->GenerateRandomBytes(1, &buffer))) {
if (!((*buffer) & 0x0f))
selected = true;
if (!((*buffer) & 0x10))
disableCache = true;
NS_Free(buffer);
}
if (!selected)
return;
if (disableCache)
self->mUseCache = false;
// consider this a fast connection if 1/3 of the connects are fast.
bool isFast = (self->mCacheEffectExperimentFastConn * 2) >= self->mCacheEffectExperimentSlowConn;
if (self->mUseCache) {
if (isFast)
self->mCacheEffectExperimentTelemetryID = Telemetry::HTTP_TRANSACTION_TIME_CONNFAST_CACHEON;
else
self->mCacheEffectExperimentTelemetryID = Telemetry::HTTP_TRANSACTION_TIME_CONNSLOW_CACHEON;
}
else {
if (isFast)
self->mCacheEffectExperimentTelemetryID = Telemetry::HTTP_TRANSACTION_TIME_CONNFAST_CACHEOFF;
else
self->mCacheEffectExperimentTelemetryID = Telemetry::HTTP_TRANSACTION_TIME_CONNSLOW_CACHEOFF;
}
LOG(("Cache Effect Experiment Started ID=%X\n", self->mCacheEffectExperimentTelemetryID));
self->mCacheEffectExperimentTimer->InitWithFuncCallback(
FinishCacheExperiment, self, kExperimentStartupDuration,
nsITimer::TYPE_ONE_SHOT);
}
/**
* Allocates a C string into that contains a ISO 639 language list
* notated with HTTP "q" values for output with a HTTP Accept-Language

View File

@ -16,7 +16,6 @@
#include "nsString.h"
#include "nsCOMPtr.h"
#include "nsWeakReference.h"
#include "mozilla/Telemetry.h"
#include "nsIHttpProtocolHandler.h"
#include "nsIProtocolProxyService.h"
@ -412,25 +411,6 @@ private:
// Whether or not to block requests for non head js/css items (e.g. media)
// while those elements load.
bool mCritialRequestPrioritization;
public:
// For the Cache Effect Experiment (see StartCacheExperiment in cpp)
static void StartCacheExperiment(nsITimer * aTimer, void * aClosure);
static void FinishCacheExperiment(nsITimer * aTimer, void * aClosure);
const static uint32_t kExperimentStartupDelay = 1000 * 60 * 2; // 2 mins
const static uint32_t kExperimentStartupDuration = 1000 * 60 * 15; // 15 mins
const static mozilla::Telemetry::ID kNullTelemetryID = static_cast<mozilla::Telemetry::ID>(0);
mozilla::Telemetry::ID mCacheEffectExperimentTelemetryID;
bool mCacheEffectExperimentOnce;
nsCOMPtr<nsITimer> mCacheEffectExperimentTimer;
// only update these on the socket thread, but reading them from the main thread is ok
uint64_t mCacheEffectExperimentSlowConn;
uint64_t mCacheEffectExperimentFastConn;
};
//-----------------------------------------------------------------------------

View File

@ -1972,34 +1972,6 @@
"extended_statistics_ok": true,
"description": "Time spent in nsDiskCacheStreamIO::Close() on the main thread (ms)"
},
"HTTP_TRANSACTION_TIME_CONNFAST_CACHEON": {
"kind": "exponential",
"high": "10000",
"n_buckets": 50,
"extended_statistics_ok": true,
"description": "ms from ayncopen to onStopRequest for fast connections with cache enabled"
},
"HTTP_TRANSACTION_TIME_CONNFAST_CACHEOFF": {
"kind": "exponential",
"high": "10000",
"n_buckets": 50,
"extended_statistics_ok": true,
"description": "ms from ayncopen to onStopRequest for fast connections with cache disabled"
},
"HTTP_TRANSACTION_TIME_CONNSLOW_CACHEON": {
"kind": "exponential",
"high": "10000",
"n_buckets": 50,
"extended_statistics_ok": true,
"description": "ms from ayncopen to onStopRequest for slow connections with cache enabled"
},
"HTTP_TRANSACTION_TIME_CONNSLOW_CACHEOFF": {
"kind": "exponential",
"high": "10000",
"n_buckets": 50,
"extended_statistics_ok": true,
"description": "ms from ayncopen to onStopRequest for slow connections with cache disabled"
},
"IDLE_NOTIFY_BACK_MS": {
"kind": "exponential",
"high": "5000",