diff options
Diffstat (limited to 'Documentation/device-mapper/cache-policies.txt')
-rw-r--r-- | Documentation/device-mapper/cache-policies.txt | 67 |
1 files changed, 64 insertions, 3 deletions
diff --git a/Documentation/device-mapper/cache-policies.txt b/Documentation/device-mapper/cache-policies.txt index 0d124a971801..d9246a32e673 100644 --- a/Documentation/device-mapper/cache-policies.txt +++ b/Documentation/device-mapper/cache-policies.txt | |||
@@ -25,10 +25,10 @@ trying to see when the io scheduler has let the ios run. | |||
25 | Overview of supplied cache replacement policies | 25 | Overview of supplied cache replacement policies |
26 | =============================================== | 26 | =============================================== |
27 | 27 | ||
28 | multiqueue | 28 | multiqueue (mq) |
29 | ---------- | 29 | --------------- |
30 | 30 | ||
31 | This policy is the default. | 31 | This policy has been deprecated in favor of the smq policy (see below). |
32 | 32 | ||
33 | The multiqueue policy has three sets of 16 queues: one set for entries | 33 | The multiqueue policy has three sets of 16 queues: one set for entries |
34 | waiting for the cache and another two for those in the cache (a set for | 34 | waiting for the cache and another two for those in the cache (a set for |
@@ -73,6 +73,67 @@ If you're trying to quickly warm a new cache device you may wish to | |||
73 | reduce these to encourage promotion. Remember to switch them back to | 73 | reduce these to encourage promotion. Remember to switch them back to |
74 | their defaults after the cache fills though. | 74 | their defaults after the cache fills though. |
75 | 75 | ||
76 | Stochastic multiqueue (smq) | ||
77 | --------------------------- | ||
78 | |||
79 | This policy is the default. | ||
80 | |||
81 | The stochastic multi-queue (smq) policy addresses some of the problems | ||
82 | with the multiqueue (mq) policy. | ||
83 | |||
84 | The smq policy (vs mq) offers the promise of less memory utilization, | ||
85 | improved performance and increased adaptability in the face of changing | ||
86 | workloads. SMQ also does not have any cumbersome tuning knobs. | ||
87 | |||
88 | Users may switch from "mq" to "smq" simply by appropriately reloading a | ||
89 | DM table that is using the cache target. Doing so will cause all of the | ||
90 | mq policy's hints to be dropped. Also, performance of the cache may | ||
91 | degrade slightly until smq recalculates the origin device's hotspots | ||
92 | that should be cached. | ||
93 | |||
94 | Memory usage: | ||
95 | The mq policy uses a lot of memory; 88 bytes per cache block on a 64 | ||
96 | bit machine. | ||
97 | |||
98 | SMQ uses 28bit indexes to implement it's data structures rather than | ||
99 | pointers. It avoids storing an explicit hit count for each block. It | ||
100 | has a 'hotspot' queue rather than a pre cache which uses a quarter of | ||
101 | the entries (each hotspot block covers a larger area than a single | ||
102 | cache block). | ||
103 | |||
104 | All these mean smq uses ~25bytes per cache block. Still a lot of | ||
105 | memory, but a substantial improvement nontheless. | ||
106 | |||
107 | Level balancing: | ||
108 | MQ places entries in different levels of the multiqueue structures | ||
109 | based on their hit count (~ln(hit count)). This means the bottom | ||
110 | levels generally have the most entries, and the top ones have very | ||
111 | few. Having unbalanced levels like this reduces the efficacy of the | ||
112 | multiqueue. | ||
113 | |||
114 | SMQ does not maintain a hit count, instead it swaps hit entries with | ||
115 | the least recently used entry from the level above. The over all | ||
116 | ordering being a side effect of this stochastic process. With this | ||
117 | scheme we can decide how many entries occupy each multiqueue level, | ||
118 | resulting in better promotion/demotion decisions. | ||
119 | |||
120 | Adaptability: | ||
121 | The MQ policy maintains a hit count for each cache block. For a | ||
122 | different block to get promoted to the cache it's hit count has to | ||
123 | exceed the lowest currently in the cache. This means it can take a | ||
124 | long time for the cache to adapt between varying IO patterns. | ||
125 | Periodically degrading the hit counts could help with this, but I | ||
126 | haven't found a nice general solution. | ||
127 | |||
128 | SMQ doesn't maintain hit counts, so a lot of this problem just goes | ||
129 | away. In addition it tracks performance of the hotspot queue, which | ||
130 | is used to decide which blocks to promote. If the hotspot queue is | ||
131 | performing badly then it starts moving entries more quickly between | ||
132 | levels. This lets it adapt to new IO patterns very quickly. | ||
133 | |||
134 | Performance: | ||
135 | Testing SMQ shows substantially better performance than MQ. | ||
136 | |||
76 | cleaner | 137 | cleaner |
77 | ------- | 138 | ------- |
78 | 139 | ||