summaryrefslogtreecommitdiffstats
path: root/net/disk_cache
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-16 21:45:22 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-16 21:45:22 +0000
commitaea6132752c6319a12ac9a20aaccf22abf1ed5cd (patch)
treecc0aa01026946ba186271954355ee86b36c6b8f8 /net/disk_cache
parent095657f57d46cac4a9bc07a716da4e9563829909 (diff)
downloadchromium_src-aea6132752c6319a12ac9a20aaccf22abf1ed5cd.zip
chromium_src-aea6132752c6319a12ac9a20aaccf22abf1ed5cd.tar.gz
chromium_src-aea6132752c6319a12ac9a20aaccf22abf1ed5cd.tar.bz2
Disk cache: Don't walk the lists of entries at startup.
BUG=none TEST=none Review URL: https://codereview.chromium.org/11308063 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@168296 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache')
-rw-r--r--net/disk_cache/backend_impl.cc3
-rw-r--r--net/disk_cache/rankings.cc212
-rw-r--r--net/disk_cache/rankings.h7
3 files changed, 0 insertions, 222 deletions
diff --git a/net/disk_cache/backend_impl.cc b/net/disk_cache/backend_impl.cc
index e7fd5d6..2e42c55 100644
--- a/net/disk_cache/backend_impl.cc
+++ b/net/disk_cache/backend_impl.cc
@@ -486,9 +486,6 @@ int BackendImpl::SyncInit() {
disabled_ = !rankings_.Init(this, new_eviction_);
- if (!disabled_ && !(user_flags_ & kNoRandom) && base::RandInt(0, 99) < 2)
- rankings_.SelfCheck(); // Ignore return value for now.
-
#if defined(STRESS_CACHE_EXTENDED_VALIDATION)
trace_object_->EnableTracing(false);
int sc = SelfCheck();
diff --git a/net/disk_cache/rankings.cc b/net/disk_cache/rankings.cc
index 58cfa11..e14ee02 100644
--- a/net/disk_cache/rankings.cc
+++ b/net/disk_cache/rankings.cc
@@ -496,7 +496,6 @@ void Rankings::TrackRankingsBlock(CacheRankingsBlock* node,
int Rankings::SelfCheck() {
int total = 0;
int error = 0;
- base::TimeTicks start = base::TimeTicks::Now();
for (int i = 0; i < LAST_ELEMENT; i++) {
int partial = CheckList(static_cast<List>(i));
if (partial < 0 && !error)
@@ -504,9 +503,7 @@ int Rankings::SelfCheck() {
else if (partial > 0)
total += partial;
}
- CACHE_UMA(AGE_MS, "ListSelfCheckTime", 0, start);
- QuickListCheck();
return error ? error : total;
}
@@ -803,65 +800,6 @@ int Rankings::CheckList(List list) {
if (rv == ERR_NO_ERROR)
return head_items;
- DetailedCheck(list);
-
- Addr last3, last4;
- int tail_items;
- int rv2 = CheckListSection(list, last1, last2, false, // Tail to head.
- &last3, &last4, &tail_items);
-
- if (!head_items && rv != ERR_INVALID_NEXT)
- rv = ERR_INVALID_HEAD;
-
- if (!tail_items && rv2 != ERR_INVALID_NEXT)
- rv2 = ERR_INVALID_HEAD;
-
- int expected = control_data_->sizes[list];
- int total_items = head_items + tail_items;
-
- if (!count_lists_) {
- // There's no expected value, so we'll use something else. If it looks like
- // we can rebuild the list, we lost at least one entry.
- if (last3 == last1 || last3 == last2 || last4 == last1 || last4 == last2)
- expected = total_items + 1;
- }
-
- if (expected) {
- // This histogram has an offset so that we can see small negative values. In
- // practice, it is linear from -9 to +8.
- UMA_HISTOGRAM_CUSTOM_COUNTS("DiskCache.LostItems(Plus10)",
- expected - total_items + 10, 0, 2000, 75);
- }
-
- const int kInvalidHead = 1;
- const int kInvalidTail = 2;
- const int kInvalidHeadAndTail = 3;
- const int kOneInvalidEntry = 4;
- const int kTwoInvalidEntries = 5;
- const int kOneInvalidLink = 6;
- const int kTwoInvalidLinks = 7;
- const int kOneInvalidEntryOneInvalidLink = 8;
-
- int error = list * 10;
- if (rv == ERR_INVALID_HEAD && rv2 != ERR_INVALID_HEAD) {
- error += kInvalidHead;
- } else if (rv == ERR_INVALID_HEAD && rv2 == ERR_INVALID_HEAD) {
- error += kInvalidHeadAndTail;
- } else if (rv != ERR_INVALID_HEAD && rv2 == ERR_INVALID_HEAD) {
- error += kInvalidTail;
- } else if (rv == ERR_INVALID_ENTRY && rv2 == ERR_INVALID_ENTRY) {
- error += kTwoInvalidEntries;
- } else if (rv == ERR_INVALID_ENTRY && rv2 == 0) {
- error += kOneInvalidEntry;
- } else if (rv == ERR_INVALID_ENTRY || rv2 == ERR_INVALID_ENTRY) {
- error += kOneInvalidEntryOneInvalidLink;
- } else if (rv2 != ERR_NO_ERROR) {
- error += kTwoInvalidLinks;
- } else {
- error += kOneInvalidLink;
- }
- CACHE_UMA(CACHE_ERROR, "ListErrorWithListId", 0, error);
-
return rv;
}
@@ -913,156 +851,6 @@ int Rankings::CheckListSection(List list, Addr end1, Addr end2, bool forward,
return ERR_NO_ERROR;
}
-// TODO(rvargas): remove when we figure why we have corrupt heads.
-// This is basically the same code as CheckListSection except that it starts
-// at a random node and it iterates until it finds something looking like the
-// last node.
-int Rankings::CheckListSegment(Addr start,
- bool forward,
- Addr* last,
- int* num_items) {
- Addr current = start;
- *last = current;
- *num_items = 0;
- if (!current.is_initialized())
- return ERR_NO_ERROR;
-
- if (!current.SanityCheckForRankings())
- return ERR_INVALID_HEAD;
-
- scoped_ptr<CacheRankingsBlock> node;
- Addr prev_addr;
- const int kMaxItemsToCheck = 100000;
- do {
- node.reset(new CacheRankingsBlock(backend_->File(current), current));
- node->Load();
- // The head may point to the wrong node so don't use SanityCheck().
- if (ExplodedSanityCheck(node.get()))
- return ERR_INVALID_ENTRY;
-
- CacheAddr next = forward ? node->Data()->next : node->Data()->prev;
- CacheAddr prev = forward ? node->Data()->prev : node->Data()->next;
-
- if (prev_addr.is_initialized() && prev != prev_addr.value())
- return ERR_INVALID_PREV;
-
- Addr next_addr(next);
- if (!next_addr.SanityCheckForRankings())
- return ERR_INVALID_NEXT;
-
- prev_addr = current;
- current = next_addr;
- *last = current;
- (*num_items)++;
-
- if (next_addr == prev_addr)
- return ERR_NO_ERROR;
- } while (*num_items < kMaxItemsToCheck);
- return ERR_NO_ERROR;
-}
-
-// TODO(rvargas): remove when we figure why we have corrupt heads.
-void Rankings::DetailedCheck(List list) {
- int rv = CheckHeadAndTail(list);
- Addr last;
- int num_items = 0;
- int error = ERR_NO_ERROR;
- if (rv == ERR_INVALID_PREV) {
- error = CheckListSegment(heads_[list], false, &last, &num_items);
- } else if (rv == ERR_INVALID_NEXT) {
- error = CheckListSegment(tails_[list], true, &last, &num_items);
- } else if (rv == ERR_INVALID_ENTRY) {
- scoped_ptr<CacheRankingsBlock> head;
- head.reset(new CacheRankingsBlock(backend_->File(heads_[list]),
- heads_[list]));
- head->Load();
- int result = ExplodedSanityCheck(head.get());
- if (!result) {
- scoped_ptr<CacheRankingsBlock> tail;
- tail.reset(new CacheRankingsBlock(backend_->File(tails_[list]),
- tails_[list]));
- tail->Load();
- result = ExplodedSanityCheck(tail.get());
- }
- CACHE_UMA(CACHE_ERROR, "DetailedListCheckSanity", 0, result);
- return;
- }
- CACHE_UMA(CACHE_ERROR, "DetailedListCheck", 0, -error);
- CACHE_UMA(COUNTS, "DetailedListCheckCount", 0, num_items);
-}
-
-// TODO(rvargas): remove when we figure why we have corrupt heads.
-// This is basically SanityCheck().
-int Rankings::ExplodedSanityCheck(CacheRankingsBlock* node) {
- int error = 0;
- const int kBlockHashFailed = 1;
- if (!node->VerifyHash())
- error = kBlockHashFailed;
-
- const RankingsNode* data = node->Data();
- const int kHasOnlyOneOfNextAndPrev = 2;
- if ((!data->next && data->prev) || (data->next && !data->prev))
- error += kHasOnlyOneOfNextAndPrev;
-
- const int kHasNeitherNextNorPrev = 4;
- if (!data->next && !data->prev)
- error += kHasNeitherNextNorPrev;
-
- Addr next_addr(data->next);
- Addr prev_addr(data->prev);
- const int kFailsSanityCheck = 8;
- if ((data->next &&
- (!next_addr.SanityCheck() || next_addr.file_type() != RANKINGS)) ||
- (data->prev &&
- (!prev_addr.SanityCheck() || prev_addr.file_type() != RANKINGS))) {
- error += kFailsSanityCheck;
- }
-
- return error;
-}
-
-// TODO(rvargas): remove when we figure why we have corrupt heads.
-void Rankings::QuickListCheck() {
- for (int i = 0; i < LAST_ELEMENT; i++) {
- int rv = CheckHeadAndTail(static_cast<List>(i));
- CACHE_UMA(CACHE_ERROR, "QuickListCheck", 0, rv * -1);
- }
-}
-
-int Rankings::CheckHeadAndTail(List list) {
- Addr head_addr = heads_[list];
- Addr tail_addr = tails_[list];
-
- if (!head_addr.is_initialized() && !tail_addr.is_initialized())
- return ERR_NO_ERROR;
-
- if (!head_addr.SanityCheckForRankings())
- return ERR_INVALID_HEAD;
-
- if (!tail_addr.SanityCheckForRankings())
- return ERR_INVALID_TAIL;
-
- scoped_ptr<CacheRankingsBlock> head;
- head.reset(new CacheRankingsBlock(backend_->File(head_addr), head_addr));
- head->Load();
- if (!SanityCheck(head.get(), true)) // From list.
- return ERR_INVALID_ENTRY;
-
- scoped_ptr<CacheRankingsBlock> tail;
- tail.reset(new CacheRankingsBlock(backend_->File(tail_addr), tail_addr));
- tail->Load();
- if (!SanityCheck(tail.get(), true)) // From list.
- return ERR_INVALID_ENTRY;
-
- if (head->Data()->prev != head_addr.value())
- return ERR_INVALID_PREV;
-
- if (tail->Data()->next != tail_addr.value())
- return ERR_INVALID_NEXT;
-
- return ERR_NO_ERROR;
-}
-
bool Rankings::IsHead(CacheAddr addr, List* list) const {
for (int i = 0; i < LAST_ELEMENT; i++) {
if (addr == heads_[i].value()) {
diff --git a/net/disk_cache/rankings.h b/net/disk_cache/rankings.h
index 3f0fe51..eaa6c2f 100644
--- a/net/disk_cache/rankings.h
+++ b/net/disk_cache/rankings.h
@@ -179,13 +179,6 @@ class Rankings {
// and the addresses of the last nodes visited.
int CheckListSection(List list, Addr end1, Addr end2, bool forward,
Addr* last, Addr* second_last, int* num_items);
- int CheckListSegment(Addr start, bool forward, Addr* last, int* num_items);
- void DetailedCheck(List list);
- static int ExplodedSanityCheck(CacheRankingsBlock* node);
- void QuickListCheck();
-
- // Returns an error code as appropriate.
- int CheckHeadAndTail(List list);
// Returns true if addr is the head or tail of any list. When there is a
// match |list| will contain the list number for |addr|.