@mark1russell7/capacity 0.0.0-bootstrap.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1107 -1
- package/build/index.d.ts +858 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +1713 -0
- package/build/index.js.map +1 -0
- package/build/instance-0n6WhJzF.d.ts +782 -0
- package/build/instance-0n6WhJzF.d.ts.map +1 -0
- package/build/instance-check-CAuD9L4Z.js +1711 -0
- package/build/instance-check-CAuD9L4Z.js.map +1 -0
- package/build/schema.d.ts +69 -0
- package/build/schema.d.ts.map +1 -0
- package/build/schema.js +315 -0
- package/build/schema.js.map +1 -0
- package/limits/alerts-routes.line.json +78 -0
- package/limits/alerts-scale.limits.json +10 -0
- package/limits/alerts-start-gate.limits.json +1149 -0
- package/limits/alerts-start-routes-limit-home.bracket.json +543 -0
- package/limits/alerts-start-routes-limit-mid.bracket.json +464 -0
- package/limits/alerts-start-routes-limit.bracket.json +579 -0
- package/limits/alerts-tail-gate.limits.json +610 -0
- package/package.json +79 -4
- package/src/app-check.ts +477 -0
- package/src/app-metrics.ts +105 -0
- package/src/app.ts +239 -0
- package/src/check.ts +228 -0
- package/src/composition.ts +680 -0
- package/src/demand.ts +312 -0
- package/src/fit.ts +153 -0
- package/src/forms.ts +358 -0
- package/src/gate.ts +237 -0
- package/src/index.ts +142 -0
- package/src/instance-check.ts +122 -0
- package/src/instance.ts +84 -0
- package/src/knee.ts +606 -0
- package/src/law.ts +215 -0
- package/src/limit.ts +112 -0
- package/src/names.ts +19 -0
- package/src/observe.ts +74 -0
- package/src/program.ts +74 -0
- package/src/scale.ts +617 -0
- package/src/schema.ts +260 -0
- package/src/value.ts +206 -0
- package/src/workload-check.ts +130 -0
- package/src/workload.ts +88 -0
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,858 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Performance and capacity models. A law gives one measure of a subject, for example the CPU time
|
|
3
|
+
* of one request, as a function of its load variables. A workload gives the load: the classes of
|
|
4
|
+
* requests with their rates. The package examines a law and a workload, and it gives the value of
|
|
5
|
+
* a law at a load point, with an interval. The catalog of forms gives the math of a law as data,
|
|
6
|
+
* with its slope and the start values of its fit. The knee of a law is the first load where its
|
|
7
|
+
* cost starts to grow fast. Its edge is the first load with no value. The gate of some laws tells if new
|
|
8
|
+
* measured values stay in the run ranges of their laws.
|
|
9
|
+
*
|
|
10
|
+
* The contract of an app gives its load variables, its classes of requests, its start with fakes of its
|
|
11
|
+
* outside services, and its live metrics. Each app gives the same contract.
|
|
12
|
+
*
|
|
13
|
+
* An instance type gives the resources of one copy of a service. A limit is a ceiling on one
|
|
14
|
+
* measure, with headroom. The package gives the share of each limit that a value takes.
|
|
15
|
+
*
|
|
16
|
+
* @packageDocumentation
|
|
17
|
+
*/
|
|
18
|
+
import { $ as AppProcess, $t as leastCount, A as compositionValue, At as lawValue, B as shareOf, Bt as LawProblem, C as LawPart, Ct as WorkloadSource, D as Over, Dt as LoadPoint, E as NestedTerm, Et as LevelOptions, F as ShareOptions, Ft as Fit, G as AppClass, Gt as Problem, H as APP_FILE, Ht as MAX_VARIABLES, I as instancePointOf, It as FitError, J as AppEntry, Jt as Run, K as AppCommand, Kt as ProblemCode, L as loadPointOf, Lt as Form, M as Load, Mt as Constant, N as PointLaw, Nt as DEFAULT_LEVEL, O as PartValue, Ot as Range, P as PointOptions, Pt as Evidence, Q as AppProblemCode, Qt as bootstrapDraws, R as mergeDemands, Rt as LAW_FORMAT, S as CompositionValue, St as WorkloadProblemCode, T as NestedPart, Tt as LawValue, U as APP_FORMAT, Ut as Measure, V as totalRate, Vt as Loser, W as APP_LINE_KINDS, Wt as Noise, X as AppLineKind, Xt as Scale, Y as AppLine, Yt as RunPoint, Z as AppProblem, Zt as Variable, _ as Composition, _t as RATE, a as InstanceProblem, at as AppStart, b as CompositionProblemCode, bt as WorkloadClass, c as LIMITS_FORMAT, ct as MetricsGap, d as LimitProblemCode, dt as VariableKind, en as leastGroups, et as AppRange, f as LimitSet, ft as Amounts, g as Catalog, gt as PlanSource, h as COMPOSITION_FORMAT, ht as NO_DEMAND, i as Instance, it as AppService, j as isLawTerm, jt as ConditionValue, k as checkComposition, kt as constantIntervals, l as Limit, lt as SeriesTarget, m as ResourceCeiling, mt as MetricsSource, n as Ceiling, nt as AppRun, o as InstanceProblemCode, ot as AppVariable, p as RESOURCE_UNITS, pt as Demand, q as AppContract, qt as ResidualKind, r as INSTANCE_FORMAT, rt as AppSeries, s as InstanceType, st as HttpEntry, t as AmountCeiling, tt as AppReady, u as LimitProblem, ut as ServiceEntry, v as CompositionOptions, vt as WORKLOAD_FORMAT, w as LawTerm, wt as ConstantInterval, x as CompositionTerm, xt as WorkloadProblem, y as CompositionProblem, yt as Workload, z as scaleDemand, zt as Law } from "./instance-0n6WhJzF.js";
|
|
19
|
+
import { Quantity } from "@mark1russell7/quantity";
|
|
20
|
+
import { Expr } from "@mark1russell7/vex";
|
|
21
|
+
import { Result } from "@mark1russell7/optional";
|
|
22
|
+
import { SeparableGroup, SeparableModel } from "@mark1russell7/rigor-statistics";
|
|
23
|
+
import { Gate, GateCaseOutcome, LimitOutcome } from "@mark1russell7/rigor-bench";
|
|
24
|
+
/** An id is lower-case words joined by `.`, `-` or `/`. A law, a subject, a measure, a form, a condition, a workload and a class each have an id. */
|
|
25
|
+
export declare const SLUG: RegExp;
|
|
26
|
+
/** A name that a program reads: a variable, a constant or a level. */
|
|
27
|
+
export declare const NAME: RegExp;
|
|
28
|
+
/**
|
|
29
|
+
* This function examines a law and gives each problem that it finds. A law with no problem gives
|
|
30
|
+
* an empty list.
|
|
31
|
+
*
|
|
32
|
+
* It examines the ids, the units and the ranges. It examines that the program reads each variable
|
|
33
|
+
* and each constant, and no other name. It examines that the law has a finite value at each corner
|
|
34
|
+
* and at the middle of its ranges. It examines that the replicates and the residuals can show an
|
|
35
|
+
* interval of the level 0.95, and that the evidence names its runs. It examines that the noise
|
|
36
|
+
* has a floor of 0 or more, a CPU model and its runs.
|
|
37
|
+
*
|
|
38
|
+
* A law with points must have one point for each residual. Each point must be in the ranges of the
|
|
39
|
+
* variables and name a run of the evidence.
|
|
40
|
+
*
|
|
41
|
+
* The interval of each constant must have a width above 0. A constant with the same value in each
|
|
42
|
+
* replicate is a bound of a search, not a measured value. For example, a shape at the edge of its
|
|
43
|
+
* search in each fit of the bootstrap gives this.
|
|
44
|
+
*/
|
|
45
|
+
export declare const checkLaw: (law: Law) => readonly LawProblem[];
|
|
46
|
+
/** This name is the name of the load variable in the programs of the catalog. A binding gives its id in a law. */
|
|
47
|
+
export declare const FORM_VARIABLE = "x";
|
|
48
|
+
/**
|
|
49
|
+
* A term is one part of a form: its constant times its basis. The basis and its slope read the
|
|
50
|
+
* variable and the shape constants of the form with `v(name)`. The slope is the change of the basis
|
|
51
|
+
* for each unit of the variable.
|
|
52
|
+
*/
|
|
53
|
+
interface Term {
|
|
54
|
+
readonly constant: string;
|
|
55
|
+
readonly basis: Expr;
|
|
56
|
+
readonly slope: Expr;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* A grid gives the start candidates of one shape constant from the points of a fit.
|
|
60
|
+
*
|
|
61
|
+
* - `inside` gives each distinct value of the variable inside its range, and each middle of two
|
|
62
|
+
* values that follow. A knee starts at these values.
|
|
63
|
+
* - `scaled` gives each factor times the largest size of the variable to the `power`. With the power
|
|
64
|
+
* 0, the candidates are the factors.
|
|
65
|
+
*/
|
|
66
|
+
type Grid = {
|
|
67
|
+
readonly kind: "inside";
|
|
68
|
+
} | {
|
|
69
|
+
readonly kind: "scaled";
|
|
70
|
+
readonly factors: readonly number[];
|
|
71
|
+
readonly power: number;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* The bounds tell where the refine of a fit can move a shape constant. They come from the points of the fit.
|
|
75
|
+
*
|
|
76
|
+
* - `range` is from the least value of the variable to its largest value. A knee is inside the range.
|
|
77
|
+
* - `size` is from the largest size of the variable up. The capacity of a queue is past each load.
|
|
78
|
+
* - `least` is from `value` up.
|
|
79
|
+
*/
|
|
80
|
+
type Bounds = {
|
|
81
|
+
readonly kind: "range";
|
|
82
|
+
} | {
|
|
83
|
+
readonly kind: "size";
|
|
84
|
+
} | {
|
|
85
|
+
readonly kind: "least";
|
|
86
|
+
readonly value: number;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* A shape constant changes the shape of a form, not its size. A fit starts it at each value of its grid. Then the fit
|
|
90
|
+
* refines it inside its bounds. A shape with no bounds has no limit.
|
|
91
|
+
*/
|
|
92
|
+
interface Shape {
|
|
93
|
+
readonly id: string;
|
|
94
|
+
readonly grid: Grid;
|
|
95
|
+
readonly bounds?: Bounds;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* A catalog form is the math of a law of one variable, as data. Its value is the sum of its terms.
|
|
99
|
+
* Thus, with fixed shape constants, a fit of a form is linear in the constants of its terms.
|
|
100
|
+
*/
|
|
101
|
+
interface CatalogForm {
|
|
102
|
+
readonly id: string;
|
|
103
|
+
readonly title: string;
|
|
104
|
+
readonly terms: readonly Term[];
|
|
105
|
+
readonly shapes: readonly Shape[];
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* A binding puts a catalog form into a law. It gives the id of the variable in the law, and the id
|
|
109
|
+
* in the law of each constant. A constant with no entry keeps its id from the catalog.
|
|
110
|
+
*/
|
|
111
|
+
interface Binding {
|
|
112
|
+
readonly variable: string;
|
|
113
|
+
readonly constants?: Readonly<Record<string, string>>;
|
|
114
|
+
}
|
|
115
|
+
/** The points of a fit: the value of the variable and the measured value of each point, in the same order. */
|
|
116
|
+
interface Points {
|
|
117
|
+
readonly x: readonly number[];
|
|
118
|
+
readonly y: readonly number[];
|
|
119
|
+
}
|
|
120
|
+
/** A start is the start values of the constants of a form, and the sum of the squared residuals at these values. */
|
|
121
|
+
interface Start {
|
|
122
|
+
readonly constants: readonly Constant[];
|
|
123
|
+
readonly rss: number;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* The catalog of the forms of a law, in the order of the roadmap. Each form is a sum of terms.
|
|
127
|
+
*
|
|
128
|
+
* - `constant`: `base`.
|
|
129
|
+
* - `linear`: `base + slope·x`.
|
|
130
|
+
* - `power`: `base + scale·x^exponent`.
|
|
131
|
+
* - `fall-power`: `base + excess / x + scale·x^exponent`. The term `excess / x` is a cost at a low load that falls as the load grows.
|
|
132
|
+
* - `logarithm`: `base + scale·ln(x)`.
|
|
133
|
+
* - `hinge`: `base + slope·x + bend·max(0, x − knee)`. After the knee the slope is `slope + bend`.
|
|
134
|
+
* - `queue`: `base + scale·capacity / (capacity − x)`. This is the delay of a queue. The form has no
|
|
135
|
+
* finite value at the capacity.
|
|
136
|
+
* - `scalability`: `unit·x / (1 + contention·(x − 1) + coherency·x·(x − 1))`. This is the
|
|
137
|
+
* universal scalability law of the throughput at a concurrency `x`.
|
|
138
|
+
* - `drift`: `base + drift·x + warm·(1 − e^(−x / settle))`. This is a measure over the age of a
|
|
139
|
+
* process: a warm-up that settles, and a steady drift.
|
|
140
|
+
*/
|
|
141
|
+
export declare const FORMS: readonly CatalogForm[];
|
|
142
|
+
/** This function gives the form of the catalog with the id, or undefined. */
|
|
143
|
+
export declare const catalogForm: (id: string) => CatalogForm | undefined;
|
|
144
|
+
/** This function gives the ids of the constants of a form: the constant of each term, then each shape constant. */
|
|
145
|
+
export declare const constantIdsOf: (form: CatalogForm) => readonly string[];
|
|
146
|
+
/** This function gives the program of the value of a form in a law. It reads the variable and each constant of the binding. */
|
|
147
|
+
export declare const programOf: (form: CatalogForm, binding: Binding) => Expr;
|
|
148
|
+
/** This function gives the program of the slope of a form in a law: the change of its value for each unit of the variable. */
|
|
149
|
+
export declare const slopeOf: (form: CatalogForm, binding: Binding) => Expr;
|
|
150
|
+
/** This function gives the form of a law from a form of the catalog. */
|
|
151
|
+
export declare const formOf: (form: CatalogForm, binding: Binding) => Form;
|
|
152
|
+
/** This function gives the value of a form at each value of its variable, or the text of the first error. */
|
|
153
|
+
export declare const formValues: (form: CatalogForm, xs: readonly number[], constants: Readonly<Record<string, number>>) => Result<readonly number[], string>;
|
|
154
|
+
/** This function gives the slope of a form at each value of its variable, or the text of the first error. */
|
|
155
|
+
export declare const formSlopes: (form: CatalogForm, xs: readonly number[], constants: Readonly<Record<string, number>>) => Result<readonly number[], string>;
|
|
156
|
+
/** This function gives the candidates of a grid for the values of a variable. */
|
|
157
|
+
export declare const gridOf: (grid: Grid, xs: readonly number[]) => readonly number[];
|
|
158
|
+
/**
|
|
159
|
+
* This function gives a form of the catalog as a separable model of `@mark1russell7/rigor-statistics`. Each term is
|
|
160
|
+
* one column of the design: the basis of the term at each point. The candidates and the bounds of each shape constant
|
|
161
|
+
* come from the values `xs` of the variable. The design is null when a basis has no finite value at a point.
|
|
162
|
+
*/
|
|
163
|
+
export declare const separableOf: (form: CatalogForm, xs: readonly number[]) => SeparableModel<number>;
|
|
164
|
+
/**
|
|
165
|
+
* This function gives the least-squares fit of a form to some points, as the start values of its constants.
|
|
166
|
+
*
|
|
167
|
+
* The fit is `fitSeparable` of `@mark1russell7/rigor-statistics`. For each combination of the grids of the shape
|
|
168
|
+
* constants, the least-squares fit gives the constants of the terms. Then a golden-section search refines each shape
|
|
169
|
+
* constant inside its bounds. A form with no shape constant has one combination, thus its start is its least-squares fit.
|
|
170
|
+
*
|
|
171
|
+
* The function gives an error when no combination has a fit, for example with fewer points than terms.
|
|
172
|
+
*/
|
|
173
|
+
export declare const startOf: (form: CatalogForm, points: Points) => Result<Start, string>;
|
|
174
|
+
/** The options of `fitLaw`. */
|
|
175
|
+
interface LawFitOptions {
|
|
176
|
+
/** These forms compete for the law. The default is each form of the catalog. */
|
|
177
|
+
readonly forms?: readonly CatalogForm[];
|
|
178
|
+
/** This binding puts the form that wins into the law. The default is the variable `x` and the ids of the catalog. */
|
|
179
|
+
readonly binding?: Binding;
|
|
180
|
+
/**
|
|
181
|
+
* This kind tells how the fit compares a value with a form. The default is `"absolute"`. A `"relative"` fit uses the
|
|
182
|
+
* weights `1 / y^2`. Thus each value of a relative fit is not 0.
|
|
183
|
+
*/
|
|
184
|
+
readonly residual?: ResidualKind;
|
|
185
|
+
/**
|
|
186
|
+
* This list gives the group of each point. The points of one group are replicates of one load. The held-out fit holds
|
|
187
|
+
* out each group. The default group of a point is its value of the variable.
|
|
188
|
+
*/
|
|
189
|
+
readonly groups?: readonly SeparableGroup[];
|
|
190
|
+
/**
|
|
191
|
+
* This list gives the group of each point for the bootstrap. Each run of the bootstrap draws whole groups of this
|
|
192
|
+
* list. The default is the list `groups`. A group of the bootstrap is an independent unit of the data, for example
|
|
193
|
+
* the job that measured its points. A plan that fixes its loads has no random load, thus a draw of whole loads is
|
|
194
|
+
* the wrong model for it.
|
|
195
|
+
*/
|
|
196
|
+
readonly bootstrapGroups?: readonly SeparableGroup[];
|
|
197
|
+
/** This number is the number of runs of the bootstrap. The default is `SEPARABLE_BOOTSTRAP_RUNS` of rigor-statistics. */
|
|
198
|
+
readonly runs?: number;
|
|
199
|
+
/** This seed starts the draws of the bootstrap. The default is 1. */
|
|
200
|
+
readonly seed?: number;
|
|
201
|
+
}
|
|
202
|
+
/** A form rank is one form that competed in a law fit, with the error of its held-out residuals. */
|
|
203
|
+
interface FormRank {
|
|
204
|
+
readonly form: string;
|
|
205
|
+
/** This error comes from the held-out residuals that have a value. With no such residual, each error is NaN. */
|
|
206
|
+
readonly error: FitError;
|
|
207
|
+
/** This number is the number of points with no held-out prediction. */
|
|
208
|
+
readonly missing: number;
|
|
209
|
+
/** This text tells why the form has no fit. A form with a fit has no reason. */
|
|
210
|
+
readonly reason?: string;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* A law fit is the part of a law that comes from a fit of its points. It has the form, the constants, the replicates and
|
|
214
|
+
* the record of the fit. The list `ranks` keeps each form that competed, best first.
|
|
215
|
+
*/
|
|
216
|
+
interface LawFit extends Pick<Law, "form" | "constants" | "replicates" | "fit"> {
|
|
217
|
+
readonly ranks: readonly FormRank[];
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* This function fits a law of one variable to its points. Each form competes, and the form with the smallest root mean
|
|
221
|
+
* square of its held-out residuals wins. A form with a point that has no held-out prediction ranks after each form with
|
|
222
|
+
* a prediction at each point.
|
|
223
|
+
*
|
|
224
|
+
* The fit of each form is `fitSeparable` of `@mark1russell7/rigor-statistics`. Each held-out residual comes from a fit of
|
|
225
|
+
* the other groups. The replicates of the winner come from a bootstrap of the whole groups of `bootstrapGroups`. The losers of the record are
|
|
226
|
+
* the other forms with a held-out prediction at each point.
|
|
227
|
+
*
|
|
228
|
+
* The function gives an error for points that a fit cannot use, and when no form has a held-out prediction at each point.
|
|
229
|
+
* It gives an error for fewer groups of the bootstrap than `leastGroups` of the level 0.95, because their draws are too few for an interval.
|
|
230
|
+
*/
|
|
231
|
+
export declare const fitLaw: (points: Points, options?: LawFitOptions) => Result<LawFit, string>;
|
|
232
|
+
/** This number is the count of steps of the grid of a knee search when the options give none. */
|
|
233
|
+
export declare const KNEE_STEPS = 64;
|
|
234
|
+
/**
|
|
235
|
+
* A knee rule tells where a law leaves its cheap region.
|
|
236
|
+
*
|
|
237
|
+
* - `rise`: the value is more than `1 + share` times the value at the start of the search.
|
|
238
|
+
* - `slope`: the slope is more than `factor` times the slope at the start of the search.
|
|
239
|
+
* - `floor`: the value is more than `1 + share` times the floor of the row. The floor of a row is its
|
|
240
|
+
* least value on the grid of the search, before its edge. The search of a row starts at its floor.
|
|
241
|
+
*/
|
|
242
|
+
type KneeRule = {
|
|
243
|
+
readonly kind: "rise";
|
|
244
|
+
readonly share: number;
|
|
245
|
+
} | {
|
|
246
|
+
readonly kind: "slope";
|
|
247
|
+
readonly factor: number;
|
|
248
|
+
} | {
|
|
249
|
+
readonly kind: "floor";
|
|
250
|
+
readonly share: number;
|
|
251
|
+
};
|
|
252
|
+
/** The floor of a law is its least value with its constants on the grid of a search, and the load of that value. */
|
|
253
|
+
interface Floor {
|
|
254
|
+
readonly load: number;
|
|
255
|
+
readonly value: number;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* These options set a knee search. The search goes along one variable, from `from` to `to`, on a
|
|
259
|
+
* grid of `steps` steps. The point `at` gives the value of each other variable of the law.
|
|
260
|
+
*
|
|
261
|
+
* The search goes from the minimum to the maximum of the variable, on 64 steps, when the options
|
|
262
|
+
* give no value. The level of the intervals is 0.95 when the options give none.
|
|
263
|
+
*/
|
|
264
|
+
interface KneeOptions extends LevelOptions {
|
|
265
|
+
readonly at?: LoadPoint;
|
|
266
|
+
readonly from?: number;
|
|
267
|
+
readonly to?: number;
|
|
268
|
+
readonly steps?: number;
|
|
269
|
+
}
|
|
270
|
+
/** An open range goes from `low` to `high`. A null end is past the end of the search. */
|
|
271
|
+
interface OpenRange {
|
|
272
|
+
readonly low: number | null;
|
|
273
|
+
readonly high: number | null;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* A crossing is a load on the variable of a search, with the interval of its replicates. A null
|
|
277
|
+
* value tells that the crossing is not in the search. The flag `outside` tells that the value is
|
|
278
|
+
* outside the range of the variable. Then the value is an extrapolation.
|
|
279
|
+
*/
|
|
280
|
+
interface Crossing {
|
|
281
|
+
readonly value: number | null;
|
|
282
|
+
readonly interval: OpenRange;
|
|
283
|
+
readonly outside: boolean;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* A knee is the result of a knee search along one variable of a law, in the unit of the variable.
|
|
287
|
+
*
|
|
288
|
+
* The `knee` is the first load where the law obeys the rule: there the law leaves its cheap region.
|
|
289
|
+
* The `edge` is the first load where the law has no finite value. This is a pole, where the value
|
|
290
|
+
* grows with no limit, or the start of a region with no value. The knee is always before the edge.
|
|
291
|
+
* The list `outside` names each other variable whose value is outside its range. Only a knee of the
|
|
292
|
+
* rule `floor` has the fields `floor` and `noFloor`.
|
|
293
|
+
*/
|
|
294
|
+
interface Knee {
|
|
295
|
+
readonly variable: string;
|
|
296
|
+
readonly unit: string;
|
|
297
|
+
readonly rule: KneeRule;
|
|
298
|
+
readonly level: number;
|
|
299
|
+
readonly search: Range;
|
|
300
|
+
readonly knee: Crossing;
|
|
301
|
+
readonly edge: Crossing;
|
|
302
|
+
readonly outside: readonly string[];
|
|
303
|
+
/** This floor is the floor of the law with its constants. */
|
|
304
|
+
readonly floor?: Floor;
|
|
305
|
+
/** This number is the count of replicates with no floor above 0. The rule cannot apply to them, thus the interval of the knee leaves them out. */
|
|
306
|
+
readonly noFloor?: number;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* This function gives the problem of a knee rule, or undefined for a correct rule. The rule can come
|
|
310
|
+
* from data, thus the function also examines its shape. The path of a problem starts with `path`.
|
|
311
|
+
*/
|
|
312
|
+
export declare const kneeRuleProblem: (rule: unknown, path?: string) => LawProblem | undefined;
|
|
313
|
+
/** An open value is a value of a search with the interval of its replicates. A null value or end is past the end of the search. */
|
|
314
|
+
interface OpenValue {
|
|
315
|
+
readonly value: number | null;
|
|
316
|
+
readonly interval: OpenRange;
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* This function gives the knee of a law along one variable, with an interval. It also gives the
|
|
320
|
+
* edge: the first load where the law has no finite value.
|
|
321
|
+
*
|
|
322
|
+
* The point `at` of the options gives each other variable of the law. The function evaluates the
|
|
323
|
+
* law with its constants, then with each replicate. The interval of the knee and of the edge is the
|
|
324
|
+
* share `level` of the values of the replicates, made wider to hold the value.
|
|
325
|
+
*
|
|
326
|
+
* The search tests a grid of loads, then a bisection finds each crossing. A crossing between two
|
|
327
|
+
* loads of the grid is found. Two edges in one step of the grid can hide the first edge.
|
|
328
|
+
*
|
|
329
|
+
* The rule `floor` gives each row its own floor. Thus the knee of a row is always after its floor,
|
|
330
|
+
* and the uncertainty of the floor is in the interval. A replicate with no floor above 0 has no knee:
|
|
331
|
+
* the field `noFloor` counts these replicates, and the interval leaves them out. When they are more
|
|
332
|
+
* than one tail of the level, the function gives a problem.
|
|
333
|
+
*
|
|
334
|
+
* The function gives a problem for a variable or a point that the law cannot read. A bad search
|
|
335
|
+
* range, rule or count of steps, and a level that the law cannot show, also give a problem. The last
|
|
336
|
+
* problems are a law with no value at the start of the search, and a rule that cannot apply there.
|
|
337
|
+
*/
|
|
338
|
+
export declare const lawKnee: (law: Law, variable: string, rule: KneeRule, options?: KneeOptions) => Result<Knee, LawProblem>;
|
|
339
|
+
/**
|
|
340
|
+
* A reach is the result of a search along one variable for the first load where a law is above an
|
|
341
|
+
* amount. The loads are in the unit of the variable. Before the `crossing`, the law holds the amount.
|
|
342
|
+
*
|
|
343
|
+
* Thus for a law that grows along the variable, the crossing is the largest load that holds the
|
|
344
|
+
* amount. The `edge` and the list `outside` are as in a knee.
|
|
345
|
+
*/
|
|
346
|
+
interface Reach {
|
|
347
|
+
readonly variable: string;
|
|
348
|
+
readonly unit: string;
|
|
349
|
+
/** This amount is the amount of the search, in the unit of the measure of the law. */
|
|
350
|
+
readonly amount: number;
|
|
351
|
+
readonly level: number;
|
|
352
|
+
readonly search: Range;
|
|
353
|
+
readonly crossing: Crossing;
|
|
354
|
+
readonly edge: Crossing;
|
|
355
|
+
readonly outside: readonly string[];
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* This function gives the first load along one variable where a law is above an amount, with an
|
|
359
|
+
* interval. This is the inverse query of one law: the largest load that one limit holds.
|
|
360
|
+
*
|
|
361
|
+
* The options are the options of `lawKnee`. When the law is above the amount at the start of the
|
|
362
|
+
* search, the crossing is the start. When the law holds the amount on all of the search, the
|
|
363
|
+
* crossing is null. A pole is above each amount, so the crossing is before the pole.
|
|
364
|
+
*
|
|
365
|
+
* The function gives each problem of `lawKnee` that is not about a rule. An amount that is not finite
|
|
366
|
+
* gives a problem. An amount that does not convert to the unit of the measure also gives a problem.
|
|
367
|
+
*/
|
|
368
|
+
export declare const lawReach: (law: Law, variable: string, amount: Quantity, options?: KneeOptions) => Result<Reach, LawProblem>;
|
|
369
|
+
/** This level is the level of the family of tests of a gate. It is the chance of one false block or more in one run of the gate. */
|
|
370
|
+
export declare const GATE_ALPHA = .01;
|
|
371
|
+
/**
|
|
372
|
+
* This count is the jobs that each must show the same side before the gate blocks. One job on a slow runner
|
|
373
|
+
* cannot block alone. It is the default of `jobs` of `notSlowerVerdict` of `@mark1russell7/rigor-bench`.
|
|
374
|
+
*/
|
|
375
|
+
export declare const GATE_JOBS = 2;
|
|
376
|
+
/** The side of a measured value against the run range of its law. */
|
|
377
|
+
type ReadSide = "within" | "high" | "low";
|
|
378
|
+
/** A law read tells where one measured value falls against the run range of its law at one load point. */
|
|
379
|
+
interface LawRead {
|
|
380
|
+
readonly value: number;
|
|
381
|
+
/** This range is the range `run` of `lawValue`: where one measured run falls. */
|
|
382
|
+
readonly run: Range;
|
|
383
|
+
readonly side: ReadSide;
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* This function tells where one measured value falls against the run range of a law at a load point. The range is
|
|
387
|
+
* the range `run` of `lawValue`. A value above the range is `high`, and a value below it is `low`.
|
|
388
|
+
*
|
|
389
|
+
* The function gives a problem for a point outside the range of a variable, because there the law has no value to
|
|
390
|
+
* compare. It also gives each problem of `lawValue`, and a problem for a value that is not finite.
|
|
391
|
+
*/
|
|
392
|
+
export declare const lawRead: (law: Law, point: LoadPoint, value: number, options?: LevelOptions) => Result<LawRead, LawProblem>;
|
|
393
|
+
/** A gate read is one measured value of one job at one load point. */
|
|
394
|
+
interface GateRead {
|
|
395
|
+
readonly point: LoadPoint;
|
|
396
|
+
readonly value: number;
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* A gate job is the reads of one job for one law. A job with a reason in `noRead` gives no read, for example a job with a
|
|
400
|
+
* noise floor over its limit. The caller gives only the reads in the conditions of the law.
|
|
401
|
+
*/
|
|
402
|
+
interface GateJob {
|
|
403
|
+
/** This name is the name of the job, for example the address of its CI run and its start. */
|
|
404
|
+
readonly job: string;
|
|
405
|
+
readonly reads: readonly GateRead[];
|
|
406
|
+
readonly noRead?: string;
|
|
407
|
+
/** These texts tell each read that the caller left out, for example a point that the law leaves out. The counts do not use them. */
|
|
408
|
+
readonly unread?: readonly string[];
|
|
409
|
+
}
|
|
410
|
+
/** A gate case is one law and the jobs that measured its subject in its conditions. */
|
|
411
|
+
interface GateCase {
|
|
412
|
+
readonly law: Law;
|
|
413
|
+
readonly jobs: readonly GateJob[];
|
|
414
|
+
}
|
|
415
|
+
/** These options set the level of the run range, the level of the family of tests and the count of jobs of a side. */
|
|
416
|
+
interface LawGateOptions extends LevelOptions {
|
|
417
|
+
/** This level is the level of the family of tests. The default is `GATE_ALPHA`. */
|
|
418
|
+
readonly alpha?: number;
|
|
419
|
+
/** This count is the jobs that each must show a side. The default is `GATE_JOBS`. */
|
|
420
|
+
readonly jobs?: number;
|
|
421
|
+
}
|
|
422
|
+
/** A job count tells the reads of one job for one law, and the p of the count of each side. */
|
|
423
|
+
interface JobCount {
|
|
424
|
+
readonly job: string;
|
|
425
|
+
/** This count is the reads in the range of the law. */
|
|
426
|
+
readonly reads: number;
|
|
427
|
+
readonly high: number;
|
|
428
|
+
readonly low: number;
|
|
429
|
+
/** This p is the p of the binomial test of the count `high`, with the chance of one side under the claim. */
|
|
430
|
+
readonly pHigh: number;
|
|
431
|
+
readonly pLow: number;
|
|
432
|
+
/** These texts tell each read that the caller left out (`GateJob.unread`), and each read that the law cannot compare. */
|
|
433
|
+
readonly unread: readonly string[];
|
|
434
|
+
}
|
|
435
|
+
/** A side test is the test of one side of one law over the jobs, after the Holm correction of the family. */
|
|
436
|
+
interface SideTest {
|
|
437
|
+
readonly side: "high" | "low";
|
|
438
|
+
/** This p is the p of the claim "`jobs` jobs or more show this side" (`partialConjunction`). */
|
|
439
|
+
readonly p: number;
|
|
440
|
+
/** This p is the p after the Holm correction of the family. */
|
|
441
|
+
readonly adjusted: number;
|
|
442
|
+
readonly reject: boolean;
|
|
443
|
+
}
|
|
444
|
+
/** A job with no read tells the job and the reason. */
|
|
445
|
+
interface NoReadJob {
|
|
446
|
+
readonly job: string;
|
|
447
|
+
readonly reason: string;
|
|
448
|
+
}
|
|
449
|
+
/** A law gate case is the outcome of one law, with the counts of each job and the test of each side. */
|
|
450
|
+
interface LawGateCase extends GateCaseOutcome {
|
|
451
|
+
/** This name is the id of the law. */
|
|
452
|
+
readonly case: string;
|
|
453
|
+
readonly outcome: LimitOutcome;
|
|
454
|
+
/** This text tells the reason of the outcome, in one sentence. */
|
|
455
|
+
readonly reason: string;
|
|
456
|
+
readonly jobs: readonly JobCount[];
|
|
457
|
+
readonly noRead: readonly NoReadJob[];
|
|
458
|
+
/** These tests are the two sides, or an empty list for a case with too few jobs. */
|
|
459
|
+
readonly sides: readonly SideTest[];
|
|
460
|
+
}
|
|
461
|
+
/** A law gate is the gate of `@mark1russell7/rigor-bench` over the laws, with the facts that it uses. */
|
|
462
|
+
interface LawGate extends Gate {
|
|
463
|
+
readonly level: number;
|
|
464
|
+
readonly alpha: number;
|
|
465
|
+
/** This count is the jobs that each must show a side. */
|
|
466
|
+
readonly need: number;
|
|
467
|
+
/** This chance is the chance of one side for one read of a job that agrees with its law: `(1 - level) / 2`. */
|
|
468
|
+
readonly share: number;
|
|
469
|
+
readonly cases: readonly LawGateCase[];
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* This function gives the gate of some laws. For each law, it tells if the measured values of the jobs stay in the run
|
|
473
|
+
* range of the law. It is the rule of a gate of the laws of a subject, for example on a pull request.
|
|
474
|
+
*
|
|
475
|
+
* - **A read:** each value of a job falls `within`, `high` or `low` against the run range of its law (`lawRead`).
|
|
476
|
+
* A read of a job that agrees with its law falls on one side with a chance of `share`, `(1 - level) / 2`, or less.
|
|
477
|
+
* - **A job:** for each side, the binomial test of the count of reads on that side gives the p of the job.
|
|
478
|
+
* A job with `noRead`, or with no read in the range of the law, gives no read.
|
|
479
|
+
* - **A side:** `partialConjunction` joins the p of the jobs for the claim "`jobs` jobs or more show this side". Thus one
|
|
480
|
+
* job on an odd runner cannot block alone. The claim has no condition on how the reads of one job depend on each other.
|
|
481
|
+
* - **The family:** `holm` corrects the tests of the two sides of each law at the level `alpha`. A rejected side makes the
|
|
482
|
+
* case `beyond`. A low side is a block too: the law is no longer the law of the subject, and a new fit must replace it.
|
|
483
|
+
* - **No read:** a case with fewer than `jobs` jobs that read is `cannot decide`. So is a case whose reads are too few to
|
|
484
|
+
* reject a side, also with each read on that side. The gate of `@mark1russell7/rigor-bench` (`gateOf`) joins the cases.
|
|
485
|
+
* A gate with no case, or with a case that cannot decide and no block, is "no read". It does not pass.
|
|
486
|
+
*
|
|
487
|
+
* The function throws a `RangeError` for a level, an alpha or a count of jobs that is not valid.
|
|
488
|
+
*/
|
|
489
|
+
export declare const lawGate: (cases: readonly GateCase[], options?: LawGateOptions) => LawGate;
|
|
490
|
+
/**
|
|
491
|
+
* This function examines a demand and gives each problem that it finds. A demand with no problem
|
|
492
|
+
* gives an empty list.
|
|
493
|
+
*
|
|
494
|
+
* It examines the id, the class of the app and the rate of each class. It examines the name and the amount of
|
|
495
|
+
* each variable and each level. It examines that a variable has one kind of unit in each class, and that no name is
|
|
496
|
+
* a level and a variable.
|
|
497
|
+
*/
|
|
498
|
+
export declare const demandProblems: (demand: Demand) => readonly WorkloadProblem[];
|
|
499
|
+
/**
|
|
500
|
+
* This function examines a workload and gives each problem that it finds. A workload with no
|
|
501
|
+
* problem gives an empty list.
|
|
502
|
+
*
|
|
503
|
+
* It examines the format, the id and the title. It examines the demand with `demandProblems`. It
|
|
504
|
+
* examines that a plan has a note. It examines that the window of a metrics source goes from a UTC
|
|
505
|
+
* time to a later UTC time.
|
|
506
|
+
*/
|
|
507
|
+
export declare const checkWorkload: (workload: Workload) => readonly WorkloadProblem[];
|
|
508
|
+
/** This function tells if a text is an HTTPS URL. The package uses no global of a browser or of Node.js. */
|
|
509
|
+
export declare const isHttps: (text: string) => boolean;
|
|
510
|
+
/** This function gives the names of the placeholders in a text, in their order. */
|
|
511
|
+
export declare const placeholdersOf: (text: string) => readonly string[];
|
|
512
|
+
/**
|
|
513
|
+
* This function puts the value of each placeholder into a text. It gives undefined when the text holds a
|
|
514
|
+
* placeholder that `values` does not give.
|
|
515
|
+
*/
|
|
516
|
+
export declare const fillPlaceholders: (text: string, values: Readonly<Record<string, string>>) => string | undefined;
|
|
517
|
+
/**
|
|
518
|
+
* This function gives the path of a request of a class of HTTP at some amounts. Each amount is a number in
|
|
519
|
+
* the unit of its variable. It gives undefined when `values` does not give each variable of the path.
|
|
520
|
+
*/
|
|
521
|
+
export declare const requestPath: (entry: HttpEntry, values: Readonly<Record<string, number>>) => string | undefined;
|
|
522
|
+
/**
|
|
523
|
+
* This function examines the contract of an app and gives each problem that it finds. A contract with no
|
|
524
|
+
* problem gives an empty list.
|
|
525
|
+
*
|
|
526
|
+
* It examines the format, the id, the title and the repository. It examines each variable, each class and
|
|
527
|
+
* its entry, each command and its placeholders, each outside service and each series of the live metrics.
|
|
528
|
+
*/
|
|
529
|
+
export declare const checkApp: (app: AppContract) => readonly AppProblem[];
|
|
530
|
+
/**
|
|
531
|
+
* This function gives each part of the demand of an app that its live metrics cannot give. A contract whose
|
|
532
|
+
* metrics give its whole demand gives an empty list. The live check of a law reads a demand with no gap.
|
|
533
|
+
*/
|
|
534
|
+
export declare const metricsGaps: (app: AppContract) => readonly MetricsGap[];
|
|
535
|
+
/**
|
|
536
|
+
* This function examines a workload against the contract of its app, and gives each problem that it finds.
|
|
537
|
+
* The workload is a workload that `checkWorkload` accepts.
|
|
538
|
+
*
|
|
539
|
+
* Each class of the workload is a class of the app: the class that its field `of` names, or else its id. Its
|
|
540
|
+
* rate and each variable of its request are in the range of the app, and it gives each request variable of
|
|
541
|
+
* its class. Each level of the workload is a level variable of the app, in its range. A class or a level that
|
|
542
|
+
* the workload does not give is 0.
|
|
543
|
+
*/
|
|
544
|
+
export declare const appWorkloadProblems: (app: AppContract, workload: Workload) => readonly AppProblem[];
|
|
545
|
+
/**
|
|
546
|
+
* An observed class is the count of the requests of one class in a window of the live metrics, for
|
|
547
|
+
* example `{ value: 1200, unit: "{request}" }`. Its `request` gives each variable of one request.
|
|
548
|
+
*/
|
|
549
|
+
interface ObservedClass {
|
|
550
|
+
readonly id: string;
|
|
551
|
+
readonly count: Quantity;
|
|
552
|
+
readonly request: Amounts;
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* An observation is the live metrics of an app in one window, from `from` to `to`. Its `origin`
|
|
556
|
+
* names the place of the metrics. Each level is the level in the window.
|
|
557
|
+
*/
|
|
558
|
+
interface Observation {
|
|
559
|
+
readonly origin: string;
|
|
560
|
+
readonly from: string;
|
|
561
|
+
readonly to: string;
|
|
562
|
+
readonly classes: readonly ObservedClass[];
|
|
563
|
+
readonly levels: Amounts;
|
|
564
|
+
}
|
|
565
|
+
/** A workload name is the id and the title of a workload. */
|
|
566
|
+
interface WorkloadName {
|
|
567
|
+
readonly id: string;
|
|
568
|
+
readonly title: string;
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* This function gives the workload of an observation. The rate of a class is its count, divided by
|
|
572
|
+
* the seconds of the window. Thus the rate is the mean rate of the window. For the load at a peak,
|
|
573
|
+
* give the window of the peak.
|
|
574
|
+
*
|
|
575
|
+
* It gives each problem of an observation that is not correct, and each problem of the workload.
|
|
576
|
+
*/
|
|
577
|
+
export declare const observedWorkload: (observation: Observation, name: WorkloadName) => Result<Workload, readonly WorkloadProblem[]>;
|
|
578
|
+
/** A reading is one value of one series of an app at one time. `series` is the id of the series, and `at` is a UTC time. */
|
|
579
|
+
interface SeriesReading {
|
|
580
|
+
readonly series: string;
|
|
581
|
+
readonly at: string;
|
|
582
|
+
readonly value: number;
|
|
583
|
+
}
|
|
584
|
+
/** A window of the live metrics goes from `from` to `to`, two UTC times. Its `origin` names the place of the metrics. */
|
|
585
|
+
interface MetricsWindow {
|
|
586
|
+
readonly origin: string;
|
|
587
|
+
readonly from: string;
|
|
588
|
+
readonly to: string;
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* This function gives the increase of a counter from its values in the order of their times. A value below
|
|
592
|
+
* the value before it is a new start of the process. The counter starts again at 0, thus the increase adds
|
|
593
|
+
* the whole value.
|
|
594
|
+
*/
|
|
595
|
+
export declare const counterIncrease: (values: readonly number[]) => number;
|
|
596
|
+
/**
|
|
597
|
+
* This function gives the observation of an app in a window. The observation has the count of the requests of
|
|
598
|
+
* each class, the mean of each request variable and each level. It reads only the readings in the window.
|
|
599
|
+
*
|
|
600
|
+
* - The count of a class is the increase of its counter. A class with no request in the window is not in the observation.
|
|
601
|
+
* - The mean of a request variable is the increase of the counter of its total, over the count of its class.
|
|
602
|
+
* - A level is the mean of the readings of its gauge, with the same weight for each reading. Item CAP-63 adds a weight for the time of each reading.
|
|
603
|
+
*
|
|
604
|
+
* It gives a problem for each gap of the metrics of the app (`metricsGaps`). It also gives a problem for a
|
|
605
|
+
* counter with fewer than 2 readings, and for a gauge with no reading. `observedWorkload` gives the workload
|
|
606
|
+
* of the observation.
|
|
607
|
+
*/
|
|
608
|
+
export declare const observationOf: (app: AppContract, window: MetricsWindow, readings: readonly SeriesReading[]) => Result<Observation, readonly AppProblem[]>;
|
|
609
|
+
/**
|
|
610
|
+
* This function examines the resources of an instance and gives each problem that it finds. An
|
|
611
|
+
* instance with no problem gives an empty list.
|
|
612
|
+
*
|
|
613
|
+
* It examines that the instance has a resource. It examines the name and the amount of each
|
|
614
|
+
* resource. It examines the unit of each resource of `RESOURCE_UNITS`.
|
|
615
|
+
*/
|
|
616
|
+
export declare const instanceProblems: (instance: Instance) => readonly InstanceProblem[];
|
|
617
|
+
/**
|
|
618
|
+
* This function examines an instance type and gives each problem that it finds. An instance type
|
|
619
|
+
* with no problem gives an empty list.
|
|
620
|
+
*
|
|
621
|
+
* It examines the format, the id and the title. It examines the resources with `instanceProblems`.
|
|
622
|
+
*/
|
|
623
|
+
export declare const checkInstance: (type: InstanceType) => readonly InstanceProblem[];
|
|
624
|
+
/**
|
|
625
|
+
* This function examines one limit and gives each problem that it finds. The text `path` is the
|
|
626
|
+
* path of the limit, and it goes before the path of each problem.
|
|
627
|
+
*/
|
|
628
|
+
export declare const limitProblems: (limit: Limit, path?: string) => readonly LimitProblem[];
|
|
629
|
+
/**
|
|
630
|
+
* This function examines a limit set and gives each problem that it finds. A limit set with no
|
|
631
|
+
* problem gives an empty list.
|
|
632
|
+
*
|
|
633
|
+
* It examines the format, the id and the title. It examines each limit with `limitProblems`. It
|
|
634
|
+
* examines that two limits do not have one id.
|
|
635
|
+
*/
|
|
636
|
+
export declare const checkLimits: (set: LimitSet) => readonly LimitProblem[];
|
|
637
|
+
/**
|
|
638
|
+
* A limit use tells how much of a limit one value of its measure takes. The `amount` is the amount
|
|
639
|
+
* of the limit: its ceiling, less its headroom. The `use` is the value, divided by that amount.
|
|
640
|
+
* The limit holds when the `use` is 1 or less.
|
|
641
|
+
*/
|
|
642
|
+
interface LimitUse {
|
|
643
|
+
/** This id is the id of the limit. */
|
|
644
|
+
readonly limit: string;
|
|
645
|
+
readonly measure: string;
|
|
646
|
+
readonly value: Quantity;
|
|
647
|
+
readonly amount: Quantity;
|
|
648
|
+
readonly use: number;
|
|
649
|
+
readonly holds: boolean;
|
|
650
|
+
}
|
|
651
|
+
/**
|
|
652
|
+
* This function gives the amount of a limit on an instance: the ceiling, less the headroom. It is
|
|
653
|
+
* the largest value of the measure that holds the limit, in the unit of the ceiling.
|
|
654
|
+
*
|
|
655
|
+
* It gives a problem for a limit that is not correct. It gives a problem for a ceiling that names
|
|
656
|
+
* a resource when the instance does not have that resource.
|
|
657
|
+
*/
|
|
658
|
+
export declare const limitAmount: (limit: Limit, instance: Instance) => Result<Quantity, LimitProblem>;
|
|
659
|
+
/**
|
|
660
|
+
* This function gives the use of a limit on an instance by one value of its measure. The use is
|
|
661
|
+
* the value, divided by the amount of the limit. Thus a use of 1 is exactly at the limit.
|
|
662
|
+
*
|
|
663
|
+
* It gives each problem of `limitAmount`. It gives a problem for a value that is not a finite
|
|
664
|
+
* amount of 0 or more. It gives a problem for a value that does not convert to the unit of the ceiling.
|
|
665
|
+
*/
|
|
666
|
+
export declare const limitUse: (limit: Limit, instance: Instance, value: Quantity) => Result<LimitUse, LimitProblem>;
|
|
667
|
+
/**
|
|
668
|
+
* This function gives the use of each limit on an instance. The `values` give the value of each
|
|
669
|
+
* measure, by the id of the measure. The uses go from the largest to the smallest. Thus the first
|
|
670
|
+
* use is the limit that binds.
|
|
671
|
+
*
|
|
672
|
+
* A limit with no value is a problem, and not a limit that holds. The function also gives a
|
|
673
|
+
* problem for two limits with one id, and each problem of `limitUse`.
|
|
674
|
+
*/
|
|
675
|
+
export declare const limitUses: (limits: readonly Limit[], instance: Instance, values: Amounts) => Result<readonly LimitUse[], LimitProblem>;
|
|
676
|
+
/** This number is the largest count of instances of a scale search when the options give none: 2 to the power 20. */
|
|
677
|
+
export declare const SCALE_MOST: number;
|
|
678
|
+
/** This number is the count of steps of the grid of a scale search when the options give none. */
|
|
679
|
+
export declare const SCALE_STEPS: number;
|
|
680
|
+
/**
|
|
681
|
+
* A scale model holds what the scale queries of a service read: the resources of one instance, the
|
|
682
|
+
* limits of the service and the compositions. Each limit reads the composition of its measure. The
|
|
683
|
+
* catalog gives each law and each nested composition that the compositions name.
|
|
684
|
+
*/
|
|
685
|
+
interface ScaleModel {
|
|
686
|
+
readonly instance: Instance;
|
|
687
|
+
readonly limits: readonly Limit[];
|
|
688
|
+
/** Each composition gives one measure, by the id of its measure. The list can hold compositions that no limit reads. */
|
|
689
|
+
readonly compositions: readonly Composition[];
|
|
690
|
+
readonly catalog: Catalog;
|
|
691
|
+
}
|
|
692
|
+
/**
|
|
693
|
+
* These options set a scale query. The field `given` gives the state of each instance, for example
|
|
694
|
+
* its heap. A level in `whole` does not divide between the instances, as in `shareOf`.
|
|
695
|
+
*
|
|
696
|
+
* The count search goes up to `most` instances. The load search goes from `1 / most` to `most`
|
|
697
|
+
* times the demand. Each search has a grid of `steps` steps on a log scale. The level of the
|
|
698
|
+
* intervals is 0.95 when the options give none.
|
|
699
|
+
*/
|
|
700
|
+
interface ScaleOptions extends LevelOptions {
|
|
701
|
+
readonly given?: Amounts;
|
|
702
|
+
readonly whole?: readonly string[];
|
|
703
|
+
readonly most?: number;
|
|
704
|
+
readonly steps?: number;
|
|
705
|
+
}
|
|
706
|
+
/** A scale problem code names the part of a scale model, or of a scale query, that is not correct. */
|
|
707
|
+
type ScaleProblemCode = CompositionProblemCode | LimitProblemCode;
|
|
708
|
+
/** A scale problem tells what is not correct, and where: `path` is the path of the field in the model or in the query. */
|
|
709
|
+
type ScaleProblem = Problem<ScaleProblemCode>;
|
|
710
|
+
/**
|
|
711
|
+
* A limit count is the lowest count of instances that holds one limit at a load. Each larger count
|
|
712
|
+
* also holds the limit. A null count is more than the largest count of the search.
|
|
713
|
+
*/
|
|
714
|
+
interface LimitCount {
|
|
715
|
+
readonly limit: string;
|
|
716
|
+
readonly measure: string;
|
|
717
|
+
readonly count: OpenValue;
|
|
718
|
+
/** This number is the share of the replicates where this limit needs more instances than each other limit. */
|
|
719
|
+
readonly binds: number;
|
|
720
|
+
/** This flag tells that the composition has no value past the share of the estimate. Then the edge of the composition sets the count. */
|
|
721
|
+
readonly edge: boolean;
|
|
722
|
+
/** This flag tells that a law of the composition reads a variable outside its range at the count of the estimate. */
|
|
723
|
+
readonly extrapolated: boolean;
|
|
724
|
+
}
|
|
725
|
+
/**
|
|
726
|
+
* A limit reach is the first load where one limit breaks at a count of instances, as a factor of
|
|
727
|
+
* the demand. Below this factor, the limit holds. A null factor is past the end of the search.
|
|
728
|
+
*/
|
|
729
|
+
interface LimitReach {
|
|
730
|
+
readonly limit: string;
|
|
731
|
+
readonly measure: string;
|
|
732
|
+
readonly factor: OpenValue;
|
|
733
|
+
/** This number is the share of the replicates where this limit breaks before each other limit. */
|
|
734
|
+
readonly binds: number;
|
|
735
|
+
/** This flag tells that the composition has no value past the factor of the estimate. Then the edge of the composition sets the factor. */
|
|
736
|
+
readonly edge: boolean;
|
|
737
|
+
/** This flag tells that a law of the composition reads a variable outside its range at the factor of the estimate. */
|
|
738
|
+
readonly extrapolated: boolean;
|
|
739
|
+
}
|
|
740
|
+
/**
|
|
741
|
+
* A count reach is the highest load that a count of instances holds, as a factor of the demand. The
|
|
742
|
+
* demand at the factor `f` is `scaleDemand(demand, f)`. The `factor` is the first factor where a
|
|
743
|
+
* limit breaks, and the `binding` limit breaks there in the estimate.
|
|
744
|
+
*
|
|
745
|
+
* The limits go from the first limit that breaks to the last. The flag `extrapolated` tells that a
|
|
746
|
+
* law reads a variable outside its range at the factor of the estimate.
|
|
747
|
+
*/
|
|
748
|
+
interface CountReach {
|
|
749
|
+
readonly count: number;
|
|
750
|
+
readonly level: number;
|
|
751
|
+
readonly search: Range;
|
|
752
|
+
readonly factor: OpenValue;
|
|
753
|
+
readonly binding: string | null;
|
|
754
|
+
readonly extrapolated: boolean;
|
|
755
|
+
readonly limits: readonly LimitReach[];
|
|
756
|
+
}
|
|
757
|
+
/**
|
|
758
|
+
* A scale rule is the lowest count of instances that holds each limit at a load, with its interval.
|
|
759
|
+
* Each larger count also holds each limit. A null count is more than `most` instances.
|
|
760
|
+
*
|
|
761
|
+
* The `binding` limit needs the most instances in the estimate. It is null when one instance holds
|
|
762
|
+
* each limit at each share of the search. The limits go from the largest count to the smallest. The
|
|
763
|
+
* reach `next` is the highest load of the count of the estimate: there the service needs one more instance.
|
|
764
|
+
*/
|
|
765
|
+
interface ScaleRule {
|
|
766
|
+
readonly level: number;
|
|
767
|
+
readonly most: number;
|
|
768
|
+
readonly count: OpenValue;
|
|
769
|
+
readonly binding: string | null;
|
|
770
|
+
readonly extrapolated: boolean;
|
|
771
|
+
readonly limits: readonly LimitCount[];
|
|
772
|
+
readonly next: CountReach | null;
|
|
773
|
+
}
|
|
774
|
+
/**
|
|
775
|
+
* This function gives the highest load that a count of instances holds, as a factor of the demand,
|
|
776
|
+
* with an interval. Thus it is the inverse query of the scale rule. The demand divides between the
|
|
777
|
+
* instances, as in `shareOf`, and the levels in `options.whole` do not divide.
|
|
778
|
+
*
|
|
779
|
+
* Each row of the doubt of the laws has its own search. Row `i` of each limit reads row `i` of each
|
|
780
|
+
* law, thus the rows of the limits pair. The factor of a row is the first factor where one limit
|
|
781
|
+
* of the row breaks, or where a composition has no value. The interval is the share `level` of the
|
|
782
|
+
* factors of the replicates, made wider to hold the factor of the estimate.
|
|
783
|
+
*
|
|
784
|
+
* The search tests a grid of factors, then a bisection finds each crossing. A crossing between two
|
|
785
|
+
* loads of the grid is found. Two crossings in one step of the grid can hide the first.
|
|
786
|
+
*
|
|
787
|
+
* The function gives a problem for a model, a demand or options that are not correct. It gives a
|
|
788
|
+
* problem for a count that is not a whole number of 1 or more. It also gives a problem when a
|
|
789
|
+
* composition has no value at the start of the search.
|
|
790
|
+
*/
|
|
791
|
+
export declare const countReach: (model: ScaleModel, count: number, demand: Demand, options?: ScaleOptions) => Result<CountReach, ScaleProblem>;
|
|
792
|
+
/**
|
|
793
|
+
* This function gives the scale rule of a service at a load: the lowest count of instances that
|
|
794
|
+
* holds each limit, with an interval. It also gives the limit that binds first, and the load of the
|
|
795
|
+
* next step: the highest load of that count, from `countReach`.
|
|
796
|
+
*
|
|
797
|
+
* The search goes along the share of the demand on one instance: the share of `n` instances is
|
|
798
|
+
* `1 / n`. It starts at the share of `most` instances and goes up to the share of one instance. The
|
|
799
|
+
* count of a row comes from the first share where one limit of the row breaks. Thus the count holds
|
|
800
|
+
* each limit, and each larger count also holds each limit. A level in `options.whole` does not divide.
|
|
801
|
+
*
|
|
802
|
+
* Each row of the doubt of the laws has its own search, and the rows of the limits pair, as in
|
|
803
|
+
* `countReach`. The interval of the count is the share `level` of the counts of the replicates, made
|
|
804
|
+
* wider to hold the count of the estimate. The field `binds` of each limit is the share of the
|
|
805
|
+
* replicates where that limit sets the count.
|
|
806
|
+
*
|
|
807
|
+
* The function gives each problem of `countReach` that is not about a count.
|
|
808
|
+
*/
|
|
809
|
+
export declare const scaleRule: (model: ScaleModel, demand: Demand, options?: ScaleOptions) => Result<ScaleRule, ScaleProblem>;
|
|
810
|
+
/** A limit ladder holds, for each row of one limit, the first load on one instance where the row breaks the limit. */
|
|
811
|
+
interface LimitLadder {
|
|
812
|
+
readonly limit: string;
|
|
813
|
+
readonly measure: string;
|
|
814
|
+
/**
|
|
815
|
+
* Each value is the first load on one instance, as a factor of the demand, where one row breaks the limit. Row 0 is the
|
|
816
|
+
* estimate. A load where the composition has no value also breaks the row. Infinity tells that the row holds on all of the search.
|
|
817
|
+
*/
|
|
818
|
+
readonly rows: readonly number[];
|
|
819
|
+
/** This flag tells that the edge of the composition sets the load of row 0. */
|
|
820
|
+
readonly edge: boolean;
|
|
821
|
+
}
|
|
822
|
+
/**
|
|
823
|
+
* A scale ladder is the scale rule of a service at each load of a range, from one search. With no level in `whole`, the
|
|
824
|
+
* demand on one of `n` instances at `f` times the load is the demand at `f / n` times the load. Thus each row of each
|
|
825
|
+
* limit breaks at one load on one instance, and a count needs only arithmetic.
|
|
826
|
+
*
|
|
827
|
+
* The function `ruleAt(f)` gives the value of `scaleRule` at the demand `scaleDemand(demand, f)`. The function
|
|
828
|
+
* `reachAt(n, f)` gives the value of `countReach` for `n` instances at the same demand. Each of them reads the
|
|
829
|
+
* compositions only for the flags `extrapolated`, one value for each limit.
|
|
830
|
+
*/
|
|
831
|
+
interface ScaleLadder {
|
|
832
|
+
readonly level: number;
|
|
833
|
+
readonly most: number;
|
|
834
|
+
/** This range holds the factors of the demand that the ladder answers. */
|
|
835
|
+
readonly range: Range;
|
|
836
|
+
/** This range holds the loads on one instance of the search, as factors of the demand. */
|
|
837
|
+
readonly search: Range;
|
|
838
|
+
/** The limits are in the order of the model. */
|
|
839
|
+
readonly limits: readonly LimitLadder[];
|
|
840
|
+
readonly ruleAt: (factor: number) => Result<ScaleRule, ScaleProblem>;
|
|
841
|
+
readonly reachAt: (count: number, factor: number) => Result<CountReach, ScaleProblem>;
|
|
842
|
+
}
|
|
843
|
+
/**
|
|
844
|
+
* This function gives the scale ladder of a service over the factors of the demand from `range.low` to `range.high`.
|
|
845
|
+
* The search covers the loads on one instance that `scaleRule` and `countReach` read at each factor of the range: from
|
|
846
|
+
* `range.low / most` to `range.high * most`. Its grid has the density of the grid of `scaleRule`, up to the largest
|
|
847
|
+
* count of steps.
|
|
848
|
+
*
|
|
849
|
+
* The values of the ladder agree with `scaleRule` and `countReach` to the precision of their bisections. They can differ
|
|
850
|
+
* when two crossings are in one step of a grid, because the grids are different.
|
|
851
|
+
*
|
|
852
|
+
* The function gives each problem of `scaleRule`. It also gives a problem for a level in `options.whole`. With such a level,
|
|
853
|
+
* the demand on one instance does not depend only on the load over the count. It gives a problem for a range that does not
|
|
854
|
+
* go from a number above 0 to a larger finite number.
|
|
855
|
+
*/
|
|
856
|
+
export declare const scaleLadder: (model: ScaleModel, demand: Demand, range: Range, options?: ScaleOptions) => Result<ScaleLadder, ScaleProblem>;
|
|
857
|
+
export { APP_FILE, APP_FORMAT, APP_LINE_KINDS, type AmountCeiling, type Amounts, type AppClass, type AppCommand, type AppContract, type AppEntry, type AppLine, type AppLineKind, type AppProblem, type AppProblemCode, type AppProcess, type AppRange, type AppReady, type AppRun, type AppSeries, type AppService, type AppStart, type AppVariable, type Binding, type Bounds, COMPOSITION_FORMAT, type Catalog, type CatalogForm, type Ceiling, type Composition, type CompositionOptions, type CompositionProblem, type CompositionProblemCode, type CompositionTerm, type CompositionValue, type ConditionValue, type Constant, type ConstantInterval, type CountReach, type Crossing, DEFAULT_LEVEL, type Demand, type Evidence, type Fit, type FitError, type Floor, type Form, type FormRank, type GateCase, type GateJob, type GateRead, type Grid, type HttpEntry, INSTANCE_FORMAT, type Instance, type InstanceProblem, type InstanceProblemCode, type InstanceType, type JobCount, type Knee, type KneeOptions, type KneeRule, LAW_FORMAT, LIMITS_FORMAT, type Law, type LawFit, type LawFitOptions, type LawGate, type LawGateCase, type LawGateOptions, type LawPart, type LawProblem, type LawRead, type LawTerm, type LawValue, type LevelOptions, type Limit, type LimitCount, type LimitLadder, type LimitProblem, type LimitProblemCode, type LimitReach, type LimitSet, type LimitUse, type Load, type LoadPoint, type Loser, MAX_VARIABLES, type Measure, type MetricsGap, type MetricsSource, type MetricsWindow, NO_DEMAND, type NestedPart, type NestedTerm, type NoReadJob, type Noise, type Observation, type ObservedClass, type OpenRange, type OpenValue, type Over, type PartValue, type PlanSource, type PointLaw, type PointOptions, type Points, type Problem, type ProblemCode, RATE, RESOURCE_UNITS, type Range, type Reach, type ReadSide, type ResidualKind, type ResourceCeiling, type Run, type RunPoint, type Scale, type ScaleLadder, type ScaleModel, type ScaleOptions, type ScaleProblem, type ScaleProblemCode, type ScaleRule, type SeriesReading, type SeriesTarget, type ServiceEntry, type Shape, type ShareOptions, type SideTest, type Start, type Term, type Variable, type VariableKind, WORKLOAD_FORMAT, type Workload, type WorkloadClass, type WorkloadName, type WorkloadProblem, type WorkloadProblemCode, type WorkloadSource, bootstrapDraws, checkComposition, compositionValue, constantIntervals, instancePointOf, isLawTerm, lawValue, leastCount, leastGroups, loadPointOf, mergeDemands, scaleDemand, shareOf, totalRate };
|
|
858
|
+
//# sourceMappingURL=index.d.ts.map
|