Bug 1029760 - Modified inner predictor telemetry counters so data would persist. r=hurley

This commit is contained in:
Jeremy Poulin 2014-06-24 14:16:10 -07:00
parent 5871469922
commit a61533480e
2 changed files with 30 additions and 35 deletions

View File

@ -121,21 +121,6 @@ const long STARTUP_WINDOW = 5L * 60L * 1000000L; // 5min
// Version for the database schema
static const int32_t PREDICTOR_SCHEMA_VERSION = 1;
struct PredictorTelemetryAccumulators {
Telemetry::AutoCounter<Telemetry::PREDICTOR_PREDICT_ATTEMPTS> mPredictAttempts;
Telemetry::AutoCounter<Telemetry::PREDICTOR_LEARN_ATTEMPTS> mLearnAttempts;
Telemetry::AutoCounter<Telemetry::PREDICTOR_PREDICT_FULL_QUEUE> mPredictFullQueue;
Telemetry::AutoCounter<Telemetry::PREDICTOR_LEARN_FULL_QUEUE> mLearnFullQueue;
Telemetry::AutoCounter<Telemetry::PREDICTOR_TOTAL_PREDICTIONS> mTotalPredictions;
Telemetry::AutoCounter<Telemetry::PREDICTOR_TOTAL_PRECONNECTS> mTotalPreconnects;
Telemetry::AutoCounter<Telemetry::PREDICTOR_TOTAL_PRERESOLVES> mTotalPreresolves;
Telemetry::AutoCounter<Telemetry::PREDICTOR_PREDICTIONS_CALCULATED> mPredictionsCalculated;
Telemetry::AutoCounter<Telemetry::PREDICTOR_LOAD_COUNT_IS_ZERO> mLoadCountZeroes;
Telemetry::AutoCounter<Telemetry::PREDICTOR_LOAD_COUNT_OVERFLOWS> mLoadCountOverflows;
Telemetry::AutoCounter<Telemetry::PREDICTOR_STARTUP_COUNT_IS_ZERO> mStartupCountZeroes;
Telemetry::AutoCounter<Telemetry::PREDICTOR_STARTUP_COUNT_OVERFLOWS> mStartupCountOverflows;
};
// Listener for the speculative DNS requests we'll fire off, which just ignores
// the result (since we're just trying to warm the cache). This also exists to
// reduce round-trips to the main thread, by being something threadsafe the
@ -456,8 +441,6 @@ Predictor::Init()
mStartupTime = PR_Now();
mAccumulators = new PredictorTelemetryAccumulators();
rv = InstallObserver();
NS_ENSURE_SUCCESS(rv, rv);
@ -677,7 +660,8 @@ Predictor::EnsureInitStorage()
if (newStartupCount <= 0) {
PREDICTOR_LOG(("Predictor::EnsureInitStorage startup count overflow\n"));
newStartupCount = mStartupCount;
++mAccumulators->mStartupCountOverflows;
Telemetry::AutoCounter<Telemetry::PREDICTOR_STARTUP_COUNT_OVERFLOWS> startupCountOverflows;
++startupCountOverflows;
}
rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("startup_count"),
@ -1083,9 +1067,10 @@ public:
if (NS_FAILED(rv)) {
continue;
}
++gPredictor->mAccumulators->mTotalPredictions;
++gPredictor->mAccumulators->mTotalPreconnects;
Telemetry::AutoCounter<Telemetry::PREDICTOR_TOTAL_PREDICTIONS> totalPredictions;
Telemetry::AutoCounter<Telemetry::PREDICTOR_TOTAL_PRECONNECTS> totalPreconnects;
++totalPredictions;
++totalPreconnects;
gPredictor->mSpeculativeService->SpeculativeConnect(uri, gPredictor);
if (mVerifier) {
mVerifier->OnPredictPreconnect(uri);
@ -1101,8 +1086,10 @@ public:
continue;
}
++gPredictor->mAccumulators->mTotalPredictions;
++gPredictor->mAccumulators->mTotalPreresolves;
Telemetry::AutoCounter<Telemetry::PREDICTOR_TOTAL_PREDICTIONS> totalPredictions;
Telemetry::AutoCounter<Telemetry::PREDICTOR_TOTAL_PRERESOLVES> totalPreresolves;
++totalPredictions;
++totalPreresolves;
nsAutoCString hostname;
uri->GetAsciiHost(hostname);
nsCOMPtr<nsICancelable> tmpCancelable;
@ -1171,7 +1158,8 @@ int
Predictor::CalculateConfidence(int baseConfidence, PRTime lastHit,
PRTime lastPossible, int globalDegradation)
{
++mAccumulators->mPredictionsCalculated;
Telemetry::AutoCounter<Telemetry::PREDICTOR_PREDICTIONS_CALCULATED> predictionsCalculated;
++predictionsCalculated;
int maxConfidence = 100;
int confidenceDegradation = 0;
@ -1333,7 +1321,8 @@ Predictor::UpdateTopLevel(QueryType queryType, const TopLevelInfo &info,
PREDICTOR_LOG(("Predictor::UpdateTopLevel type %d id %d load count "
"overflow\n", queryType, info.id));
newLoadCount = info.loadCount;
++mAccumulators->mLoadCountOverflows;
Telemetry::AutoCounter<Telemetry::PREDICTOR_LOAD_COUNT_OVERFLOWS> loadCountOverflows;
++loadCountOverflows;
}
// First, let's update the page in the database, since loading a page
@ -1365,7 +1354,8 @@ Predictor::TryPredict(QueryType queryType, const TopLevelInfo &info, PRTime now,
if (!info.loadCount) {
PREDICTOR_LOG(("Predictor::TryPredict info.loadCount is zero!\n"));
++mAccumulators->mLoadCountZeroes;
Telemetry::AutoCounter<Telemetry::PREDICTOR_LOAD_COUNT_IS_ZERO> loadCountZeroes;
++loadCountZeroes;
return false;
}
@ -1451,7 +1441,8 @@ Predictor::WouldRedirect(const TopLevelInfo &info, PRTime now, UriInfo &newUri)
if (!info.loadCount) {
PREDICTOR_LOG(("Predictor::WouldRedirect info.loadCount is zero!\n"));
++mAccumulators->mLoadCountZeroes;
Telemetry::AutoCounter<Telemetry::PREDICTOR_LOAD_COUNT_IS_ZERO> loadCountZeroes;
++loadCountZeroes;
return false;
}
@ -1589,7 +1580,8 @@ Predictor::PredictForStartup(PredictorVerifierHandle &verifier,
if (!mStartupCount) {
PREDICTOR_LOG(("Predictor::PredictForStartup mStartupCount is zero!\n"));
++mAccumulators->mStartupCountZeroes;
Telemetry::AutoCounter<Telemetry::PREDICTOR_STARTUP_COUNT_IS_ZERO> startupCountZeroes;
++startupCountZeroes;
return;
}
@ -1750,10 +1742,13 @@ Predictor::Predict(nsIURI *targetURI, nsIURI *sourceURI,
return NS_ERROR_INVALID_ARG;
}
++mAccumulators->mPredictAttempts;
Telemetry::AutoCounter<Telemetry::PREDICTOR_PREDICT_ATTEMPTS> predictAttempts;
++predictAttempts;
nsresult rv = ReserveSpaceInQueue();
if (NS_FAILED(rv)) {
++mAccumulators->mPredictFullQueue;
Telemetry::AutoCounter<Telemetry::PREDICTOR_PREDICT_FULL_QUEUE> predictFullQueue;
++predictFullQueue;
return NS_ERROR_NOT_AVAILABLE;
}
@ -2266,10 +2261,13 @@ Predictor::Learn(nsIURI *targetURI, nsIURI *sourceURI,
return NS_ERROR_INVALID_ARG;
}
++mAccumulators->mLearnAttempts;
Telemetry::AutoCounter<Telemetry::PREDICTOR_LEARN_ATTEMPTS> learnAttempts;
++learnAttempts;
nsresult rv = ReserveSpaceInQueue();
if (NS_FAILED(rv)) {
++mAccumulators->mLearnFullQueue;
Telemetry::AutoCounter<Telemetry::PREDICTOR_LEARN_FULL_QUEUE> learnFullQueue;
++learnFullQueue;
return NS_ERROR_NOT_AVAILABLE;
}

View File

@ -33,7 +33,6 @@ namespace net {
typedef nsMainThreadPtrHandle<nsINetworkPredictorVerifier> PredictorVerifierHandle;
class PredictionRunner;
struct PredictorTelemetryAccumulators;
class PredictorDNSListener;
class Predictor : public nsINetworkPredictor
@ -222,8 +221,6 @@ private:
int32_t mQueueSize;
mozilla::Mutex mQueueSizeLock;
nsAutoPtr<PredictorTelemetryAccumulators> mAccumulators;
nsRefPtr<PredictorDNSListener> mDNSListener;
nsCOMPtr<nsITimer> mCommitTimer;