зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1614610 - Have cache occupancy for each content-type in cache index r=valentin
Differential Revision: https://phabricator.services.mozilla.com/D63624 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
a61d164b44
Коммит
47f2a10a01
|
@ -3894,46 +3894,19 @@ void CacheIndex::DoTelemetryReport() {
|
|||
NS_LITERAL_CSTRING("MEDIA"), NS_LITERAL_CSTRING("STYLESHEET"),
|
||||
NS_LITERAL_CSTRING("WASM")};
|
||||
|
||||
// size in kB of all entries
|
||||
uint32_t size = 0;
|
||||
// count of all entries
|
||||
uint32_t count = 0;
|
||||
|
||||
// the same stats as above split by content type
|
||||
uint32_t sizeByType[nsICacheEntry::CONTENT_TYPE_LAST];
|
||||
uint32_t countByType[nsICacheEntry::CONTENT_TYPE_LAST];
|
||||
|
||||
memset(&sizeByType, 0, sizeof(sizeByType));
|
||||
memset(&countByType, 0, sizeof(countByType));
|
||||
|
||||
for (auto iter = mIndex.Iter(); !iter.Done(); iter.Next()) {
|
||||
CacheIndexEntry* entry = iter.Get();
|
||||
if (entry->IsRemoved() || !entry->IsInitialized() || entry->IsFileEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
uint32_t entrySize = entry->GetFileSize();
|
||||
uint8_t contentType = entry->GetContentType();
|
||||
|
||||
++count;
|
||||
++countByType[contentType];
|
||||
size += entrySize;
|
||||
sizeByType[contentType] += entrySize;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < nsICacheEntry::CONTENT_TYPE_LAST; ++i) {
|
||||
if (size > 0) {
|
||||
Telemetry::Accumulate(Telemetry::NETWORK_CACHE_SIZE_SHARE,
|
||||
contentTypeNames[i],
|
||||
round(static_cast<double>(sizeByType[i]) * 100.0 /
|
||||
static_cast<double>(size)));
|
||||
if (mIndexStats.Size() > 0) {
|
||||
Telemetry::Accumulate(
|
||||
Telemetry::NETWORK_CACHE_SIZE_SHARE, contentTypeNames[i],
|
||||
round(static_cast<double>(mIndexStats.SizeByType(i)) * 100.0 /
|
||||
static_cast<double>(mIndexStats.Size())));
|
||||
}
|
||||
|
||||
if (count > 0) {
|
||||
Telemetry::Accumulate(Telemetry::NETWORK_CACHE_ENTRY_COUNT_SHARE,
|
||||
contentTypeNames[i],
|
||||
round(static_cast<double>(countByType[i]) * 100.0 /
|
||||
static_cast<double>(count)));
|
||||
if (mIndexStats.Count() > 0) {
|
||||
Telemetry::Accumulate(
|
||||
Telemetry::NETWORK_CACHE_ENTRY_COUNT_SHARE, contentTypeNames[i],
|
||||
round(static_cast<double>(mIndexStats.CountByType(i)) * 100.0 /
|
||||
static_cast<double>(mIndexStats.Count())));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3943,8 +3916,10 @@ void CacheIndex::DoTelemetryReport() {
|
|||
} else {
|
||||
probeKey = NS_LITERAL_CSTRING("USERDEFINEDSIZE");
|
||||
}
|
||||
Telemetry::Accumulate(Telemetry::NETWORK_CACHE_ENTRY_COUNT, probeKey, count);
|
||||
Telemetry::Accumulate(Telemetry::NETWORK_CACHE_SIZE, probeKey, size >> 10);
|
||||
Telemetry::Accumulate(Telemetry::NETWORK_CACHE_ENTRY_COUNT, probeKey,
|
||||
mIndexStats.Count());
|
||||
Telemetry::Accumulate(Telemetry::NETWORK_CACHE_SIZE, probeKey,
|
||||
mIndexStats.Size() >> 10);
|
||||
}
|
||||
|
||||
// static
|
||||
|
|
|
@ -228,7 +228,16 @@ class CacheIndexEntry : public PLDHashEntryHdr {
|
|||
uint16_t GetOnStopTime() const { return mRec->mOnStopTime; }
|
||||
|
||||
void SetContentType(uint8_t aType) { mRec->mContentType = aType; }
|
||||
uint8_t GetContentType() const { return mRec->mContentType; }
|
||||
uint8_t GetContentType() const {
|
||||
if (mRec->mContentType >= nsICacheEntry::CONTENT_TYPE_LAST) {
|
||||
LOG(
|
||||
("CacheIndexEntry::GetContentType() - Found invalid content type "
|
||||
"[hash=%08x%08x%08x%08x%08x, contentType=%u]",
|
||||
LOGSHA1(mRec->mHash), mRec->mContentType));
|
||||
return nsICacheEntry::CONTENT_TYPE_UNKNOWN;
|
||||
}
|
||||
return mRec->mContentType;
|
||||
}
|
||||
|
||||
// Sets filesize in kilobytes.
|
||||
void SetFileSize(uint32_t aFileSize) {
|
||||
|
@ -518,6 +527,12 @@ class CacheIndexStats {
|
|||
return mCount;
|
||||
}
|
||||
|
||||
uint32_t CountByType(uint8_t aContentType) {
|
||||
MOZ_ASSERT(!mStateLogged, "CacheIndexStats::CountByType() - state logged!");
|
||||
MOZ_RELEASE_ASSERT(aContentType < nsICacheEntry::CONTENT_TYPE_LAST);
|
||||
return mCountByType[aContentType];
|
||||
}
|
||||
|
||||
uint32_t Dirty() {
|
||||
MOZ_ASSERT(!mStateLogged, "CacheIndexStats::Dirty() - state logged!");
|
||||
return mDirty;
|
||||
|
@ -540,6 +555,12 @@ class CacheIndexStats {
|
|||
return mSize;
|
||||
}
|
||||
|
||||
uint32_t SizeByType(uint8_t aContentType) {
|
||||
MOZ_ASSERT(!mStateLogged, "CacheIndexStats::SizeByType() - state logged!");
|
||||
MOZ_RELEASE_ASSERT(aContentType < nsICacheEntry::CONTENT_TYPE_LAST);
|
||||
return mSizeByType[aContentType];
|
||||
}
|
||||
|
||||
void BeforeChange(const CacheIndexEntry* aEntry) {
|
||||
#ifdef DEBUG_STATS
|
||||
if (!mDisableLogging) {
|
||||
|
@ -556,7 +577,9 @@ class CacheIndexStats {
|
|||
#endif
|
||||
if (aEntry) {
|
||||
MOZ_ASSERT(mCount);
|
||||
uint8_t contentType = aEntry->GetContentType();
|
||||
mCount--;
|
||||
mCountByType[contentType]--;
|
||||
if (aEntry->IsDirty()) {
|
||||
MOZ_ASSERT(mDirty);
|
||||
mDirty--;
|
||||
|
@ -579,6 +602,7 @@ class CacheIndexStats {
|
|||
} else {
|
||||
MOZ_ASSERT(mSize >= aEntry->GetFileSize());
|
||||
mSize -= aEntry->GetFileSize();
|
||||
mSizeByType[contentType] -= aEntry->GetFileSize();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -593,7 +617,9 @@ class CacheIndexStats {
|
|||
mStateLogged = false;
|
||||
#endif
|
||||
if (aEntry) {
|
||||
uint8_t contentType = aEntry->GetContentType();
|
||||
++mCount;
|
||||
++mCountByType[contentType];
|
||||
if (aEntry->IsDirty()) {
|
||||
mDirty++;
|
||||
}
|
||||
|
@ -610,6 +636,7 @@ class CacheIndexStats {
|
|||
mEmpty++;
|
||||
} else {
|
||||
mSize += aEntry->GetFileSize();
|
||||
mSizeByType[contentType] += aEntry->GetFileSize();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -625,12 +652,14 @@ class CacheIndexStats {
|
|||
|
||||
private:
|
||||
uint32_t mCount;
|
||||
uint32_t mCountByType[nsICacheEntry::CONTENT_TYPE_LAST];
|
||||
uint32_t mNotInitialized;
|
||||
uint32_t mRemoved;
|
||||
uint32_t mDirty;
|
||||
uint32_t mFresh;
|
||||
uint32_t mEmpty;
|
||||
uint32_t mSize;
|
||||
uint32_t mSizeByType[nsICacheEntry::CONTENT_TYPE_LAST];
|
||||
#ifdef DEBUG
|
||||
// We completely remove the data about an entry from the stats in
|
||||
// BeforeChange() and set this flag to true. The entry is then modified,
|
||||
|
|
Загрузка…
Ссылка в новой задаче