Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Unified Diff: net/disk_cache/eviction.cc

Issue 6967006: Disk cache: Make sure the list of unused entries is not (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fix stupid gcc warning Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« net/disk_cache/eviction.h ('K') | « net/disk_cache/eviction.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/eviction.cc
===================================================================
--- net/disk_cache/eviction.cc (revision 84533)
+++ net/disk_cache/eviction.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -116,7 +116,7 @@
Rankings::ScopedRankingsBlock next(rankings_,
rankings_->GetPrev(node.get(), Rankings::NO_USE));
int target_size = empty ? 0 : max_size_;
- while (header_->num_bytes > target_size && next.get()) {
+ while ((header_->num_bytes > target_size && next.get()) || test_mode_) {
// The iterator could be invalidated within EvictEntry().
if (!next->HasData())
break;
@@ -304,15 +304,8 @@
}
// If we are not meeting the time targets lets move on to list length.
- if (!empty && Rankings::LAST_ELEMENT == list) {
- list = SelectListByLenght();
- // Make sure that frequently used items are kept for a minimum time; we know
- // that this entry is not older than its current target, but it must be at
- // least older than the target for list 0 (kTargetTime).
- if ((Rankings::HIGH_USE == list || Rankings::LOW_USE == list) &&
- !NodeIsOldEnough(next[list].get(), 0))
- list = 0;
- }
+ if (!empty && Rankings::LAST_ELEMENT == list)
+ list = SelectListByLenght(next);
if (empty)
list = 0;
@@ -321,7 +314,8 @@
int target_size = empty ? 0 : max_size_;
for (; list < kListsToSearch; list++) {
- while (header_->num_bytes > target_size && next[list].get()) {
+ while ((header_->num_bytes > target_size && next[list].get()) ||
+ test_mode_) {
// The iterator could be invalidated within EvictEntry().
if (!next[list]->HasData())
break;
@@ -514,15 +508,24 @@
return (Time::Now() - used).InHours() > kTargetTime * multiplier;
}
-int Eviction::SelectListByLenght() {
+int Eviction::SelectListByLenght(Rankings::ScopedRankingsBlock* next) {
int data_entries = header_->num_entries -
header_->lru.sizes[Rankings::DELETED];
// Start by having each list to be roughly the same size.
if (header_->lru.sizes[0] > data_entries / 3)
return 0;
- if (header_->lru.sizes[1] > data_entries / 3)
- return 1;
- return 2;
+
+ int list = (header_->lru.sizes[1] > data_entries / 3) ? 1 : 2;
+
+ // Make sure that frequently used items are kept for a minimum time; we know
+ // that this entry is not older than its current target, but it must be at
+ // least older than the target for list 0 (kTargetTime), as long as we don't
+ // exhaust list 0.
+ if (!NodeIsOldEnough(next[list].get(), 0) &&
+ header_->lru.sizes[0] > data_entries / 10)
+ list = 0;
+
+ return list;
}
void Eviction::ReportListStats() {
« net/disk_cache/eviction.h ('K') | « net/disk_cache/eviction.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698