LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
fj_mg1_respt_moments.m
1%{ @file fj_mg1_respt_moments.m
2 % @brief Mean and variance of the M/G/1 response time, as ForkTail inputs
3 %
4 % @author LINE Development Team
5%}
6
7%{
8 % @brief Mean and variance of the M/G/1 response time, as ForkTail inputs
9 %
10 % @details
11 % Closes the white-box route of fj_tail_forktail for a fork branch that is
12 % an M/G/1 FCFS queue, from the first three moments of its service time:
13 %
14 % E[T] = E[S]*(1 + rho/(1-rho) * (1+SCV_S)/2)
15 % V[T] = E[W]^2 + lambda*E[S^3]/(3*(1-rho)) + E[S^2] - E[S]^2
16 %
17 % with rho = lambda*E[S] and E[W] = lambda*E[S^2]/(2*(1-rho)), i.e. the
18 % Pollaczek-Khinchine mean waiting time. The third moment enters only the
19 % variance, so an exponential or phase-type branch needs no extra input
20 % beyond what the service distribution already reports (getMoments(3) on a
21 % Markovian law, or 3*ES*VS + ES^3 + skewness*VS^(3/2) in general).
22 %
23 % @par Syntax:
24 % @code
25 % [ET, VT] = fj_mg1_respt_moments(lambda, ES, ES2, ES3)
26 % @endcode
27 %
28 % @par Parameters:
29 % <table>
30 % <tr><th>Name<th>Description
31 % <tr><td>lambda<td>Arrival rate at the branch
32 % <tr><td>ES<td>First moment of the service time
33 % <tr><td>ES2<td>Second moment of the service time
34 % <tr><td>ES3<td>Third moment of the service time
35 % </table>
36 %
37 % @par Returns:
38 % <table>
39 % <tr><th>Name<th>Description
40 % <tr><td>ET<td>Mean response time
41 % <tr><td>VT<td>Variance of the response time
42 % </table>
43 %
44 % @par References:
45 % M. Nguyen, S. Alesawi, N. Li, H. Che, H. Jiang, "ForkTail: A Black-Box
46 % Fork-Join Tail Latency Prediction Model for User-Facing Datacenter
47 % Workloads", ACM HPDC 2018, Eqs. (10) and (11).
48%}
49function [ET, VT] = fj_mg1_respt_moments(lambda, ES, ES2, ES3)
50
51rho = lambda * ES;
52if rho >= 1
53 line_error(mfilename, 'The branch is unstable (rho = %g >= 1); the response time moments do not exist.', rho);
54end
55if ~isfinite(ES3)
56 line_error(mfilename, ['The service law has no finite third moment, so the ForkTail response ' ...
57 'time variance is undefined (a Pareto branch with shape <= 3, for instance). ' ...
58 'Use a service law with three finite moments.']);
59end
60scvS = (ES2 - ES^2) / ES^2;
61ET = ES * (1 + rho/(1-rho) * (1 + scvS)/2);
62EW = lambda * ES2 / (2*(1-rho));
63VT = EW^2 + lambda*ES3/(3*(1-rho)) + ES2 - ES^2;
64end