Bug 1505948: Add cache info to network profiler markers r=mstange,nwgh

This commit is contained in:
Randell Jesup 2018-11-14 15:54:22 -05:00
Родитель a37d80eed4
Коммит 286dfeada3
9 изменённых файлов: 55 добавлений и 14 удалений

Просмотреть файл

@ -74,6 +74,15 @@ extern mozilla::LazyLogModule gHttpLog;
typedef nsTArray<Tuple<nsCString, nsCString>> ArrayOfStringPairs;
enum CacheDisposition : uint8_t {
kCacheUnresolved = 0,
kCacheHit = 1,
kCacheHitViaReval = 2,
kCacheMissedViaReval = 3,
kCacheMissed = 4,
kCacheUnknown = 5
};
/*
* This class is a partial implementation of nsIHttpChannel. It contains code
* shared by nsHttpChannel and HttpChannelChild.

Просмотреть файл

@ -1231,6 +1231,7 @@ HttpChannelChild::OnStopRequest(const nsresult& channelStatus,
profiler_add_network_marker(mURI, priority, mChannelId, NetworkLoadType::LOAD_STOP,
mLastStatusReported, TimeStamp::Now(),
mTransferSize,
kCacheUnknown,
&mTransactionTimings);
}
#endif
@ -1881,7 +1882,7 @@ HttpChannelChild::Redirect1Begin(const uint32_t& registrarId,
PROFILER_ADD_NETWORK_MARKER(mURI, mPriority, channelId, NetworkLoadType::LOAD_REDIRECT,
mLastStatusReported, TimeStamp::Now(),
0,
0, kCacheUnknown,
&mTransactionTimings,
uri);
@ -2676,7 +2677,7 @@ HttpChannelChild::AsyncOpen(nsIStreamListener *listener, nsISupports *aContext)
mLastStatusReported = TimeStamp::Now();
PROFILER_ADD_NETWORK_MARKER(mURI, mPriority, mChannelId, NetworkLoadType::LOAD_START,
mChannelCreationTimestamp, mLastStatusReported,
0, nullptr, nullptr);
0, kCacheUnknown, nullptr, nullptr);
mIsPending = true;
mWasOpened = true;

Просмотреть файл

@ -162,13 +162,6 @@ static uint32_t sRCWNMaxWaitMs = 500;
static NS_DEFINE_CID(kStreamListenerTeeCID, NS_STREAMLISTENERTEE_CID);
enum CacheDisposition {
kCacheHit = 1,
kCacheHitViaReval = 2,
kCacheMissedViaReval = 3,
kCacheMissed = 4
};
using mozilla::Telemetry::LABELS_DOCUMENT_ANALYTICS_TRACKER_FASTBLOCKED;
static const struct {
@ -331,6 +324,7 @@ AutoRedirectVetoNotifier::ReportRedirectResult(bool succeeded)
nsHttpChannel::nsHttpChannel()
: HttpAsyncAborter<nsHttpChannel>(this)
, mCacheDisposition(kCacheUnresolved)
, mLogicalOffset(0)
, mPostID(0)
, mRequestTime(0)
@ -942,6 +936,7 @@ nsHttpChannel::ContinueConnect()
}
AccumulateCacheHitTelemetry(kCacheHit);
mCacheDisposition = kCacheHit;
return rv;
}
@ -2749,6 +2744,7 @@ nsHttpChannel::ContinueProcessResponse2(nsresult rv)
cacheDisposition = kCacheMissedViaReval;
}
AccumulateCacheHitTelemetry(cacheDisposition);
mCacheDisposition = cacheDisposition;
Telemetry::Accumulate(Telemetry::HTTP_RESPONSE_VERSION,
static_cast<uint32_t>(mResponseHead->Version()));
@ -5893,7 +5889,7 @@ nsHttpChannel::ContinueProcessRedirectionAfterFallback(nsresult rv)
GetPriority(&priority);
profiler_add_network_marker(mURI, priority, mChannelId, NetworkLoadType::LOAD_REDIRECT,
mLastStatusReported, TimeStamp::Now(),
mLogicalOffset, nullptr,
mLogicalOffset, mCacheDisposition, nullptr,
mRedirectURI);
}
#endif
@ -6348,7 +6344,7 @@ nsHttpChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *context)
if (profiler_is_active()) {
profiler_add_network_marker(mURI, mPriority, mChannelId, NetworkLoadType::LOAD_START,
mChannelCreationTimestamp, mLastStatusReported,
0);
0, mCacheDisposition);
}
#endif
@ -7738,7 +7734,7 @@ nsHttpChannel::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult st
profiler_add_network_marker(uri, priority, mChannelId, NetworkLoadType::LOAD_STOP,
mLastStatusReported, TimeStamp::Now(),
mLogicalOffset,
&mTransactionTimings);
mCacheDisposition, &mTransactionTimings, nullptr);
}
#endif

Просмотреть файл

@ -286,6 +286,8 @@ public:
already_AddRefed<TabPromise> TakeRedirectTabPromise() { return mRedirectTabPromise.forget(); }
uint64_t CrossProcessRedirectIdentifier() { return mCrossProcessRedirectIdentifier; }
CacheDisposition mCacheDisposition;
protected:
virtual ~nsHttpChannel();

Просмотреть файл

@ -12,6 +12,7 @@
#include "Layers.h"
#include "mozilla/Sprintf.h"
#include "mozilla/Maybe.h"
#include "mozilla/net/HttpBaseChannel.h"
using namespace mozilla;
@ -156,6 +157,25 @@ static const char *GetNetworkState(NetworkLoadType aType)
return "";
}
static const char *GetCacheState(mozilla::net::CacheDisposition aCacheDisposition)
{
switch (aCacheDisposition) {
case mozilla::net::kCacheUnresolved:
return "Unresolved";
case mozilla::net::kCacheHit:
return "Hit";
case mozilla::net::kCacheHitViaReval:
return "HitViaReval";
case mozilla::net::kCacheMissedViaReval:
return "MissedViaReval";
case mozilla::net::kCacheMissed:
return "Missed";
case mozilla::net::kCacheUnknown:
default:
return nullptr;
}
return nullptr;
}
void
NetworkMarkerPayload::StreamPayload(SpliceableJSONWriter& aWriter,
@ -165,8 +185,12 @@ NetworkMarkerPayload::StreamPayload(SpliceableJSONWriter& aWriter,
StreamCommonProps("Network", aWriter, aProcessStartTime, aUniqueStacks);
aWriter.IntProperty("id", mID);
const char *typeString = GetNetworkState(mType);
const char *cacheString = GetCacheState(mCacheDisposition);
// want to use aUniqueStacks.mUniqueStrings->WriteElement(aWriter, typeString);
aWriter.StringProperty("status", typeString);
if (cacheString) {
aWriter.StringProperty("cache", cacheString);
}
aWriter.IntProperty("pri", mPri);
if (mCount > 0) {
aWriter.IntProperty("count", mCount);

Просмотреть файл

@ -3765,6 +3765,7 @@ profiler_add_network_marker(nsIURI* aURI,
mozilla::TimeStamp aStart,
mozilla::TimeStamp aEnd,
int64_t aCount,
mozilla::net::CacheDisposition aCacheDisposition,
const mozilla::net::TimingStruct* aTimings,
nsIURI* aRedirectURI)
{
@ -3792,6 +3793,7 @@ profiler_add_network_marker(nsIURI* aURI,
aEnd,
aPriority,
aCount,
aCacheDisposition,
aTimings,
PromiseFlatCString(redirect_spec).get()));
}

Просмотреть файл

@ -95,6 +95,8 @@ if CONFIG['MOZ_GECKO_PROFILER']:
'/docshell/base',
'/ipc/chromium/src',
'/mozglue/linker',
'/netwerk/base',
'/netwerk/protocol/http',
'/toolkit/crashreporter/google-breakpad/src',
'/tools/profiler/core/',
'/tools/profiler/gecko/',

Просмотреть файл

@ -93,6 +93,7 @@ class SpliceableJSONWriter;
namespace mozilla {
namespace net {
struct TimingStruct;
enum CacheDisposition : uint8_t;
}
}
class nsIURI;
@ -607,8 +608,8 @@ enum class NetworkLoadType {
LOAD_REDIRECT
};
#define PROFILER_ADD_NETWORK_MARKER(uri, pri, channel, type, start, end, count, timings, redirect) \
profiler_add_network_marker(uri, pri, channel, type, start, end, count, timings, redirect)
#define PROFILER_ADD_NETWORK_MARKER(uri, pri, channel, type, start, end, count, cache, timings, redirect) \
profiler_add_network_marker(uri, pri, channel, type, start, end, count, cache, timings, redirect)
void profiler_add_network_marker(nsIURI* aURI,
int32_t aPriority,
@ -617,6 +618,7 @@ void profiler_add_network_marker(nsIURI* aURI,
mozilla::TimeStamp aStart,
mozilla::TimeStamp aEnd,
int64_t aCount,
mozilla::net::CacheDisposition aCacheDisposition,
const mozilla::net::TimingStruct* aTimings = nullptr,
nsIURI* aRedirectURI = nullptr);

Просмотреть файл

@ -262,6 +262,7 @@ public:
const mozilla::TimeStamp& aEndTime,
int32_t aPri,
int64_t aCount,
mozilla::net::CacheDisposition aCacheDisposition,
const mozilla::net::TimingStruct* aTimings = nullptr,
const char* aRedirectURI = nullptr)
: ProfilerMarkerPayload(aStartTime, aEndTime, mozilla::Nothing())
@ -273,6 +274,7 @@ public:
, mType(aType)
, mPri(aPri)
, mCount(aCount)
, mCacheDisposition(aCacheDisposition)
{
if (aTimings) {
mTimings = *aTimings;
@ -289,6 +291,7 @@ private:
int32_t mPri;
int64_t mCount;
mozilla::net::TimingStruct mTimings;
mozilla::net::CacheDisposition mCacheDisposition;
};
class ScreenshotPayload : public ProfilerMarkerPayload