diff options
Diffstat (limited to 'netwerk/cache2')
-rw-r--r-- | netwerk/cache2/CacheEntry.cpp | 15 | ||||
-rw-r--r-- | netwerk/cache2/CacheFile.cpp | 34 | ||||
-rw-r--r-- | netwerk/cache2/CacheFileIOManager.cpp | 55 | ||||
-rw-r--r-- | netwerk/cache2/CacheFileMetadata.cpp | 14 | ||||
-rw-r--r-- | netwerk/cache2/CacheFileUtils.cpp | 111 | ||||
-rw-r--r-- | netwerk/cache2/CacheFileUtils.h | 59 | ||||
-rw-r--r-- | netwerk/cache2/CacheIOThread.cpp | 56 | ||||
-rw-r--r-- | netwerk/cache2/CacheIndex.cpp | 99 | ||||
-rw-r--r-- | netwerk/cache2/CacheIndex.h | 5 | ||||
-rw-r--r-- | netwerk/cache2/CacheObserver.cpp | 58 | ||||
-rw-r--r-- | netwerk/cache2/CacheObserver.h | 10 | ||||
-rw-r--r-- | netwerk/cache2/CacheStorageService.cpp | 103 | ||||
-rw-r--r-- | netwerk/cache2/CacheStorageService.h | 12 | ||||
-rw-r--r-- | netwerk/cache2/OldWrappers.cpp | 19 |
14 files changed, 0 insertions, 650 deletions
diff --git a/netwerk/cache2/CacheEntry.cpp b/netwerk/cache2/CacheEntry.cpp index b79bf7373..51e441aa7 100644 --- a/netwerk/cache2/CacheEntry.cpp +++ b/netwerk/cache2/CacheEntry.cpp @@ -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 diff --git a/netwerk/cache2/CacheFile.cpp b/netwerk/cache2/CacheFile.cpp index fa0a89382..69fc3d33c 100644 --- a/netwerk/cache2/CacheFile.cpp +++ b/netwerk/cache2/CacheFile.cpp @@ -14,7 +14,6 @@ #include <algorithm> #include "nsComponentManagerUtils.h" #include "nsProxyRelease.h" -#include "mozilla/Telemetry.h" // When CACHE_CHUNKS is defined we always cache unused chunks in mCacheChunks. // When it is not defined, we always release the chunks ASAP, i.e. we cache @@ -1866,33 +1865,6 @@ CacheFile::Truncate(int64_t aOffset) return NS_OK; } -static uint32_t -StatusToTelemetryEnum(nsresult aStatus) -{ - if (NS_SUCCEEDED(aStatus)) { - return 0; - } - - switch (aStatus) { - case NS_BASE_STREAM_CLOSED: - return 0; // Log this as a success - case NS_ERROR_OUT_OF_MEMORY: - return 2; - case NS_ERROR_FILE_DISK_FULL: - return 3; - case NS_ERROR_FILE_CORRUPTED: - return 4; - case NS_ERROR_FILE_NOT_FOUND: - return 5; - case NS_BINDING_ABORTED: - return 6; - default: - return 1; // other error - } - - NS_NOTREACHED("We should never get here"); -} - nsresult CacheFile::RemoveInput(CacheFileInputStream *aInput, nsresult aStatus) { @@ -1914,9 +1886,6 @@ CacheFile::RemoveInput(CacheFileInputStream *aInput, nsresult aStatus) // chunks that won't be used anymore. CleanUpCachedChunks(); - Telemetry::Accumulate(Telemetry::NETWORK_CACHE_V2_INPUT_STREAM_STATUS, - StatusToTelemetryEnum(aStatus)); - return NS_OK; } @@ -1952,9 +1921,6 @@ CacheFile::RemoveOutput(CacheFileOutputStream *aOutput, nsresult aStatus) // Notify close listener as the last action aOutput->NotifyCloseListener(); - Telemetry::Accumulate(Telemetry::NETWORK_CACHE_V2_OUTPUT_STREAM_STATUS, - StatusToTelemetryEnum(aStatus)); - return NS_OK; } diff --git a/netwerk/cache2/CacheFileIOManager.cpp b/netwerk/cache2/CacheFileIOManager.cpp index 1d0d57635..25e621d12 100644 --- a/netwerk/cache2/CacheFileIOManager.cpp +++ b/netwerk/cache2/CacheFileIOManager.cpp @@ -21,7 +21,6 @@ #include "nsIObserverService.h" #include "nsICacheStorageVisitor.h" #include "nsISizeOf.h" -#include "mozilla/Telemetry.h" #include "mozilla/DebugOnly.h" #include "mozilla/Services.h" #include "nsDirectoryServiceUtils.h" @@ -1173,8 +1172,6 @@ CacheFileIOManager::Shutdown() return NS_ERROR_NOT_INITIALIZED; } - Telemetry::AutoTimer<Telemetry::NETWORK_DISK_CACHE_SHUTDOWN_V2> shutdownTimer; - CacheIndex::PreShutdown(); ShutdownMetadataWriteScheduling(); @@ -1192,7 +1189,6 @@ CacheFileIOManager::Shutdown() CacheIndex::Shutdown(); if (CacheObserver::ClearCacheOnShutdown()) { - Telemetry::AutoTimer<Telemetry::NETWORK_DISK_CACHE2_SHUTDOWN_CLEAR_PRIVATE> totalTimer; gInstance->SyncRemoveAllCacheFiles(); } @@ -3826,45 +3822,6 @@ CacheFileIOManager::CreateCacheTree() StartRemovingTrash(); - if (!CacheObserver::CacheFSReported()) { - uint32_t fsType = 4; // Other OS - -#ifdef XP_WIN - nsAutoString target; - nsresult rv = mCacheDirectory->GetTarget(target); - if (NS_FAILED(rv)) { - return NS_OK; - } - - wchar_t volume_path[MAX_PATH + 1] = { 0 }; - if (!::GetVolumePathNameW(target.get(), - volume_path, - mozilla::ArrayLength(volume_path))) { - return NS_OK; - } - - wchar_t fsName[6] = { 0 }; - if (!::GetVolumeInformationW(volume_path, nullptr, 0, nullptr, nullptr, - nullptr, fsName, - mozilla::ArrayLength(fsName))) { - return NS_OK; - } - - if (wcscmp(fsName, L"NTFS") == 0) { - fsType = 0; - } else if (wcscmp(fsName, L"FAT32") == 0) { - fsType = 1; - } else if (wcscmp(fsName, L"FAT") == 0) { - fsType = 2; - } else { - fsType = 3; - } -#endif - - Telemetry::Accumulate(Telemetry::NETWORK_CACHE_FS_TYPE, fsType); - CacheObserver::SetCacheFSReported(); - } - return NS_OK; } @@ -3910,18 +3867,6 @@ CacheFileIOManager::OpenNSPRHandle(CacheFileHandle *aHandle, bool aCreate) LOG(("CacheFileIOManager::OpenNSPRHandle() - Successfully evicted entry" " with hash %08x%08x%08x%08x%08x. %s to create the new file.", LOGSHA1(&hash), NS_SUCCEEDED(rv) ? "Succeeded" : "Failed")); - - // Report the full size only once per session - static bool sSizeReported = false; - if (!sSizeReported) { - uint32_t cacheUsage; - if (NS_SUCCEEDED(CacheIndex::GetCacheSize(&cacheUsage))) { - cacheUsage >>= 10; - Telemetry::Accumulate(Telemetry::NETWORK_CACHE_SIZE_FULL_FAT, - cacheUsage); - sSizeReported = true; - } - } } else { LOG(("CacheFileIOManager::OpenNSPRHandle() - Couldn't evict an existing" " entry.")); diff --git a/netwerk/cache2/CacheFileMetadata.cpp b/netwerk/cache2/CacheFileMetadata.cpp index 3814b4c87..86fc089aa 100644 --- a/netwerk/cache2/CacheFileMetadata.cpp +++ b/netwerk/cache2/CacheFileMetadata.cpp @@ -14,7 +14,6 @@ #include "nsICacheEntry.h" // for nsICacheEntryMetaDataVisitor #include "../cache/nsCacheUtils.h" #include "nsIFile.h" -#include "mozilla/Telemetry.h" #include "mozilla/DebugOnly.h" #include "prnetdb.h" @@ -687,16 +686,6 @@ CacheFileMetadata::OnDataRead(CacheFileHandle *aHandle, char *aBuf, return NS_OK; } - if (mFirstRead) { - Telemetry::AccumulateTimeDelta( - Telemetry::NETWORK_CACHE_METADATA_FIRST_READ_TIME_MS, mReadStart); - Telemetry::Accumulate( - Telemetry::NETWORK_CACHE_METADATA_FIRST_READ_SIZE, mBufSize); - } else { - Telemetry::AccumulateTimeDelta( - Telemetry::NETWORK_CACHE_METADATA_SECOND_READ_TIME_MS, mReadStart); - } - // check whether we have read all necessary data uint32_t realOffset = NetworkEndian::readUint32(mBuf + mBufSize - sizeof(uint32_t)); @@ -776,9 +765,6 @@ CacheFileMetadata::OnDataRead(CacheFileHandle *aHandle, char *aBuf, return NS_OK; } - Telemetry::Accumulate(Telemetry::NETWORK_CACHE_METADATA_SIZE, - size - realOffset); - // We have all data according to offset information at the end of the entry. // Try to parse it. rv = ParseMetadata(realOffset, realOffset - usedOffset, true); diff --git a/netwerk/cache2/CacheFileUtils.cpp b/netwerk/cache2/CacheFileUtils.cpp index d43e958bf..a090a9cb1 100644 --- a/netwerk/cache2/CacheFileUtils.cpp +++ b/netwerk/cache2/CacheFileUtils.cpp @@ -7,7 +7,6 @@ #include "CacheFileUtils.h" #include "LoadContextInfo.h" #include "mozilla/Tokenizer.h" -#include "mozilla/Telemetry.h" #include "nsCOMPtr.h" #include "nsAutoPtr.h" #include "nsString.h" @@ -402,116 +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); - - if (aType == MISS) { - mozilla::Telemetry::AccumulateTimeDelta( - mozilla::Telemetry::NETWORK_CACHE_V2_MISS_TIME_MS, - aLoadStart); - } else { - mozilla::Telemetry::AccumulateTimeDelta( - mozilla::Telemetry::NETWORK_CACHE_V2_HIT_TIME_MS, - aLoadStart); - } - - Telemetry::Accumulate(Telemetry::NETWORK_CACHE_HIT_MISS_STAT_PER_CACHE_SIZE, - hitMissValue); - - 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; - - Telemetry::Accumulate(Telemetry::NETWORK_CACHE_HIT_RATE_PER_CACHE_SIZE, - bucketOffset + i); - sHRStats[i].Reset(); - } - } -} - void FreeBuffer(void *aBuf) { #ifndef NS_FREE_PERMANENT_DATA diff --git a/netwerk/cache2/CacheFileUtils.h b/netwerk/cache2/CacheFileUtils.h index 3371c3eb5..b66f0adf1 100644 --- a/netwerk/cache2/CacheFileUtils.h +++ b/netwerk/cache2/CacheFileUtils.h @@ -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, sHitStats and Telemetry::Accumulated() 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); diff --git a/netwerk/cache2/CacheIOThread.cpp b/netwerk/cache2/CacheIOThread.cpp index b96f03216..2fbc0ccce 100644 --- a/netwerk/cache2/CacheIOThread.cpp +++ b/netwerk/cache2/CacheIOThread.cpp @@ -18,56 +18,6 @@ namespace mozilla { namespace net { -namespace { // anon - -class CacheIOTelemetry -{ -public: - typedef CacheIOThread::EventQueue::size_type size_type; - static size_type mMinLengthToReport[CacheIOThread::LAST_LEVEL]; - static void Report(uint32_t aLevel, size_type aLength); -}; - -static CacheIOTelemetry::size_type const kGranularity = 30; - -CacheIOTelemetry::size_type -CacheIOTelemetry::mMinLengthToReport[CacheIOThread::LAST_LEVEL] = { - kGranularity, kGranularity, kGranularity, kGranularity, - kGranularity, kGranularity, kGranularity, kGranularity -}; - -// static -void CacheIOTelemetry::Report(uint32_t aLevel, CacheIOTelemetry::size_type aLength) -{ - if (mMinLengthToReport[aLevel] > aLength) { - return; - } - - static Telemetry::ID telemetryID[] = { - Telemetry::HTTP_CACHE_IO_QUEUE_2_OPEN_PRIORITY, - Telemetry::HTTP_CACHE_IO_QUEUE_2_READ_PRIORITY, - Telemetry::HTTP_CACHE_IO_QUEUE_2_MANAGEMENT, - Telemetry::HTTP_CACHE_IO_QUEUE_2_OPEN, - Telemetry::HTTP_CACHE_IO_QUEUE_2_READ, - Telemetry::HTTP_CACHE_IO_QUEUE_2_WRITE_PRIORITY, - Telemetry::HTTP_CACHE_IO_QUEUE_2_WRITE, - Telemetry::HTTP_CACHE_IO_QUEUE_2_INDEX, - Telemetry::HTTP_CACHE_IO_QUEUE_2_EVICT - }; - - // Each bucket is a multiply of kGranularity (30, 60, 90..., 300+) - aLength = (aLength / kGranularity); - // Next time report only when over the current length + kGranularity - mMinLengthToReport[aLevel] = (aLength + 1) * kGranularity; - - // 10 is number of buckets we have in each probe - aLength = std::min<size_type>(aLength, 10); - - Telemetry::Accumulate(telemetryID[aLevel], aLength - 1); // counted from 0 -} - -} // anon - namespace detail { /** @@ -527,7 +477,6 @@ void CacheIOThread::LoopOneLevel(uint32_t aLevel) mCurrentlyExecutingLevel = aLevel; bool returnEvents = false; - bool reportTelementry = true; EventQueue::size_type index; { @@ -541,11 +490,6 @@ void CacheIOThread::LoopOneLevel(uint32_t aLevel) break; } - if (reportTelementry) { - reportTelementry = false; - CacheIOTelemetry::Report(aLevel, length); - } - // Drop any previous flagging, only an event on the current level may set // this flag. mRerunCurrentEvent = false; diff --git a/netwerk/cache2/CacheIndex.cpp b/netwerk/cache2/CacheIndex.cpp index 4525bbe6d..2c6451d72 100644 --- a/netwerk/cache2/CacheIndex.cpp +++ b/netwerk/cache2/CacheIndex.cpp @@ -20,7 +20,6 @@ #include "nsITimer.h" #include "mozilla/AutoRestore.h" #include <algorithm> -#include "mozilla/Telemetry.h" #include "mozilla/Unused.h" @@ -1295,29 +1294,6 @@ CacheIndex::GetCacheSize(uint32_t *_retval) // 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) { LOG(("CacheIndex::GetCacheStats() [info=%p]", aInfo)); @@ -3167,11 +3143,6 @@ CacheIndex::ChangeState(EState aNewState) return; } - if ((mState == READING || mState == BUILDING || mState == UPDATING) && - aNewState == READY) { - ReportHashStats(); - } - // Try to evict entries over limit everytime we're leaving state READING, // BUILDING or UPDATING, but not during shutdown or when removing all // entries. @@ -3720,76 +3691,6 @@ CacheIndex::SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) return mallocSizeOf(gInstance) + SizeOfExcludingThis(mallocSizeOf); } -namespace { - -class HashComparator -{ -public: - bool Equals(CacheIndexRecord* a, CacheIndexRecord* b) const { - return memcmp(&a->mHash, &b->mHash, sizeof(SHA1Sum::Hash)) == 0; - } - bool LessThan(CacheIndexRecord* a, CacheIndexRecord* b) const { - return memcmp(&a->mHash, &b->mHash, sizeof(SHA1Sum::Hash)) < 0; - } -}; - -void -ReportHashSizeMatch(const SHA1Sum::Hash *aHash1, const SHA1Sum::Hash *aHash2) -{ - const uint32_t *h1 = reinterpret_cast<const uint32_t *>(aHash1); - const uint32_t *h2 = reinterpret_cast<const uint32_t *>(aHash2); - - for (uint32_t i = 0; i < 5; ++i) { - if (h1[i] != h2[i]) { - uint32_t bitsDiff = h1[i] ^ h2[i]; - bitsDiff = NetworkEndian::readUint32(&bitsDiff); - - // count leading zeros in bitsDiff - static const uint8_t debruijn32[32] = - { 0, 31, 9, 30, 3, 8, 13, 29, 2, 5, 7, 21, 12, 24, 28, 19, - 1, 10, 4, 14, 6, 22, 25, 20, 11, 15, 23, 26, 16, 27, 17, 18}; - - bitsDiff |= bitsDiff>>1; - bitsDiff |= bitsDiff>>2; - bitsDiff |= bitsDiff>>4; - bitsDiff |= bitsDiff>>8; - bitsDiff |= bitsDiff>>16; - bitsDiff++; - - uint8_t hashSizeMatch = debruijn32[bitsDiff*0x076be629>>27] + (i<<5); - Telemetry::Accumulate(Telemetry::NETWORK_CACHE_HASH_STATS, hashSizeMatch); - - return; - } - } - - MOZ_ASSERT(false, "Found a collision in the index!"); -} - -} // namespace - -void -CacheIndex::ReportHashStats() -{ - // We're gathering the hash stats only once, exclude too small caches. - if (CacheObserver::HashStatsReported() || mFrecencyArray.Length() < 15000) { - return; - } - - nsTArray<CacheIndexRecord *> records; - for (auto iter = mFrecencyArray.Iter(); !iter.Done(); iter.Next()) { - records.AppendElement(iter.Get()); - } - - records.Sort(HashComparator()); - - for (uint32_t i = 1; i < records.Length(); i++) { - ReportHashSizeMatch(&records[i-1]->mHash, &records[i]->mHash); - } - - CacheObserver::SetHashStatsReported(); -} - // static void CacheIndex::OnAsyncEviction(bool aEvicting) diff --git a/netwerk/cache2/CacheIndex.h b/netwerk/cache2/CacheIndex.h index dc72c346f..acb3bdd25 100644 --- a/netwerk/cache2/CacheIndex.h +++ b/netwerk/cache2/CacheIndex.h @@ -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); @@ -918,8 +915,6 @@ private: // Memory reporting (private part) size_t SizeOfExcludingThisInternal(mozilla::MallocSizeOf mallocSizeOf) const; - void ReportHashStats(); - static mozilla::StaticRefPtr<CacheIndex> gInstance; static StaticMutex sLock; diff --git a/netwerk/cache2/CacheObserver.cpp b/netwerk/cache2/CacheObserver.cpp index 6b6d89395..32e0dff95 100644 --- a/netwerk/cache2/CacheObserver.cpp +++ b/netwerk/cache2/CacheObserver.cpp @@ -86,12 +86,6 @@ bool CacheObserver::sSanitizeOnShutdown = kDefaultSanitizeOnShutdown; static bool kDefaultClearCacheOnShutdown = false; bool CacheObserver::sClearCacheOnShutdown = kDefaultClearCacheOnShutdown; -static bool kDefaultCacheFSReported = false; -bool CacheObserver::sCacheFSReported = kDefaultCacheFSReported; - -static bool kDefaultHashStatsReported = false; -bool CacheObserver::sHashStatsReported = kDefaultHashStatsReported; - static uint32_t const kDefaultMaxShutdownIOLag = 2; // seconds Atomic<uint32_t, Relaxed> CacheObserver::sMaxShutdownIOLag(kDefaultMaxShutdownIOLag); @@ -331,58 +325,6 @@ CacheObserver::StoreDiskCacheCapacity() } // static -void -CacheObserver::SetCacheFSReported() -{ - sCacheFSReported = true; - - if (!sSelf) { - return; - } - - if (NS_IsMainThread()) { - sSelf->StoreCacheFSReported(); - } else { - nsCOMPtr<nsIRunnable> event = - NewRunnableMethod(sSelf, &CacheObserver::StoreCacheFSReported); - NS_DispatchToMainThread(event); - } -} - -void -CacheObserver::StoreCacheFSReported() -{ - mozilla::Preferences::SetInt("browser.cache.disk.filesystem_reported", - sCacheFSReported); -} - -// static -void -CacheObserver::SetHashStatsReported() -{ - sHashStatsReported = true; - - if (!sSelf) { - return; - } - - if (NS_IsMainThread()) { - sSelf->StoreHashStatsReported(); - } else { - nsCOMPtr<nsIRunnable> event = - NewRunnableMethod(sSelf, &CacheObserver::StoreHashStatsReported); - NS_DispatchToMainThread(event); - } -} - -void -CacheObserver::StoreHashStatsReported() -{ - mozilla::Preferences::SetInt("browser.cache.disk.hashstats_reported", - sHashStatsReported); -} - -// static void CacheObserver::ParentDirOverride(nsIFile** aDir) { if (NS_WARN_IF(!aDir)) diff --git a/netwerk/cache2/CacheObserver.h b/netwerk/cache2/CacheObserver.h index 62e5bbc6e..ccdd89030 100644 --- a/netwerk/cache2/CacheObserver.h +++ b/netwerk/cache2/CacheObserver.h @@ -61,12 +61,6 @@ class CacheObserver : public nsIObserver { return sHalfLifeExperiment; } static bool ClearCacheOnShutdown() { return sSanitizeOnShutdown && sClearCacheOnShutdown; } - static bool CacheFSReported() - { return sCacheFSReported; } - static void SetCacheFSReported(); - static bool HashStatsReported() - { return sHashStatsReported; } - static void SetHashStatsReported(); static void ParentDirOverride(nsIFile ** aDir); static bool EntryIsTooBig(int64_t aSize, bool aUsingDisk); @@ -82,8 +76,6 @@ private: static CacheObserver* sSelf; void StoreDiskCacheCapacity(); - void StoreCacheFSReported(); - void StoreHashStatsReported(); void AttachToPreferences(); static uint32_t sUseNewCache; @@ -106,8 +98,6 @@ private: static int32_t sHalfLifeExperiment; static bool sSanitizeOnShutdown; static bool sClearCacheOnShutdown; - static bool sCacheFSReported; - static bool sHashStatsReported; static Atomic<uint32_t, Relaxed> sMaxShutdownIOLag; static Atomic<PRIntervalTime> sShutdownDemandedTime; diff --git a/netwerk/cache2/CacheStorageService.cpp b/netwerk/cache2/CacheStorageService.cpp index 67ef4c526..3ee1e15cd 100644 --- a/netwerk/cache2/CacheStorageService.cpp +++ b/netwerk/cache2/CacheStorageService.cpp @@ -964,8 +964,6 @@ CacheStorageService::RegisterEntry(CacheEntry* aEntry) if (mShutdown || !aEntry->CanRegister()) return; - TelemetryRecordEntryCreation(aEntry); - LOG(("CacheStorageService::RegisterEntry [entry=%p]", aEntry)); MemoryPool& pool = Pool(aEntry->IsUsingDisk()); @@ -983,8 +981,6 @@ CacheStorageService::UnregisterEntry(CacheEntry* aEntry) if (!aEntry->IsRegistered()) return; - TelemetryRecordEntryRemoval(aEntry); - LOG(("CacheStorageService::UnregisterEntry [entry=%p]", aEntry)); MemoryPool& pool = Pool(aEntry->IsUsingDisk()); @@ -2018,105 +2014,6 @@ uint32_t CacheStorageService::CacheQueueSize(bool highPriority) return thread->QueueSize(highPriority); } -// Telementry collection - -namespace { - -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; -} - -} // namespace - -void -CacheStorageService::TelemetryPrune(TimeStamp &now) -{ - static TimeDuration const oneMinute = TimeDuration::FromSeconds(60); - static TimeStamp dontPruneUntil = now + oneMinute; - if (now < dontPruneUntil) - return; - - static TimeDuration const fifteenMinutes = TimeDuration::FromSeconds(900); - for (auto iter = mPurgeTimeStamps.Iter(); !iter.Done(); iter.Next()) { - if (now - iter.Data() > fifteenMinutes) { - // We are not interested in resurrection of entries after 15 minutes - // of time. This is also the limit for the telemetry. - iter.Remove(); - } - } - 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 diff --git a/netwerk/cache2/CacheStorageService.h b/netwerk/cache2/CacheStorageService.h index f40459d84..7e968e359 100644 --- a/netwerk/cache2/CacheStorageService.h +++ b/netwerk/cache2/CacheStorageService.h @@ -188,12 +188,6 @@ private: bool IsForcedValidEntry(nsACString const &aEntryKeyWithContext); private: - // These are helpers for telemetry monitoring of the memory pools. - void TelemetryPrune(TimeStamp &now); - void TelemetryRecordEntryCreation(CacheEntry const* entry); - void TelemetryRecordEntryRemoval(CacheEntry const* entry); - -private: // Following methods are thread safe to call. friend class CacheStorage; @@ -370,12 +364,6 @@ private: uint32_t mWhat; }; - // Used just for telemetry purposes, accessed only on the management thread. - // Note: not included in the memory reporter, this is not expected to be huge - // and also would be complicated to report since reporting happens on the main - // thread but this table is manipulated on the management thread. - nsDataHashtable<nsCStringHashKey, mozilla::TimeStamp> mPurgeTimeStamps; - // nsICacheTesting class IOThreadSuspender : public Runnable { diff --git a/netwerk/cache2/OldWrappers.cpp b/netwerk/cache2/OldWrappers.cpp index 81df88df0..76a4fa6c1 100644 --- a/netwerk/cache2/OldWrappers.cpp +++ b/netwerk/cache2/OldWrappers.cpp @@ -21,7 +21,6 @@ #include "nsNetCID.h" #include "nsNetUtil.h" #include "nsProxyRelease.h" -#include "mozilla/Telemetry.h" static NS_DEFINE_CID(kStreamTransportServiceCID, NS_STREAMTRANSPORTSERVICE_CID); @@ -793,24 +792,6 @@ _OldCacheLoad::Run() return NS_OK; } - if (NS_SUCCEEDED(mStatus)) { - if (mFlags & nsICacheStorage::OPEN_TRUNCATE) { - mozilla::Telemetry::AccumulateTimeDelta( - mozilla::Telemetry::NETWORK_CACHE_V1_TRUNCATE_TIME_MS, - mLoadStart); - } - else if (mNew) { - mozilla::Telemetry::AccumulateTimeDelta( - mozilla::Telemetry::NETWORK_CACHE_V1_MISS_TIME_MS, - mLoadStart); - } - else { - mozilla::Telemetry::AccumulateTimeDelta( - mozilla::Telemetry::NETWORK_CACHE_V1_HIT_TIME_MS, - mLoadStart); - } - } - if (!(mFlags & CHECK_MULTITHREADED)) Check(); |