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