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

Side by Side Diff: net/disk_cache/eviction.cc

Issue 49027: Disk cache: First pass to make it possible to have... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/disk_cache/eviction.h ('k') | net/disk_cache/stress_cache.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // The eviction policy is a very simple pure LRU, so the elements at the end of 5 // The eviction policy is a very simple pure LRU, so the elements at the end of
6 // the list are evicted until kCleanUpMargin free space is available. There is 6 // the list are evicted until kCleanUpMargin free space is available. There is
7 // only one list in use (Rankings::NO_USE), and elements are sent to the front 7 // only one list in use (Rankings::NO_USE), and elements are sent to the front
8 // of the list whenever they are accessed. 8 // of the list whenever they are accessed.
9 9
10 // The new (in-development) eviction policy ads re-use as a factor to evict 10 // The new (in-development) eviction policy ads re-use as a factor to evict
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 namespace disk_cache { 60 namespace disk_cache {
61 61
62 void Eviction::Init(BackendImpl* backend) { 62 void Eviction::Init(BackendImpl* backend) {
63 // We grab a bunch of info from the backend to make the code a little cleaner 63 // We grab a bunch of info from the backend to make the code a little cleaner
64 // when we're actually doing work. 64 // when we're actually doing work.
65 backend_ = backend; 65 backend_ = backend;
66 rankings_ = &backend->rankings_; 66 rankings_ = &backend->rankings_;
67 header_ = &backend_->data_->header; 67 header_ = &backend_->data_->header;
68 max_size_ = LowWaterAdjust(backend_->max_size_); 68 max_size_ = LowWaterAdjust(backend_->max_size_);
69 new_eviction_ = backend->new_eviction_; 69 new_eviction_ = backend->new_eviction_;
70 first_trim_ = true;
70 } 71 }
71 72
72 void Eviction::TrimCache(bool empty) { 73 void Eviction::TrimCache(bool empty) {
73 if (new_eviction_) 74 if (new_eviction_)
74 return TrimCacheV2(empty); 75 return TrimCacheV2(empty);
75 76
76 Trace("*** Trim Cache ***"); 77 Trace("*** Trim Cache ***");
77 if (backend_->disabled_) 78 if (backend_->disabled_)
78 return; 79 return;
79 80
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 135
135 rankings_->Remove(entry->rankings(), GetListForEntry(entry)); 136 rankings_->Remove(entry->rankings(), GetListForEntry(entry));
136 } 137 }
137 138
138 void Eviction::OnDestroyEntry(EntryImpl* entry) { 139 void Eviction::OnDestroyEntry(EntryImpl* entry) {
139 if (new_eviction_) 140 if (new_eviction_)
140 return OnDestroyEntryV2(entry); 141 return OnDestroyEntryV2(entry);
141 } 142 }
142 143
143 void Eviction::ReportTrimTimes(EntryImpl* entry) { 144 void Eviction::ReportTrimTimes(EntryImpl* entry) {
144 static bool first_time = true; 145 if (first_trim_) {
145 if (first_time) { 146 first_trim_ = false;
146 first_time = false;
147 if (backend_->ShouldReportAgain()) { 147 if (backend_->ShouldReportAgain()) {
148 std::string name(StringPrintf("DiskCache.TrimAge_%d", 148 std::string name(StringPrintf("DiskCache.TrimAge_%d",
149 header_->experiment)); 149 header_->experiment));
150 UMA_HISTOGRAM_HOURS(name.c_str(), 150 UMA_HISTOGRAM_HOURS(name.c_str(),
151 (Time::Now() - entry->GetLastUsed()).InHours()); 151 (Time::Now() - entry->GetLastUsed()).InHours());
152 } 152 }
153 153
154 if (header_->create_time && !header_->lru.filled) { 154 if (header_->create_time && !header_->lru.filled) {
155 // This is the first entry that we have to evict, generate some noise. 155 // This is the first entry that we have to evict, generate some noise.
156 header_->lru.filled = 1; 156 header_->lru.filled = 1;
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 header_->lru.sizes[Rankings::DELETED]; 414 header_->lru.sizes[Rankings::DELETED];
415 // Start by having each list to be roughly the same size. 415 // Start by having each list to be roughly the same size.
416 if (header_->lru.sizes[0] > data_entries / 3) 416 if (header_->lru.sizes[0] > data_entries / 3)
417 return 0; 417 return 0;
418 if (header_->lru.sizes[1] > data_entries / 3) 418 if (header_->lru.sizes[1] > data_entries / 3)
419 return 1; 419 return 1;
420 return 2; 420 return 2;
421 } 421 }
422 422
423 } // namespace disk_cache 423 } // namespace disk_cache
OLDNEW
« no previous file with comments | « net/disk_cache/eviction.h ('k') | net/disk_cache/stress_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698