summaryrefslogtreecommitdiff
path: root/netwerk
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-09-29 22:56:15 +0200
committerwolfbeast <mcwerewolf@gmail.com>2018-09-29 22:56:15 +0200
commit0b16007427aac4bb94643c6ea4cc79b81010765a (patch)
treeb53266233b12724adb28213765e5abc89af8df53 /netwerk
parent347aea437facd5324b3d8d27c587d8054e9b8b9a (diff)
downloaduxp-0b16007427aac4bb94643c6ea4cc79b81010765a.tar.gz
Remove telemetry to find optimal cache entry hash size
Tag #21.
Diffstat (limited to 'netwerk')
-rw-r--r--netwerk/cache2/CacheIndex.cpp75
-rw-r--r--netwerk/cache2/CacheIndex.h2
-rw-r--r--netwerk/cache2/CacheObserver.cpp29
-rw-r--r--netwerk/cache2/CacheObserver.h5
4 files changed, 0 insertions, 111 deletions
diff --git a/netwerk/cache2/CacheIndex.cpp b/netwerk/cache2/CacheIndex.cpp
index 1009aeaf8a..c85d271cc2 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"
@@ -3167,11 +3166,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,75 +3714,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);
-
- 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 dc72c346f7..e51c1a0dec 100644
--- a/netwerk/cache2/CacheIndex.h
+++ b/netwerk/cache2/CacheIndex.h
@@ -918,8 +918,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 6b6d893957..51afaf3a14 100644
--- a/netwerk/cache2/CacheObserver.cpp
+++ b/netwerk/cache2/CacheObserver.cpp
@@ -89,9 +89,6 @@ 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);
@@ -357,32 +354,6 @@ CacheObserver::StoreCacheFSReported()
}
// 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 62e5bbc6ec..ee989e4d87 100644
--- a/netwerk/cache2/CacheObserver.h
+++ b/netwerk/cache2/CacheObserver.h
@@ -64,9 +64,6 @@ class CacheObserver : public nsIObserver
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);
@@ -83,7 +80,6 @@ private:
void StoreDiskCacheCapacity();
void StoreCacheFSReported();
- void StoreHashStatsReported();
void AttachToPreferences();
static uint32_t sUseNewCache;
@@ -107,7 +103,6 @@ private:
static bool sSanitizeOnShutdown;
static bool sClearCacheOnShutdown;
static bool sCacheFSReported;
- static bool sHashStatsReported;
static Atomic<uint32_t, Relaxed> sMaxShutdownIOLag;
static Atomic<PRIntervalTime> sShutdownDemandedTime;