1%{ @file lsn_max_multiplicity.m
2 % @brief Computes
the maximum multiplicity of
nodes in a Layered Software Network
4 % @author LINE Development Team
8 % @brief Computes maximum multiplicity (concurrency level)
for LSN
nodes
11 % This function computes
the maximum multiplicity (throughput capacity)
for
12 % each node in a Layered Software Network (LSN). Uses Kahn
's algorithm for
13 % topological sorting to propagate constraints through the network.
17 % outflow = lsn_max_multiplicity(lsn)
22 % <tr><th>Name<th>Description
23 % <tr><td>lsn<td>Layered Software Network structure
28 % <tr><th>Name<th>Description
29 % <tr><td>outflow<td>Maximum multiplicity (throughput capacity) for each node
32function outflow = lsn_max_multiplicity(lsn)
39% Manual topological sort (Kahn's algorithm)
42% initially load ref task multiplicity
45 if type(i) == LayeredNetworkElement.TASK && isref(i)
47 % Also account
for entries with open arrivals
48 elseif type(i) == LayeredNetworkElement.ENTRY
49 if isfield(lsn,
'arrival') && ~isempty(lsn.arrival) && ...
50 iscell(lsn.arrival) && i <= length(lsn.arrival) && ...
51 ~isempty(lsn.arrival{i})
52 % Entry has open arrival - needs at least 1 thread of its parent task
63isfunction = zeros(n,1);
64if isfield(lsn,
'isfunction') && ~isempty(lsn.isfunction)
65 isfunction(1:length(lsn.isfunction)) = lsn.isfunction(:);
70 if isfunction(i) && inflow(i) > 0
71 % A function task's instances are provisioned by
the platform, not
72 % spawned by its callers, so caller concurrency does not bound them.
73 % Keeping
the declared multiplicity
is queueing-neutral when fewer
74 % jobs than instances circulate, but it
is required for
the classic
75 % think-time semantics:
the task think time overlaps across
the
76 % mult(i) instances and
is absorbed into each instance's idle period
77 % (against which
the delay-off timer races), whereas collapsing to
78 %
the caller bound would force every job to pay
the think time in
79 %
the request path and throttle
the entry.
82 outflow(i) = min(inflow(i), mult(i));
86 inflow(j) = inflow(j) + outflow(i);
90%inflow(type > LayeredNetworkElement.TASK )=0;
92 if type(i) == LayeredNetworkElement.TASK && mult(i)==Inf && ~isref(i)