LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
cache_lrum_map_levelstats.m
1%{ @file cache_lrum_map_levelstats.m
2 % @brief Per-item level statistics for the LRU(m)-MAP TTL approximation
3 %
4 % @author LINE Development Team
5%}
6
7%{
8 % @brief Level statistics of one item's embedded (list, phase) chain
9 %
10 % @details
11 % Evaluates eqs. (5)-(9) of Gast and Van Houdt (Performance Evaluation
12 % 2017) for a single item with MAP request process (D0, D1) and
13 % characteristic times T: the R-recursions of the embedded chain, the
14 % level-0 boundary vector pi_0 (left Perron vector of R_1 expm(D0 T_1)),
15 % the time-stationary level probabilities, and the request-weighted hit
16 % fractions per list.
17 %
18 % @par Syntax:
19 % @code
20 % [prob, occ, hitfrac] = cache_lrum_map_levelstats(D0, D1, T)
21 % @endcode
22 %
23 % @par Returns:
24 % <table>
25 % <tr><th>Name<th>Description
26 % <tr><td>prob<td>(1,h+1) time-stationary probability of level 0..h
27 % <tr><td>occ<td>(1,h) occupancy contribution of lists 1..h (= prob(2:end))
28 % <tr><td>hitfrac<td>(1,h) fraction of the item's requests hitting in list l
29 % </table>
30%}
31function [prob, occ, hitfrac] = cache_lrum_map_levelstats(D0, D1, T)
32h = numel(T);
33d = size(D0, 1);
34iD0 = inv(-D0);
35
36E = cell(1, h); % expm(D0*T_l)
37A = cell(1, h); % A_l of the paper
38Nh = cell(1, h);
39for l = 1:h
40 E{l} = expm(D0 * T(l));
41 Nh{l} = (eye(d) - E{l}) * iD0; %#ok<MINV>
42 A{l} = Nh{l} * D1;
43end
44A0 = iD0 * D1; %#ok<MINV>
45N0 = iD0;
46
47% R recursion, eqs. (6)-(7): R{l} is the paper's R_l over lists 1..h
48R = cell(1, h);
49for l = h:-1:1
50 if l == h
51 if h == 1
52 Aprev = A0;
53 else
54 Aprev = A{h-1};
55 end
56 R{l} = Aprev / (eye(d) - A{h});
57 elseif l == 1
58 R{l} = A0 / (eye(d) - R{l+1} * E{l+1});
59 else
60 R{l} = A{l-1} / (eye(d) - R{l+1} * E{l+1});
61 end
62end
63
64% pi_0: left Perron vector of R_1 expm(D0 T_1) (level-0 balance)
65M = R{1} * E{1};
66[V, D] = eig(M');
67[~, idx] = max(real(diag(D)));
68pi0 = real(V(:, idx))';
69pi0 = pi0 / sum(pi0);
70
71pih = cell(1, h);
72pih{1} = pi0 * R{1};
73for l = 2:h
74 pih{l} = pih{l-1} * R{l};
75end
76
77e = ones(d, 1);
78holding = zeros(1, h+1);
79holding(1) = pi0 * N0 * e;
80for l = 1:h
81 holding(1+l) = pih{l} * Nh{l} * e;
82end
83denom = sum(holding);
84prob = holding / denom;
85occ = prob(2:end);
86
87% request-weighted hit fractions: throughput of hits in list l over the
88% item's stationary request rate
89Q = D0 + D1;
90piphase = ctmc_solve(Q);
91lam = piphase * D1 * e;
92hitfrac = zeros(1, h);
93for l = 1:h
94 hitfrac(l) = (pih{l} * Nh{l} * D1 * e) / denom;
95end
96if lam > 0
97 hitfrac = hitfrac / lam;
98else
99 hitfrac = zeros(1, h);
100end
101end
Definition Station.m:245