mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 686948 - Add telemetry for cache hit/miss with/without revalidation. r=mcmanus
This commit is contained in:
parent
d5d803ecae
commit
fd8a1a0f75
@ -66,6 +66,7 @@
|
||||
#include "nsChannelClassifier.h"
|
||||
#include "nsIRedirectResultListener.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
|
||||
// True if the local cache should be bypassed when processing a request.
|
||||
#define BYPASS_LOCAL_CACHE(loadFlags) \
|
||||
@ -128,6 +129,7 @@ nsHttpChannel::nsHttpChannel()
|
||||
, mFallingBack(PR_FALSE)
|
||||
, mWaitingForRedirectCallback(PR_FALSE)
|
||||
, mRequestTimeInitialized(PR_FALSE)
|
||||
, mDidReval(false)
|
||||
{
|
||||
LOG(("Creating nsHttpChannel [this=%p]\n", this));
|
||||
mChannelCreationTime = PR_Now();
|
||||
@ -267,6 +269,8 @@ nsHttpChannel::Connect(PRBool firstTime)
|
||||
if (NS_FAILED(rv) && event) {
|
||||
event->Revoke();
|
||||
}
|
||||
mozilla::Telemetry::Accumulate(
|
||||
mozilla::Telemetry::HTTP_CACHE_DISPOSITION, kCacheHit);
|
||||
return rv;
|
||||
}
|
||||
else if (mLoadFlags & LOAD_ONLY_FROM_CACHE) {
|
||||
@ -974,6 +978,8 @@ nsHttpChannel::ProcessResponse()
|
||||
LOG((" continuation state has been reset"));
|
||||
}
|
||||
|
||||
bool successfulReval = false;
|
||||
|
||||
// handle different server response categories. Note that we handle
|
||||
// caching or not caching of error pages in
|
||||
// nsHttpResponseHead::MustValidate; if you change this switch, update that
|
||||
@ -1025,6 +1031,9 @@ nsHttpChannel::ProcessResponse()
|
||||
LOG(("ProcessNotModified failed [rv=%x]\n", rv));
|
||||
rv = ProcessNormal();
|
||||
}
|
||||
else {
|
||||
successfulReval = true;
|
||||
}
|
||||
break;
|
||||
case 401:
|
||||
case 407:
|
||||
@ -1060,6 +1069,17 @@ nsHttpChannel::ProcessResponse()
|
||||
break;
|
||||
}
|
||||
|
||||
if (!mDidReval)
|
||||
mozilla::Telemetry::Accumulate(
|
||||
mozilla::Telemetry::HTTP_CACHE_DISPOSITION, kCacheMissed);
|
||||
else if (successfulReval)
|
||||
mozilla::Telemetry::Accumulate(
|
||||
mozilla::Telemetry::HTTP_CACHE_DISPOSITION, kCacheHitViaReval);
|
||||
else
|
||||
mozilla::Telemetry::Accumulate(
|
||||
mozilla::Telemetry::HTTP_CACHE_DISPOSITION,
|
||||
kCacheMissedViaReval);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -2666,6 +2686,7 @@ nsHttpChannel::CheckCache()
|
||||
if (val)
|
||||
mRequestHead.SetHeader(nsHttp::If_None_Match,
|
||||
nsDependentCString(val));
|
||||
mDidReval = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -366,6 +366,15 @@ private:
|
||||
|
||||
protected:
|
||||
virtual void DoNotifyListenerCleanup();
|
||||
|
||||
private: // cache telemetry
|
||||
enum {
|
||||
kCacheHit = 1,
|
||||
kCacheHitViaReval = 2,
|
||||
kCacheMissedViaReval = 3,
|
||||
kCacheMissed = 4
|
||||
};
|
||||
bool mDidReval;
|
||||
};
|
||||
|
||||
#endif // nsHttpChannel_h__
|
||||
|
@ -132,6 +132,9 @@ HTTP_HISTOGRAMS(SUB, "subitem: ")
|
||||
|
||||
#undef _HTTP_HIST
|
||||
#undef HTTP_HISTOGRAMS
|
||||
|
||||
HISTOGRAM(HTTP_CACHE_DISPOSITION, 1, 5, 5, LINEAR, "HTTP Cache Hit, Reval, Failed-Reval, Miss")
|
||||
|
||||
HISTOGRAM(FIND_PLUGINS, 1, 3000, 10, EXPONENTIAL, "Time spent scanning filesystem for plugins (ms)")
|
||||
HISTOGRAM(CHECK_JAVA_ENABLED, 1, 3000, 10, EXPONENTIAL, "Time spent checking if Java is enabled (ms)")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user