mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:30:27 +00:00
applied tele.patch (dated 2018-03-17)
This commit is contained in:
@@ -872,8 +872,6 @@ CacheStorageService::RegisterEntry(CacheEntry* aEntry)
|
||||
if (mShutdown || !aEntry->CanRegister())
|
||||
return;
|
||||
|
||||
TelemetryRecordEntryCreation(aEntry);
|
||||
|
||||
LOG(("CacheStorageService::RegisterEntry [entry=%p]", aEntry));
|
||||
|
||||
MemoryPool& pool = Pool(aEntry->IsUsingDisk());
|
||||
@@ -891,8 +889,6 @@ CacheStorageService::UnregisterEntry(CacheEntry* aEntry)
|
||||
if (!aEntry->IsRegistered())
|
||||
return;
|
||||
|
||||
TelemetryRecordEntryRemoval(aEntry);
|
||||
|
||||
LOG(("CacheStorageService::UnregisterEntry [entry=%p]", aEntry));
|
||||
|
||||
MemoryPool& pool = Pool(aEntry->IsUsingDisk());
|
||||
@@ -1857,113 +1853,6 @@ CacheStorageService::GetCacheEntryInfo(CacheEntry* aEntry,
|
||||
fetchCount, lastModified, expirationTime);
|
||||
}
|
||||
|
||||
// Telementry collection
|
||||
|
||||
namespace { // anon
|
||||
|
||||
bool TelemetryEntryKey(CacheEntry const* entry, nsAutoCString& key)
|
||||
{
|
||||
nsAutoCString entryKey;
|
||||
nsresult rv = entry->HashingKey(entryKey);
|
||||
if (NS_FAILED(rv))
|
||||
return false;
|
||||
|
||||
if (entry->GetStorageID().IsEmpty()) {
|
||||
// Hopefully this will be const-copied, saves some memory
|
||||
key = entryKey;
|
||||
} else {
|
||||
key.Assign(entry->GetStorageID());
|
||||
key.Append(':');
|
||||
key.Append(entryKey);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
PLDHashOperator PrunePurgeTimeStamps(
|
||||
const nsACString& aKey, TimeStamp& aTimeStamp, void* aClosure)
|
||||
{
|
||||
TimeStamp* now = static_cast<TimeStamp*>(aClosure);
|
||||
static TimeDuration const fifteenMinutes = TimeDuration::FromSeconds(900);
|
||||
|
||||
if (*now - aTimeStamp > fifteenMinutes) {
|
||||
// We are not interested in resurrection of entries after 15 minutes
|
||||
// of time. This is also the limit for the telemetry.
|
||||
return PL_DHASH_REMOVE;
|
||||
}
|
||||
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
} // anon
|
||||
|
||||
void
|
||||
CacheStorageService::TelemetryPrune(TimeStamp &now)
|
||||
{
|
||||
static TimeDuration const oneMinute = TimeDuration::FromSeconds(60);
|
||||
static TimeStamp dontPruneUntil = now + oneMinute;
|
||||
if (now < dontPruneUntil)
|
||||
return;
|
||||
|
||||
mPurgeTimeStamps.Enumerate(PrunePurgeTimeStamps, &now);
|
||||
dontPruneUntil = now + oneMinute;
|
||||
}
|
||||
|
||||
void
|
||||
CacheStorageService::TelemetryRecordEntryCreation(CacheEntry const* entry)
|
||||
{
|
||||
MOZ_ASSERT(CacheStorageService::IsOnManagementThread());
|
||||
|
||||
nsAutoCString key;
|
||||
if (!TelemetryEntryKey(entry, key))
|
||||
return;
|
||||
|
||||
TimeStamp now = TimeStamp::NowLoRes();
|
||||
TelemetryPrune(now);
|
||||
|
||||
// When an entry is craeted (registered actually) we check if there is
|
||||
// a timestamp marked when this very same cache entry has been removed
|
||||
// (deregistered) because of over-memory-limit purging. If there is such
|
||||
// a timestamp found accumulate telemetry on how long the entry was away.
|
||||
TimeStamp timeStamp;
|
||||
if (!mPurgeTimeStamps.Get(key, &timeStamp))
|
||||
return;
|
||||
|
||||
mPurgeTimeStamps.Remove(key);
|
||||
|
||||
Telemetry::AccumulateTimeDelta(Telemetry::HTTP_CACHE_ENTRY_RELOAD_TIME,
|
||||
timeStamp, TimeStamp::NowLoRes());
|
||||
}
|
||||
|
||||
void
|
||||
CacheStorageService::TelemetryRecordEntryRemoval(CacheEntry const* entry)
|
||||
{
|
||||
MOZ_ASSERT(CacheStorageService::IsOnManagementThread());
|
||||
|
||||
// Doomed entries must not be considered, we are only interested in purged
|
||||
// entries. Note that the mIsDoomed flag is always set before deregistration
|
||||
// happens.
|
||||
if (entry->IsDoomed())
|
||||
return;
|
||||
|
||||
nsAutoCString key;
|
||||
if (!TelemetryEntryKey(entry, key))
|
||||
return;
|
||||
|
||||
// When an entry is removed (deregistered actually) we put a timestamp for this
|
||||
// entry to the hashtable so that when the entry is created (registered) again
|
||||
// we know how long it was away. Also accumulate number of AsyncOpen calls on
|
||||
// the entry, this tells us how efficiently the pool actually works.
|
||||
|
||||
TimeStamp now = TimeStamp::NowLoRes();
|
||||
TelemetryPrune(now);
|
||||
mPurgeTimeStamps.Put(key, now);
|
||||
|
||||
Telemetry::Accumulate(Telemetry::HTTP_CACHE_ENTRY_REUSE_COUNT, entry->UseCount());
|
||||
Telemetry::AccumulateTimeDelta(Telemetry::HTTP_CACHE_ENTRY_ALIVE_TIME,
|
||||
entry->LoadStart(), TimeStamp::NowLoRes());
|
||||
}
|
||||
|
||||
// nsIMemoryReporter
|
||||
|
||||
size_t
|
||||
|
||||
Reference in New Issue
Block a user