mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-07 08:18:41 +09:00
parent
e87890d893
commit
b882e7c6be
7 changed files with 0 additions and 212 deletions
|
|
@ -419,11 +419,6 @@ bool CacheEntry::Load(bool aTruncate, bool aPriority)
|
|||
{
|
||||
mozilla::MutexAutoUnlock unlock(mLock);
|
||||
|
||||
if (reportMiss) {
|
||||
CacheFileUtils::DetailedCacheHitTelemetry::AddRecord(
|
||||
CacheFileUtils::DetailedCacheHitTelemetry::MISS, mLoadStart);
|
||||
}
|
||||
|
||||
LOG((" performing load, file=%p", mFile.get()));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = mFile->Init(fileKey,
|
||||
|
|
@ -458,16 +453,6 @@ NS_IMETHODIMP CacheEntry::OnFileReady(nsresult aResult, bool aIsNew)
|
|||
|
||||
MOZ_ASSERT(!mLoadStart.IsNull());
|
||||
|
||||
if (NS_SUCCEEDED(aResult)) {
|
||||
if (aIsNew) {
|
||||
CacheFileUtils::DetailedCacheHitTelemetry::AddRecord(
|
||||
CacheFileUtils::DetailedCacheHitTelemetry::MISS, mLoadStart);
|
||||
} else {
|
||||
CacheFileUtils::DetailedCacheHitTelemetry::AddRecord(
|
||||
CacheFileUtils::DetailedCacheHitTelemetry::HIT, mLoadStart);
|
||||
}
|
||||
}
|
||||
|
||||
// OnFileReady, that is the only code that can transit from LOADING
|
||||
// to any follow-on state and can only be invoked ones on an entry.
|
||||
// Until this moment there is no consumer that could manipulate
|
||||
|
|
|
|||
|
|
@ -401,101 +401,6 @@ ValidityMap::operator[](uint32_t aIdx)
|
|||
return mMap.ElementAt(aIdx);
|
||||
}
|
||||
|
||||
StaticMutex DetailedCacheHitTelemetry::sLock;
|
||||
uint32_t DetailedCacheHitTelemetry::sRecordCnt = 0;
|
||||
DetailedCacheHitTelemetry::HitRate DetailedCacheHitTelemetry::sHRStats[kNumOfRanges];
|
||||
|
||||
DetailedCacheHitTelemetry::HitRate::HitRate()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
void
|
||||
DetailedCacheHitTelemetry::HitRate::AddRecord(ERecType aType)
|
||||
{
|
||||
if (aType == HIT) {
|
||||
++mHitCnt;
|
||||
} else {
|
||||
++mMissCnt;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t
|
||||
DetailedCacheHitTelemetry::HitRate::GetHitRateBucket(uint32_t aNumOfBuckets) const
|
||||
{
|
||||
uint32_t bucketIdx = (aNumOfBuckets * mHitCnt) / (mHitCnt + mMissCnt);
|
||||
if (bucketIdx == aNumOfBuckets) { // make sure 100% falls into the last bucket
|
||||
--bucketIdx;
|
||||
}
|
||||
|
||||
return bucketIdx;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
DetailedCacheHitTelemetry::HitRate::Count()
|
||||
{
|
||||
return mHitCnt + mMissCnt;
|
||||
}
|
||||
|
||||
void
|
||||
DetailedCacheHitTelemetry::HitRate::Reset()
|
||||
{
|
||||
mHitCnt = 0;
|
||||
mMissCnt = 0;
|
||||
}
|
||||
|
||||
// static
|
||||
void
|
||||
DetailedCacheHitTelemetry::AddRecord(ERecType aType, TimeStamp aLoadStart)
|
||||
{
|
||||
bool isUpToDate = false;
|
||||
CacheIndex::IsUpToDate(&isUpToDate);
|
||||
if (!isUpToDate) {
|
||||
// Ignore the record when the entry file count might be incorrect
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t entryCount;
|
||||
nsresult rv = CacheIndex::GetEntryFileCount(&entryCount);
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t rangeIdx = entryCount / kRangeSize;
|
||||
if (rangeIdx >= kNumOfRanges) { // The last range has no upper limit.
|
||||
rangeIdx = kNumOfRanges - 1;
|
||||
}
|
||||
|
||||
uint32_t hitMissValue = 2 * rangeIdx; // 2 values per range
|
||||
if (aType == MISS) { // The order is HIT, MISS
|
||||
++hitMissValue;
|
||||
}
|
||||
|
||||
StaticMutexAutoLock lock(sLock);
|
||||
|
||||
sHRStats[rangeIdx].AddRecord(aType);
|
||||
++sRecordCnt;
|
||||
|
||||
if (sRecordCnt < kTotalSamplesReportLimit) {
|
||||
return;
|
||||
}
|
||||
|
||||
sRecordCnt = 0;
|
||||
|
||||
for (uint32_t i = 0; i < kNumOfRanges; ++i) {
|
||||
if (sHRStats[i].Count() >= kHitRateSamplesReportLimit) {
|
||||
// The telemetry enums are grouped by buckets as follows:
|
||||
// Telemetry value : 0,1,2,3, ... ,19,20,21,22, ... ,398,399
|
||||
// Hit rate bucket : 0,0,0,0, ... , 0, 1, 1, 1, ... , 19, 19
|
||||
// Cache size range: 0,1,2,3, ... ,19, 0, 1, 2, ... , 18, 19
|
||||
uint32_t bucketOffset = sHRStats[i].GetHitRateBucket(kHitRateBuckets) *
|
||||
kNumOfRanges;
|
||||
|
||||
sHRStats[i].Reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
FreeBuffer(void *aBuf) {
|
||||
#ifndef NS_FREE_PERMANENT_DATA
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@
|
|||
#include "nsString.h"
|
||||
#include "nsTArray.h"
|
||||
#include "mozilla/StaticMutex.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
|
||||
class nsILoadContextInfo;
|
||||
class nsACString;
|
||||
|
|
@ -90,64 +89,6 @@ private:
|
|||
nsTArray<ValidityPair> mMap;
|
||||
};
|
||||
|
||||
|
||||
class DetailedCacheHitTelemetry {
|
||||
public:
|
||||
enum ERecType {
|
||||
HIT = 0,
|
||||
MISS = 1
|
||||
};
|
||||
|
||||
static void AddRecord(ERecType aType, TimeStamp aLoadStart);
|
||||
|
||||
private:
|
||||
class HitRate {
|
||||
public:
|
||||
HitRate();
|
||||
|
||||
void AddRecord(ERecType aType);
|
||||
// Returns the bucket index that the current hit rate falls into according
|
||||
// to the given aNumOfBuckets.
|
||||
uint32_t GetHitRateBucket(uint32_t aNumOfBuckets) const;
|
||||
uint32_t Count();
|
||||
void Reset();
|
||||
|
||||
private:
|
||||
uint32_t mHitCnt;
|
||||
uint32_t mMissCnt;
|
||||
};
|
||||
|
||||
// Group the hits and misses statistics by cache files count ranges (0-5000,
|
||||
// 5001-10000, ... , 95001- )
|
||||
static const uint32_t kRangeSize = 5000;
|
||||
static const uint32_t kNumOfRanges = 20;
|
||||
|
||||
// Use the same ranges to report an average hit rate. Report the hit rates
|
||||
// (and reset the counters) every kTotalSamplesReportLimit samples.
|
||||
static const uint32_t kTotalSamplesReportLimit = 1000;
|
||||
|
||||
// Report hit rate for a given cache size range only if it contains
|
||||
// kHitRateSamplesReportLimit or more samples. This limit should avoid
|
||||
// reporting a biased statistics.
|
||||
static const uint32_t kHitRateSamplesReportLimit = 500;
|
||||
|
||||
// All hit rates are accumulated in a single telemetry probe, so to use
|
||||
// a sane number of enumerated values the hit rate is divided into buckets
|
||||
// instead of using a percent value. This constant defines number of buckets
|
||||
// that we divide the hit rates into. I.e. we'll report ranges 0%-5%, 5%-10%,
|
||||
// 10-%15%, ...
|
||||
static const uint32_t kHitRateBuckets = 20;
|
||||
|
||||
// Protects sRecordCnt and sHitStats calls.
|
||||
static StaticMutex sLock;
|
||||
|
||||
// Counter of samples that is compared against kTotalSamplesReportLimit.
|
||||
static uint32_t sRecordCnt;
|
||||
|
||||
// Hit rate statistics for every cache size range.
|
||||
static HitRate sHRStats[kNumOfRanges];
|
||||
};
|
||||
|
||||
void
|
||||
FreeBuffer(void *aBuf);
|
||||
|
||||
|
|
|
|||
|
|
@ -1292,29 +1292,6 @@ CacheIndex::GetCacheSize(uint32_t *_retval)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
// static
|
||||
nsresult
|
||||
CacheIndex::GetEntryFileCount(uint32_t *_retval)
|
||||
{
|
||||
LOG(("CacheIndex::GetEntryFileCount()"));
|
||||
|
||||
StaticMutexAutoLock lock(sLock);
|
||||
|
||||
RefPtr<CacheIndex> index = gInstance;
|
||||
|
||||
if (!index) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
if (!index->IsIndexUsable()) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
*_retval = index->mIndexStats.ActiveEntriesCount();
|
||||
LOG(("CacheIndex::GetEntryFileCount() - returning %u", *_retval));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// static
|
||||
nsresult
|
||||
CacheIndex::GetCacheStats(nsILoadContextInfo *aInfo, uint32_t *aSize, uint32_t *aCount)
|
||||
|
|
|
|||
|
|
@ -662,9 +662,6 @@ public:
|
|||
// Returns cache size in kB.
|
||||
static nsresult GetCacheSize(uint32_t *_retval);
|
||||
|
||||
// Returns number of entry files in the cache
|
||||
static nsresult GetEntryFileCount(uint32_t *_retval);
|
||||
|
||||
// Synchronously returns the disk occupation and number of entries per-context.
|
||||
// Callable on any thread.
|
||||
static nsresult GetCacheStats(nsILoadContextInfo *aInfo, uint32_t *aSize, uint32_t *aCount);
|
||||
|
|
|
|||
|
|
@ -8426,18 +8426,6 @@
|
|||
"n_values": 7,
|
||||
"description": "Final status of the CacheFileInputStream (0=ok, 1=other error, 2=out of memory, 3=disk full, 4=file corrupted, 5=file not found, 6=binding aborted)"
|
||||
},
|
||||
"NETWORK_CACHE_HIT_MISS_STAT_PER_CACHE_SIZE": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "enumerated",
|
||||
"n_values": 40,
|
||||
"description": "Hit/Miss count split by cache size in file count (0=Hit 0-5000, 1=Miss 0-5000, 2=Hit 5001-10000, ...)"
|
||||
},
|
||||
"NETWORK_CACHE_HIT_RATE_PER_CACHE_SIZE": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "enumerated",
|
||||
"n_values": 400,
|
||||
"description": "Hit rate for a specific cache size in file count. The hit rate is split into 20 buckets, the lower limit of the range in percents is 5*n/20. The cache size is divided into 20 ranges of length 5000, the lower limit of the range is 5000*(n%20)"
|
||||
},
|
||||
"NETWORK_CACHE_METADATA_FIRST_READ_TIME_MS": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "exponential",
|
||||
|
|
|
|||
|
|
@ -429,8 +429,6 @@
|
|||
"MOZ_SQLITE_WEBAPPS_WRITE_B",
|
||||
"MOZ_SQLITE_WEBAPPS_WRITE_MAIN_THREAD_MS",
|
||||
"MOZ_SQLITE_WEBAPPS_WRITE_MS",
|
||||
"NETWORK_CACHE_HIT_MISS_STAT_PER_CACHE_SIZE",
|
||||
"NETWORK_CACHE_HIT_RATE_PER_CACHE_SIZE",
|
||||
"NETWORK_CACHE_METADATA_FIRST_READ_SIZE",
|
||||
"NETWORK_CACHE_METADATA_FIRST_READ_TIME_MS",
|
||||
"NETWORK_CACHE_METADATA_SECOND_READ_TIME_MS",
|
||||
|
|
@ -1273,8 +1271,6 @@
|
|||
"MOZ_SQLITE_WEBAPPS_WRITE_MS",
|
||||
"MOZ_STORAGE_ASYNC_REQUESTS_MS",
|
||||
"MOZ_STORAGE_ASYNC_REQUESTS_SUCCESS",
|
||||
"NETWORK_CACHE_HIT_MISS_STAT_PER_CACHE_SIZE",
|
||||
"NETWORK_CACHE_HIT_RATE_PER_CACHE_SIZE",
|
||||
"NETWORK_CACHE_METADATA_FIRST_READ_SIZE",
|
||||
"NETWORK_CACHE_METADATA_FIRST_READ_TIME_MS",
|
||||
"NETWORK_CACHE_METADATA_SECOND_READ_TIME_MS",
|
||||
|
|
@ -1856,7 +1852,6 @@
|
|||
"DEVTOOLS_READ_HEAP_SNAPSHOT_MS",
|
||||
"DEVTOOLS_HEAP_SNAPSHOT_NODE_COUNT",
|
||||
"DEVTOOLS_HEAP_SNAPSHOT_EDGE_COUNT",
|
||||
"NETWORK_CACHE_HIT_RATE_PER_CACHE_SIZE",
|
||||
"NETWORK_CACHE_METADATA_FIRST_READ_SIZE",
|
||||
"NETWORK_CACHE_METADATA_SIZE",
|
||||
"SSL_CIPHER_SUITE_FULL",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue