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

Side by Side Diff: net/disk_cache/blockfile/eviction_v3.cc

Issue 121643003: Reorganize net/disk_cache into backend specific directories. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase & remediate Created 6 years, 10 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/blockfile/eviction_v3.h ('k') | net/disk_cache/blockfile/experiments.h » ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 adds re-use as a factor to evict 10 // The new (in-development) eviction policy adds re-use as a factor to evict
11 // an entry. The story so far: 11 // an entry. The story so far:
12 12
13 // Entries are linked on separate lists depending on how often they are used. 13 // Entries are linked on separate lists depending on how often they are used.
14 // When we see an element for the first time, it goes to the NO_USE list; if 14 // When we see an element for the first time, it goes to the NO_USE list; if
15 // the object is reused later on, we move it to the LOW_USE list, until it is 15 // the object is reused later on, we move it to the LOW_USE list, until it is
16 // used kHighUse times, at which point it is moved to the HIGH_USE list. 16 // used kHighUse times, at which point it is moved to the HIGH_USE list.
17 // Whenever an element is evicted, we move it to the DELETED list so that if the 17 // Whenever an element is evicted, we move it to the DELETED list so that if the
18 // element is accessed again, we remember the fact that it was already stored 18 // element is accessed again, we remember the fact that it was already stored
19 // and maybe in the future we don't evict that element. 19 // and maybe in the future we don't evict that element.
20 20
21 // When we have to evict an element, first we try to use the last element from 21 // When we have to evict an element, first we try to use the last element from
22 // the NO_USE list, then we move to the LOW_USE and only then we evict an entry 22 // the NO_USE list, then we move to the LOW_USE and only then we evict an entry
23 // from the HIGH_USE. We attempt to keep entries on the cache for at least 23 // from the HIGH_USE. We attempt to keep entries on the cache for at least
24 // kTargetTime hours (with frequently accessed items stored for longer periods), 24 // kTargetTime hours (with frequently accessed items stored for longer periods),
25 // but if we cannot do that, we fall-back to keep each list roughly the same 25 // but if we cannot do that, we fall-back to keep each list roughly the same
26 // size so that we have a chance to see an element again and move it to another 26 // size so that we have a chance to see an element again and move it to another
27 // list. 27 // list.
28 28
29 #include "net/disk_cache/v3/eviction_v3.h" 29 #include "net/disk_cache/blockfile/eviction_v3.h"
30 30
31 #include "base/bind.h" 31 #include "base/bind.h"
32 #include "base/compiler_specific.h" 32 #include "base/compiler_specific.h"
33 #include "base/logging.h" 33 #include "base/logging.h"
34 #include "base/message_loop/message_loop.h" 34 #include "base/message_loop/message_loop.h"
35 #include "base/strings/string_util.h" 35 #include "base/strings/string_util.h"
36 #include "base/time/time.h" 36 #include "base/time/time.h"
37 #include "net/disk_cache/experiments.h" 37 #include "net/disk_cache/blockfile/backend_impl_v3.h"
38 #include "net/disk_cache/trace.h" 38 #include "net/disk_cache/blockfile/entry_impl_v3.h"
39 #include "net/disk_cache/v3/backend_impl_v3.h" 39 #include "net/disk_cache/blockfile/experiments.h"
40 #include "net/disk_cache/v3/entry_impl_v3.h" 40 #include "net/disk_cache/blockfile/trace.h"
41 41
42 // Define BLOCKFILE_BACKEND_IMPL_OBJ to be a disk_cache::BackendImpl* in order 42 // Define BLOCKFILE_BACKEND_IMPL_OBJ to be a disk_cache::BackendImpl* in order
43 // to use the CACHE_UMA histogram macro. 43 // to use the CACHE_UMA histogram macro.
44 #define BLOCKFILE_BACKEND_IMPL_OBJ backend_ 44 #define BLOCKFILE_BACKEND_IMPL_OBJ backend_
rvargas (doing something else) 2014/02/11 20:15:12 I know I've mentioned it before, but seeing the sa
45 #include "net/disk_cache/v3/histogram_macros.h" 45 #include "net/disk_cache/blockfile/histogram_macros_v3.h"
46 46
47 using base::Time; 47 using base::Time;
48 using base::TimeTicks; 48 using base::TimeTicks;
49 49
50 namespace { 50 namespace {
51 51
52 const int kCleanUpMargin = 1024 * 1024; 52 const int kCleanUpMargin = 1024 * 1024;
53 53
54 #if defined(V3_NOT_JUST_YET_READY) 54 #if defined(V3_NOT_JUST_YET_READY)
55 const int kHighUse = 10; // Reuse count to be on the HIGH_USE list. 55 const int kHighUse = 10; // Reuse count to be on the HIGH_USE list.
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 if (last3.get()) 505 if (last3.get())
506 CACHE_UMA(AGE, "HighUseAge", 0, 506 CACHE_UMA(AGE, "HighUseAge", 0,
507 Time::FromInternalValue(last3.get()->Data()->last_used)); 507 Time::FromInternalValue(last3.get()->Data()->last_used));
508 if (last4.get()) 508 if (last4.get())
509 CACHE_UMA(AGE, "DeletedAge", 0, 509 CACHE_UMA(AGE, "DeletedAge", 0,
510 Time::FromInternalValue(last4.get()->Data()->last_used)); 510 Time::FromInternalValue(last4.get()->Data()->last_used));
511 } 511 }
512 #endif // defined(V3_NOT_JUST_YET_READY). 512 #endif // defined(V3_NOT_JUST_YET_READY).
513 513
514 } // namespace disk_cache 514 } // namespace disk_cache
OLDNEW
« no previous file with comments | « net/disk_cache/blockfile/eviction_v3.h ('k') | net/disk_cache/blockfile/experiments.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698