1%{ @file cache_lrum_map_levelstats.m
2 % @brief Per-item level statistics
for the LRU(m)-MAP TTL approximation
4 % @author LINE Development Team
8 % @brief Level statistics of one item
's embedded (list, phase) chain
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
20 % [prob, occ, hitfrac] = cache_lrum_map_levelstats(D0, D1, T)
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
31function [prob, occ, hitfrac] = cache_lrum_map_levelstats(D0, D1, T)
36E = cell(1, h); % expm(D0*T_l)
37A = cell(1, h); % A_l of
the paper
40 E{l} = expm(D0 * T(l));
41 Nh{l} = (eye(d) - E{l}) * iD0; %#ok<MINV>
44A0 = iD0 * D1; %#ok<MINV>
47% R recursion, eqs. (6)-(7): R{l}
is the paper
's R_l over lists 1..h
56 R{l} = Aprev / (eye(d) - A{h});
58 R{l} = A0 / (eye(d) - R{l+1} * E{l+1});
60 R{l} = A{l-1} / (eye(d) - R{l+1} * E{l+1});
64% pi_0: left Perron vector of R_1 expm(D0 T_1) (level-0 balance)
67[~, idx] = max(real(diag(D)));
68pi0 = real(V(:, idx))
';
74 pih{l} = pih{l-1} * R{l};
78holding = zeros(1, h+1);
79holding(1) = pi0 * N0 * e;
81 holding(1+l) = pih{l} * Nh{l} * e;
84prob = holding / denom;
87% request-weighted hit fractions: throughput of hits in list l over the
88% item's stationary request rate
90piphase = ctmc_solve(Q);
91lam = piphase * D1 * e;
94 hitfrac(l) = (pih{l} * Nh{l} * D1 * e) / denom;
97 hitfrac = hitfrac / lam;
99 hitfrac = zeros(1, h);