1function prOt = overtake_prob(self, eidx)
2% OVERTAKE_PROB Compute overtaking probability
using transient Markov chain
4% PROT = OVERTAKE_PROB(SELF, EIDX) computes the probability that a
new
5% arrival to entry EIDX finds the server in phase-2 (post-reply processing).
7% This uses a 3-state Continuous Time Markov Chain (CTMC):
9% State 1: Server in phase-1 (caller
is blocked)
10% State 2: Server in phase-2 (caller has been released)
13% 0 -> 1: arrival (rate lambda)
14% 1 -> 2: phase-1 completion (rate mu1 = 1/S1)
15% 2 -> 0: phase-2 completion (rate mu2 = 1/S2)
17% By PASTA (Poisson Arrivals See Time Averages), the overtaking probability
18% equals the steady-state probability of being in phase-2.
20% For multi-server systems, an approximation
is used.
23% Franks, G. and Woodside, M.
"Effectiveness of early replies in
24% client-server systems", Performance Evaluation, 36(1):165-184, 1999.
27 e = eidx - lqn.eshift;
28 tidx = lqn.parent(eidx);
30 S1 = self.servt_ph1(eidx);
31 S2 = self.servt_ph2(eidx);
33 % Get throughput - use entry
if available, otherwise use task
34 if self.tput(eidx) > GlobalConstants.FineTol
35 lambda = self.tput(eidx);
36 elseif self.tput(tidx) > GlobalConstants.FineTol
37 lambda = self.tput(tidx);
42 c = lqn.mult(tidx); % number of servers
44 % Handle degenerate cases
45 if S2 < GlobalConstants.FineTol || lambda < GlobalConstants.FineTol || S1 < GlobalConstants.FineTol
54 % Single server: exact CTMC solution
55 % Generator matrix Q
for states {idle, phase-1, phase-2}
57 % Q = | -lambda lambda 0 |
61 % Steady-state: pi * Q = 0, sum(pi) = 1
63 % Solve
using the augmented system [Q
'; 1 1 1] * pi = [0; 0; 0; 1]
64 Q = [-lambda, lambda, 0;
71 % Use least squares
for numerical stability
74 % PASTA:
P(find in phase-2) = pi(3)
75 prOt = max(0, min(1, pi(3)));
77 % Multi-server approximation
78 % Based on utilization decomposition
79 rho = lambda * (S1 + S2) / c;
82 % Saturated system: probability proportional to phase-2 fraction
83 prOt = S2 / (S1 + S2);
85 % Probability a random server
is in phase-2
86 % Approximation: fraction of time in phase-2 weighted by utilization
87 prOt = (S2 / (S1 + S2)) * rho;
91 prOt = max(0, min(1, prOt));