1%{ @file cache_ttl_hlru.m
2 % @brief TTL (characteristic-time) approximation
for h-LRU / LRU(m) caches
4 % @author LINE Development Team
8 % @brief Steady-state list occupancy probabilities
for an h-LRU cache
11 % Computes
the characteristic-time (TTL) approximation of
the list-based
12 % h-LRU (LRU(m)) replacement policy: h LRU lists of capacities m(1..h), a
13 % miss inserts
the item at
the head of list 1, a hit in list l exchanges
14 %
the item with
the tail of list l+1 (Gast and Van Houdt, SIGMETRICS 2015).
15 % Under
the approximation each list l has a characteristic time T(l);
the
16 % level process of an item with request rate lam
is a birth-death chain
17 % with up-probability 1-e(l) and down-probability e(l), e(l)=exp(-lam*T(l)),
18 % giving pi(l) proportional to prod_{s<=l} (1-e(s))/e(s). For h=1
this
19 % reduces exactly to
the Che approximation
for LRU.
23 % pij = cache_ttl_hlru(lambda, m)
28 % <tr><th>Name<th>Description
29 % <tr><td>lambda<td>(u x n x h+1) per-class per-item request rates (as built
30 % by solver_mva_cache_analyzer; identical across lists)
31 % <tr><td>m<td>(1 x h) list capacities
36 % <tr><th>Name<th>Description
37 % <tr><td>pij<td>(n x h+1) probabilities;
column 1 = not cached,
column
41function pij = cache_ttl_hlru(lambda, m)
42% aggregate
the request rate of each item over
the user classes;
the
43% analyzer replicates
the same rate on every list slice, so read slice 2
44lam = zeros(size(lambda,2),1);
45for v = 1:size(lambda,1)
46 lam = lam + reshape(lambda(v,:,min(2,size(lambda,3))), [], 1);
52% characteristic times solved by per-list bisection (Gauss-Seidel sweeps):
53% sum_k pi_l(k; T) = m(l), with sum_k pi_l increasing in T(l)
54T = ones(1,h) / max(mean(lam), GlobalConstants.FineTol);
56for sweep = 1:maxSweeps
60 hi = max(T(l), 1/max(mean(lam), GlobalConstants.FineTol));
61 % grow hi until
the list-l occupancy reaches its capacity
62 while cache_hlru_occ(lam, T, l, hi, h) < m(l) && hi < 1e12
67 if cache_hlru_occ(lam, T, l, mid, h) < m(l)
75 if max(abs(T-Told)./max(Told,GlobalConstants.Zero)) < GlobalConstants.FineTol
80pij = cache_hlru_levelprobs(lam, T, h); % (n x h+1): [pi_0, pi_1..pi_h]
83function occ = cache_hlru_occ(lam, T, l, Tl, h)
84% total occupancy of list l when its characteristic time
is Tl
86P = cache_hlru_levelprobs(lam, T, h);
90function
P = cache_hlru_levelprobs(lam, T, h)
91% birth-death level probabilities: pi_l ~ prod_{s<=l} (1-e_s)/e_s
98 e = exp(-lam(k)*T(l));
99 w(1+l) = w(l) * (1-e)/max(e, GlobalConstants.Zero);