@drupflare/spool 0.3.0 → 0.4.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/README.md +263 -41
- package/dist/cdn/client.js +1 -1
- package/dist/cdn/manifest.json +7 -7
- package/dist/cdn/spool-sw.js +1 -1
- package/dist/client/entry.js +33 -1
- package/dist/client/register.d.ts +23 -1
- package/dist/client/register.js +53 -7
- package/dist/protocol/config.d.ts +16 -1
- package/dist/protocol/config.js +3 -1
- package/dist/protocol/dataset.d.ts +183 -0
- package/dist/protocol/dataset.js +206 -0
- package/dist/protocol/envelope.d.ts +1 -0
- package/dist/protocol/envelope.js +2 -1
- package/dist/protocol/errors.d.ts +1 -1
- package/dist/protocol/graph.d.ts +23 -4
- package/dist/protocol/graph.js +34 -3
- package/dist/protocol/index.d.ts +3 -0
- package/dist/protocol/index.js +3 -0
- package/dist/protocol/plan.d.ts +100 -0
- package/dist/protocol/plan.js +661 -0
- package/dist/protocol/provision.d.ts +46 -0
- package/dist/protocol/provision.js +38 -0
- package/dist/protocol/query.d.ts +66 -5
- package/dist/protocol/query.js +103 -4
- package/dist/protocol/route.d.ts +6 -2
- package/dist/protocol/route.js +31 -3
- package/dist/protocol/write.d.ts +146 -0
- package/dist/protocol/write.js +101 -0
- package/dist/report/dataset.d.ts +48 -0
- package/dist/report/dataset.js +93 -0
- package/dist/report/derive.d.ts +285 -0
- package/dist/report/derive.js +676 -1
- package/dist/report/economics.d.ts +11 -1
- package/dist/report/economics.js +19 -1
- package/dist/report/index.d.ts +2 -0
- package/dist/report/index.js +2 -0
- package/dist/report/inputs.d.ts +97 -0
- package/dist/report/inputs.js +133 -0
- package/dist/report/institution.d.ts +188 -1
- package/dist/report/institution.js +146 -0
- package/dist/report/loops.d.ts +73 -0
- package/dist/report/loops.js +101 -0
- package/dist/report/measurement.d.ts +1 -1
- package/dist/report/measurement.js +3 -1
- package/dist/report/model.d.ts +2 -0
- package/dist/report/model.js +4 -0
- package/dist/report/thirdparty.d.ts +57 -0
- package/dist/report/thirdparty.js +111 -0
- package/dist/report/trim.d.ts +56 -0
- package/dist/report/trim.js +83 -1
- package/dist/server/dataset.d.ts +48 -0
- package/dist/server/dataset.js +308 -0
- package/dist/server/embedded.d.ts +3 -3
- package/dist/server/embedded.js +3 -3
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.js +2 -0
- package/dist/server/spool.d.ts +20 -0
- package/dist/server/spool.js +126 -18
- package/dist/server/write.d.ts +27 -0
- package/dist/server/write.js +127 -0
- package/dist/sw/analytics.d.ts +6 -0
- package/dist/sw/analytics.js +14 -0
- package/dist/sw/dataset-sync.d.ts +76 -0
- package/dist/sw/dataset-sync.js +149 -0
- package/dist/sw/dataset.d.ts +91 -0
- package/dist/sw/dataset.js +318 -0
- package/dist/sw/graph/index.d.ts +31 -1
- package/dist/sw/graph/index.js +57 -5
- package/dist/sw/graph/invalidate.d.ts +15 -3
- package/dist/sw/graph/invalidate.js +42 -4
- package/dist/sw/idb.js +78 -9
- package/dist/sw/partition.d.ts +6 -1
- package/dist/sw/partition.js +21 -2
- package/dist/sw/principal-dataset.d.ts +64 -0
- package/dist/sw/principal-dataset.js +254 -0
- package/dist/sw/render.d.ts +7 -2
- package/dist/sw/render.js +19 -5
- package/dist/sw/replica.d.ts +12 -3
- package/dist/sw/replica.js +40 -5
- package/dist/sw/runtime.d.ts +43 -2
- package/dist/sw/runtime.js +340 -24
- package/dist/sw/seal.d.ts +13 -0
- package/dist/sw/seal.js +13 -4
- package/dist/sw/static.d.ts +18 -0
- package/dist/sw/static.js +84 -1
- package/dist/sw/storage.d.ts +51 -1
- package/dist/sw/storage.js +33 -1
- package/dist/sw/write.d.ts +107 -0
- package/dist/sw/write.js +442 -0
- package/package.json +3 -2
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { ProtocolError } from './errors.js';
|
|
2
|
+
import { checkPattern } from './pattern.js';
|
|
3
|
+
/** the header that names one flush of one key; a retry of the same flush sends the same id */
|
|
4
|
+
export const WRITE_HEADERS = { id: 'spool-write-id' };
|
|
5
|
+
/** a write class name is 1 to 64 of letters, digits, `_` and `-` */
|
|
6
|
+
export const WRITE_NAME = /^[A-Za-z0-9_-]{1,64}$/;
|
|
7
|
+
const VERSION = /^[A-Za-z0-9._:~-]{1,128}$/;
|
|
8
|
+
const WRITE_ID = /^[A-Za-z0-9_-]{16,64}$/;
|
|
9
|
+
/** the most characters in a key */
|
|
10
|
+
export const MAX_WRITE_KEY = 256;
|
|
11
|
+
/** the most bytes `maxBytes` may declare for one value's JSON body */
|
|
12
|
+
export const MAX_WRITE_BYTES = 1_048_576;
|
|
13
|
+
/** the most records `maxPending` may declare per class and partition */
|
|
14
|
+
export const MAX_WRITE_PENDING = 1000;
|
|
15
|
+
/** the status the server answers each refusal with */
|
|
16
|
+
export const WRITE_STATUS = {
|
|
17
|
+
'writes-off': 403,
|
|
18
|
+
'unknown-write': 404,
|
|
19
|
+
'bad-method': 405,
|
|
20
|
+
'bad-key': 400,
|
|
21
|
+
'missing-version': 428,
|
|
22
|
+
'bad-version': 400,
|
|
23
|
+
'bad-id': 400,
|
|
24
|
+
'bad-body': 400,
|
|
25
|
+
'too-large': 413,
|
|
26
|
+
'too-many': 429,
|
|
27
|
+
'id-reused': 422,
|
|
28
|
+
forbidden: 403,
|
|
29
|
+
'sign-in': 401,
|
|
30
|
+
'no-partition': 409,
|
|
31
|
+
'no-record': 404,
|
|
32
|
+
'not-conflicted': 409,
|
|
33
|
+
unavailable: 503
|
|
34
|
+
};
|
|
35
|
+
function bad(name, message) {
|
|
36
|
+
throw new ProtocolError('bad-write', `${name}: ${message}`);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Declares a write class. Throws `bad-write` for a public scope, a kind other than `last-value`, a
|
|
40
|
+
* name or pattern that does not parse, a missing function or a limit that is not a positive
|
|
41
|
+
* integer within its cap.
|
|
42
|
+
*/
|
|
43
|
+
export function defineWrite(declaration) {
|
|
44
|
+
const name = String(declaration?.name);
|
|
45
|
+
if (typeof declaration?.name !== 'string' || !WRITE_NAME.test(declaration.name)) {
|
|
46
|
+
return bad(name, 'a write name is 1 to 64 of letters, digits, _ and -');
|
|
47
|
+
}
|
|
48
|
+
const scope = declaration.scope;
|
|
49
|
+
if (scope !== 'principal') {
|
|
50
|
+
return bad(name, `scope must be "principal"; a "${scope}" write is never queued`);
|
|
51
|
+
}
|
|
52
|
+
const kind = declaration.kind ?? 'last-value';
|
|
53
|
+
if (kind !== 'last-value') {
|
|
54
|
+
return bad(name, `kind "${kind}" does not exist; the only kind is "last-value"`);
|
|
55
|
+
}
|
|
56
|
+
if (typeof declaration.path !== 'string')
|
|
57
|
+
return bad(name, 'path must be a route pattern');
|
|
58
|
+
checkPattern(declaration.path);
|
|
59
|
+
for (const fn of ['key', 'read', 'apply']) {
|
|
60
|
+
if (typeof declaration[fn] !== 'function')
|
|
61
|
+
return bad(name, `${fn} must be a function`);
|
|
62
|
+
}
|
|
63
|
+
const caps = { maxBytes: MAX_WRITE_BYTES, maxPending: MAX_WRITE_PENDING };
|
|
64
|
+
for (const limit of ['maxBytes', 'maxPending']) {
|
|
65
|
+
const value = declaration[limit];
|
|
66
|
+
if (!Number.isSafeInteger(value) || value < 1 || value > caps[limit]) {
|
|
67
|
+
return bad(name, `${limit} must be an integer from 1 to ${caps[limit]}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return Object.freeze({ ...declaration, kind: 'last-value' });
|
|
71
|
+
}
|
|
72
|
+
/** the config entry the worker gets for a class */
|
|
73
|
+
export function serializeWrite(write) {
|
|
74
|
+
return { name: write.name, maxBytes: write.maxBytes, maxPending: write.maxPending };
|
|
75
|
+
}
|
|
76
|
+
/** whether `key` is a key the wire carries: a non-empty string of at most {@link MAX_WRITE_KEY} characters without NUL */
|
|
77
|
+
export function isWriteKey(key) {
|
|
78
|
+
return (typeof key === 'string' &&
|
|
79
|
+
key.length > 0 &&
|
|
80
|
+
key.length <= MAX_WRITE_KEY &&
|
|
81
|
+
!key.includes('\u0000'));
|
|
82
|
+
}
|
|
83
|
+
/** whether `version` is a version the wire carries */
|
|
84
|
+
export const isWriteVersion = (version) => typeof version === 'string' && VERSION.test(version);
|
|
85
|
+
/** whether `id` is a write id the wire carries */
|
|
86
|
+
export const isWriteId = (id) => typeof id === 'string' && WRITE_ID.test(id);
|
|
87
|
+
/** the `If-Match` value for a version: a strong entity tag */
|
|
88
|
+
export const ifMatch = (version) => `"${version}"`;
|
|
89
|
+
/** the version in an `If-Match` value, or null when it is not one strong entity tag of a valid version */
|
|
90
|
+
export function readIfMatch(header) {
|
|
91
|
+
const match = header === null ? null : /^"([^"]*)"$/.exec(header.trim());
|
|
92
|
+
return match && isWriteVersion(match[1]) ? match[1] : null;
|
|
93
|
+
}
|
|
94
|
+
/** a random write id: 22 base64url characters of 128 random bits */
|
|
95
|
+
export function newWriteId() {
|
|
96
|
+
const bytes = crypto.getRandomValues(new Uint8Array(16));
|
|
97
|
+
let binary = '';
|
|
98
|
+
for (const byte of bytes)
|
|
99
|
+
binary += String.fromCharCode(byte);
|
|
100
|
+
return btoa(binary).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
|
101
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Row } from './measurement.js';
|
|
2
|
+
/** bytes of the 304 a plain HTTP cache gets back, socket bytes (L1, `measurements/dataset-baseline/2026-11-15.json`) */
|
|
3
|
+
export declare const NOT_MODIFIED_SOCKET_BYTES = 220;
|
|
4
|
+
/** bytes of the first load of a seed, per collection size, for the three arms */
|
|
5
|
+
export type DatasetSeed = {
|
|
6
|
+
v03: number;
|
|
7
|
+
v04: number;
|
|
8
|
+
native: number;
|
|
9
|
+
};
|
|
10
|
+
/** bytes of one update to a collection of `rows`, for the three arms; `v03Records` is the records shape with `have` */
|
|
11
|
+
export type DatasetUpdate = {
|
|
12
|
+
rows: number;
|
|
13
|
+
change: string;
|
|
14
|
+
changedRows: number;
|
|
15
|
+
v03: number;
|
|
16
|
+
v03Records: number | null;
|
|
17
|
+
v04: number;
|
|
18
|
+
native: number;
|
|
19
|
+
};
|
|
20
|
+
export type DatasetFigures = {
|
|
21
|
+
seeds: Record<number, DatasetSeed>;
|
|
22
|
+
updates: DatasetUpdate[];
|
|
23
|
+
};
|
|
24
|
+
/** the three arms' bytes from the raw rows of a dataset-baseline reading, gate open and list shape for v0.3 */
|
|
25
|
+
export declare function datasetFigures(rows: readonly Row[]): DatasetFigures;
|
|
26
|
+
/** a site's traffic and updates, declared per site (L3) */
|
|
27
|
+
export type Site = {
|
|
28
|
+
name: string;
|
|
29
|
+
viewsPerDay: number;
|
|
30
|
+
updatesPerDay: number;
|
|
31
|
+
devices: number;
|
|
32
|
+
};
|
|
33
|
+
export type SiteFigures = {
|
|
34
|
+
/** views per device per day that a held copy answers: views per device times the return survival */
|
|
35
|
+
served: number;
|
|
36
|
+
/** patches or refetches per device per day, at most one per answered view */
|
|
37
|
+
fetches: number;
|
|
38
|
+
bytesPerDay: Record<'v03' | 'v04' | 'native', number>;
|
|
39
|
+
joulesPerDay: Record<'v03' | 'v04' | 'native', number>;
|
|
40
|
+
/** updates per device over one hold that repay the v0.4 seed's extra bytes against the v0.3 control */
|
|
41
|
+
breakEven: number;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Bytes per device per day for each arm at a site. A device holds one copy for `DATASET_DEFAULTS.holdDays`
|
|
45
|
+
* and refetches the seed each time. Views that find a copy are `views x survival`; a native cache
|
|
46
|
+
* revalidates on each of those views and sends the full resource when a change landed since the last one.
|
|
47
|
+
*/
|
|
48
|
+
export declare function siteFigures(site: Site, seed: DatasetSeed, update: DatasetUpdate): SiteFigures;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { DATASET_DEFAULTS } from '../protocol/provision.js';
|
|
2
|
+
import { attributionalJoules } from './model.js';
|
|
3
|
+
/** bytes of the 304 a plain HTTP cache gets back, socket bytes (L1, `measurements/dataset-baseline/2026-11-15.json`) */
|
|
4
|
+
export const NOT_MODIFIED_SOCKET_BYTES = 220;
|
|
5
|
+
const at = (row, key) => {
|
|
6
|
+
const value = row[key];
|
|
7
|
+
if (typeof value !== 'object' || value === null)
|
|
8
|
+
throw new TypeError(`no ${key} in the row`);
|
|
9
|
+
return value;
|
|
10
|
+
};
|
|
11
|
+
const num = (row, key) => {
|
|
12
|
+
const value = row[key];
|
|
13
|
+
if (typeof value !== 'number')
|
|
14
|
+
throw new TypeError(`no numeric ${key} in the row`);
|
|
15
|
+
return value;
|
|
16
|
+
};
|
|
17
|
+
/** the three arms' bytes from the raw rows of a dataset-baseline reading, gate open and list shape for v0.3 */
|
|
18
|
+
export function datasetFigures(rows) {
|
|
19
|
+
const scenarios = rows.filter((r) => r.kind === 'scenario' && r.arm === 'gate open');
|
|
20
|
+
const sizes = [...new Set(scenarios.map((r) => num(r, 'n')))].sort((a, b) => a - b);
|
|
21
|
+
const seeds = {};
|
|
22
|
+
const updates = [];
|
|
23
|
+
const find = (pick) => {
|
|
24
|
+
const found = rows.find(pick);
|
|
25
|
+
if (!found)
|
|
26
|
+
throw new RangeError('the reading has no row for this collection and change');
|
|
27
|
+
return found;
|
|
28
|
+
};
|
|
29
|
+
for (const n of sizes) {
|
|
30
|
+
for (const change of ['change-1', 'change-1pct']) {
|
|
31
|
+
const list = find((r) => r.kind === 'scenario' &&
|
|
32
|
+
r.shape === 'list' &&
|
|
33
|
+
r.arm === 'gate open' &&
|
|
34
|
+
r.n === n &&
|
|
35
|
+
r.change === change);
|
|
36
|
+
const records = rows.find((r) => r.kind === 'scenario' &&
|
|
37
|
+
r.shape === 'records' &&
|
|
38
|
+
r.arm === 'gate open' &&
|
|
39
|
+
r.n === n &&
|
|
40
|
+
r.change === change);
|
|
41
|
+
const v04 = find((r) => r.kind === 'v04' && r.n === n && r.change === change);
|
|
42
|
+
const native = find((r) => r.kind === 'native' && r.n === n && r.change === change);
|
|
43
|
+
if (change === 'change-1') {
|
|
44
|
+
seeds[n] = {
|
|
45
|
+
v03: num(at(list, 'seed'), 'brotli'),
|
|
46
|
+
v04: num(at(v04, 'seed'), 'brotli'),
|
|
47
|
+
native: num(at(native, 'firstLoad'), 'socketBytes')
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
updates.push({
|
|
51
|
+
rows: n,
|
|
52
|
+
change,
|
|
53
|
+
changedRows: num(list, 'changedRows'),
|
|
54
|
+
v03: num(at(list, 'refetchWithout'), 'brotli'),
|
|
55
|
+
v03Records: records?.refetchWithHave
|
|
56
|
+
? num(at(records, 'refetchWithHave'), 'brotli')
|
|
57
|
+
: null,
|
|
58
|
+
v04: num(at(v04, 'patch'), 'brotli'),
|
|
59
|
+
native: num(at(native, 'revalidateChanged'), 'socketBytes')
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return { seeds, updates };
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Bytes per device per day for each arm at a site. A device holds one copy for `DATASET_DEFAULTS.holdDays`
|
|
67
|
+
* and refetches the seed each time. Views that find a copy are `views x survival`; a native cache
|
|
68
|
+
* revalidates on each of those views and sends the full resource when a change landed since the last one.
|
|
69
|
+
*/
|
|
70
|
+
export function siteFigures(site, seed, update) {
|
|
71
|
+
const { survival, holdDays } = DATASET_DEFAULTS;
|
|
72
|
+
const served = (site.viewsPerDay / site.devices) * survival;
|
|
73
|
+
const fetches = Math.min(site.updatesPerDay, served);
|
|
74
|
+
const changed = served > 0 ? 1 - Math.exp(-site.updatesPerDay / served) : 0;
|
|
75
|
+
const bytesPerDay = {
|
|
76
|
+
v03: seed.v03 / holdDays + fetches * update.v03,
|
|
77
|
+
v04: seed.v04 / holdDays + fetches * update.v04,
|
|
78
|
+
native: served * (changed * update.native + (1 - changed) * NOT_MODIFIED_SOCKET_BYTES)
|
|
79
|
+
};
|
|
80
|
+
const saved = update.v03 - update.v04;
|
|
81
|
+
const extra = Math.max(0, seed.v04 - seed.v03);
|
|
82
|
+
return {
|
|
83
|
+
served,
|
|
84
|
+
fetches,
|
|
85
|
+
bytesPerDay,
|
|
86
|
+
joulesPerDay: {
|
|
87
|
+
v03: attributionalJoules(bytesPerDay.v03),
|
|
88
|
+
v04: attributionalJoules(bytesPerDay.v04),
|
|
89
|
+
native: attributionalJoules(bytesPerDay.native)
|
|
90
|
+
},
|
|
91
|
+
breakEven: saved > 0 ? extra / saved : Infinity
|
|
92
|
+
};
|
|
93
|
+
}
|
package/dist/report/derive.d.ts
CHANGED
|
@@ -63,6 +63,37 @@ export declare function saving(a: {
|
|
|
63
63
|
}, b: {
|
|
64
64
|
joules: Spread;
|
|
65
65
|
}): number;
|
|
66
|
+
/** one arm of an idle-activity-tabs reading, per minute and net of its floor */
|
|
67
|
+
export type TabsArm = {
|
|
68
|
+
/** kept windows that had a floor to net against */
|
|
69
|
+
windows: number;
|
|
70
|
+
/** the round's idle draw, or for the three-tab polling arms the quiet window of the same round */
|
|
71
|
+
floor: 'idle' | 'tabs-3-quiet';
|
|
72
|
+
/** package joules per minute above the floor */
|
|
73
|
+
joulesPerMinute: Spread;
|
|
74
|
+
/** origin requests per minute in the window */
|
|
75
|
+
pingsPerMinute: Spread;
|
|
76
|
+
};
|
|
77
|
+
/** the figures of an idle-activity-tabs reading; `ratio` holds arm medians, when both arms exist */
|
|
78
|
+
export type TabsFigures = {
|
|
79
|
+
idleWatts: Spread | null;
|
|
80
|
+
dropped: number;
|
|
81
|
+
/** windows of a three-tab polling arm with no kept tabs-3-quiet window in their round */
|
|
82
|
+
unmatched: number;
|
|
83
|
+
arms: Record<string, TabsArm>;
|
|
84
|
+
ratio: {
|
|
85
|
+
poll3ToLeader?: number;
|
|
86
|
+
poll3ToPoll1?: number;
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Joules per minute above the idle draw of each kept window of an idle-activity-tabs run, per arm.
|
|
91
|
+
* A window is dropped over the contamination limit. The idle draw is the median of the kept idle
|
|
92
|
+
* windows of its round. The two three-tab polling arms are netted against the tabs-3-quiet window
|
|
93
|
+
* of the same round, and a window whose round has none is left out. The one-tab and hidden arms
|
|
94
|
+
* are not netted against a quiet arm: the rig has no quiet arm for them.
|
|
95
|
+
*/
|
|
96
|
+
export declare function tabsFigures(rows: readonly Row[]): TabsFigures;
|
|
66
97
|
/** the per-request cost of a locally served model, above the model-resident idle draw */
|
|
67
98
|
export type InferenceFigures = {
|
|
68
99
|
rounds: number;
|
|
@@ -153,6 +184,8 @@ export type NavFigures = {
|
|
|
153
184
|
medianDocBytes: number;
|
|
154
185
|
medianThirdPartyBytes: number;
|
|
155
186
|
};
|
|
187
|
+
/** a navigation that loaded the site's page; a 4xx or 5xx document is a block page, not the site */
|
|
188
|
+
export declare function loaded(nav: Row): boolean;
|
|
156
189
|
/** bytes and request counts by navigation kind, over the navigations that loaded */
|
|
157
190
|
export declare function repeatNavFigures(rows: readonly Row[]): Record<string, NavFigures>;
|
|
158
191
|
/**
|
|
@@ -221,3 +254,255 @@ export type WireFigures = {
|
|
|
221
254
|
};
|
|
222
255
|
/** medians by navigation kind from an on-wire run: rows carry a `wire` summary beside the browser's counts */
|
|
223
256
|
export declare function onWireFigures(rows: readonly Row[]): Record<string, WireFigures>;
|
|
257
|
+
/** the least-squares coefficients of `y` on the columns of `X`, with the residual standard error */
|
|
258
|
+
export type LeastSquares = {
|
|
259
|
+
coef: number[];
|
|
260
|
+
rss: number;
|
|
261
|
+
residualSe: number;
|
|
262
|
+
n: number;
|
|
263
|
+
};
|
|
264
|
+
/** ordinary least squares by the normal equations; `X` rows must each hold every column */
|
|
265
|
+
export declare function leastSquares(X: ReadonlyArray<readonly number[]>, y: readonly number[]): LeastSquares;
|
|
266
|
+
/** a page of the first-view corpus as the run's `method` lists it */
|
|
267
|
+
export type FirstViewPageInfo = {
|
|
268
|
+
id: string;
|
|
269
|
+
site: string;
|
|
270
|
+
wireBytes: number;
|
|
271
|
+
classBytes: Record<string, number>;
|
|
272
|
+
facade: boolean;
|
|
273
|
+
requests?: number;
|
|
274
|
+
};
|
|
275
|
+
/** the first-view figures of one run, every value over the pages it measured */
|
|
276
|
+
export type FirstViewFigures = {
|
|
277
|
+
rounds: number;
|
|
278
|
+
pages: number;
|
|
279
|
+
sites: number;
|
|
280
|
+
wireBytes: number;
|
|
281
|
+
/** windows over the contamination limit, dropped before any figure */
|
|
282
|
+
dropped: number;
|
|
283
|
+
idleWatts: Spread;
|
|
284
|
+
/** metered joules per first view, per page's median over rounds, above idle */
|
|
285
|
+
joules: {
|
|
286
|
+
mean: number;
|
|
287
|
+
median: number;
|
|
288
|
+
};
|
|
289
|
+
/** SWD v4 attributional joules of each page's wire bytes */
|
|
290
|
+
attributional: {
|
|
291
|
+
mean: number;
|
|
292
|
+
median: number;
|
|
293
|
+
};
|
|
294
|
+
ratio: {
|
|
295
|
+
/** mean over pages of metered over attributional */
|
|
296
|
+
mean: number;
|
|
297
|
+
median: number;
|
|
298
|
+
/** metered mean over attributional mean */
|
|
299
|
+
ofMeans: number;
|
|
300
|
+
/** the mean ratio of each site's pages, lowest and highest */
|
|
301
|
+
siteMin: number;
|
|
302
|
+
siteMax: number;
|
|
303
|
+
sites: number;
|
|
304
|
+
};
|
|
305
|
+
/** least-squares fit of metered joules per page on the class bytes, in joules per MB */
|
|
306
|
+
fit: {
|
|
307
|
+
n: number;
|
|
308
|
+
intercept: number;
|
|
309
|
+
image: number;
|
|
310
|
+
script: number;
|
|
311
|
+
other: number;
|
|
312
|
+
residualSe: number;
|
|
313
|
+
/** each term's share of the metered joules over the pages */
|
|
314
|
+
shares: {
|
|
315
|
+
intercept: number;
|
|
316
|
+
image: number;
|
|
317
|
+
script: number;
|
|
318
|
+
other: number;
|
|
319
|
+
};
|
|
320
|
+
};
|
|
321
|
+
/** the facade arm on pages whose iframes it changes; null when no page has one */
|
|
322
|
+
facade: {
|
|
323
|
+
pages: number;
|
|
324
|
+
savedJ: {
|
|
325
|
+
mean: number;
|
|
326
|
+
median: number;
|
|
327
|
+
};
|
|
328
|
+
savedBytes: {
|
|
329
|
+
mean: number;
|
|
330
|
+
median: number;
|
|
331
|
+
};
|
|
332
|
+
savedShare: number;
|
|
333
|
+
} | null;
|
|
334
|
+
missedPages: string[];
|
|
335
|
+
};
|
|
336
|
+
/** the key of the null route in a `drupal-render` reading: arm, URL class and phase */
|
|
337
|
+
export declare const DRUPAL_NULL_KEY = "null/null/steady";
|
|
338
|
+
/** header values an arm's responses carried, counted */
|
|
339
|
+
export type DrupalCacheCounts = {
|
|
340
|
+
page: Record<string, number>;
|
|
341
|
+
dynamic: Record<string, number>;
|
|
342
|
+
};
|
|
343
|
+
/** one arm, URL class and phase of a `drupal-render` reading, per request */
|
|
344
|
+
export type DrupalArmFigures = {
|
|
345
|
+
rounds: number;
|
|
346
|
+
/** joules per request above the round's idle draw, over the rounds */
|
|
347
|
+
gross: Spread;
|
|
348
|
+
/** the same less the null route of that round; null when no round pairs with it */
|
|
349
|
+
net: Spread | null;
|
|
350
|
+
status: Record<string, number>;
|
|
351
|
+
cache: DrupalCacheCounts;
|
|
352
|
+
};
|
|
353
|
+
export type DrupalRenderFigures = {
|
|
354
|
+
rounds: number;
|
|
355
|
+
/** windows over the contamination limit, dropped before any figure */
|
|
356
|
+
dropped: number;
|
|
357
|
+
/** the idle draw of each round: the mean of its kept idle windows */
|
|
358
|
+
idleWatts: Spread;
|
|
359
|
+
arms: Record<string, DrupalArmFigures>;
|
|
360
|
+
};
|
|
361
|
+
/**
|
|
362
|
+
* Joules per request of a `drupal-render` reading. A window's energy less its round's idle draw
|
|
363
|
+
* times its length, over its requests. Each round pairs an arm's window with the null route's
|
|
364
|
+
* window of the same round, so the net figure is paired per round, not a difference of medians.
|
|
365
|
+
*/
|
|
366
|
+
export declare function drupalRenderFigures(rows: readonly Row[]): DrupalRenderFigures;
|
|
367
|
+
/**
|
|
368
|
+
* The first-view figures of a `rapl first-view` reading. A window's joules are its package energy
|
|
369
|
+
* less the idle draw of its round times its length, over its navigations. Each page's figure is the
|
|
370
|
+
* median over the rounds of its original arm; the facade arm is compared with the same page's
|
|
371
|
+
* original arm. The fit is ordinary least squares of each page's joules on its image, script and
|
|
372
|
+
* other bytes, so its coefficients and shares are indicative at this many pages.
|
|
373
|
+
*/
|
|
374
|
+
export declare function firstViewFigures(measurement: Measurement): FirstViewFigures;
|
|
375
|
+
/** one file count at one emulated delay of a chunk-split run, per navigation */
|
|
376
|
+
export type ChunkArmFigures = {
|
|
377
|
+
chunks: number;
|
|
378
|
+
rttMs: number;
|
|
379
|
+
/** windows of this arm, one per round */
|
|
380
|
+
rounds: number;
|
|
381
|
+
/** joules above the round's idle draw per navigation, median and range over rounds */
|
|
382
|
+
joules: Spread;
|
|
383
|
+
/** requests the origin counted per navigation */
|
|
384
|
+
requests: number;
|
|
385
|
+
/** wire bytes the origin sent per navigation */
|
|
386
|
+
bytes: number;
|
|
387
|
+
/** bytes above the one-file arm of the same delay, per navigation */
|
|
388
|
+
bytePenalty: number;
|
|
389
|
+
/** SWD v4 joules of the byte penalty (L2, attributional) */
|
|
390
|
+
penaltyJ: number;
|
|
391
|
+
/** ScriptDuration and TaskDuration in ms per navigation */
|
|
392
|
+
scriptMs: number;
|
|
393
|
+
taskMs: number;
|
|
394
|
+
/** origin CPU milliseconds per navigation */
|
|
395
|
+
originCpuMs: number;
|
|
396
|
+
/** navigations that failed or timed out, summed over the windows */
|
|
397
|
+
navErrors: number;
|
|
398
|
+
};
|
|
399
|
+
/** the line of one delay's file counts: joules on requests, with intervals over rounds */
|
|
400
|
+
export type ChunkFit = {
|
|
401
|
+
rttMs: number;
|
|
402
|
+
/** rounds every file count of this delay measured: the bootstrap's sample */
|
|
403
|
+
rounds: number;
|
|
404
|
+
/** joules per navigation for each extra request */
|
|
405
|
+
slope: Estimate;
|
|
406
|
+
/** joules per navigation at zero requests */
|
|
407
|
+
intercept: Estimate;
|
|
408
|
+
/** ScriptDuration in ms per extra request */
|
|
409
|
+
scriptSlope: Estimate;
|
|
410
|
+
/** TaskDuration in ms per extra request */
|
|
411
|
+
taskSlope: Estimate;
|
|
412
|
+
/** extra requests that cost one joule (1 / slope); null when the slope's interval reaches zero */
|
|
413
|
+
requestsPerJoule: Estimate | null;
|
|
414
|
+
};
|
|
415
|
+
export type ChunkSplitFigures = {
|
|
416
|
+
/** windows over the contamination limit, dropped before any figure */
|
|
417
|
+
dropped: number;
|
|
418
|
+
idleWatts: Spread;
|
|
419
|
+
arms: ChunkArmFigures[];
|
|
420
|
+
/** one fit per delay that measured at least two rounds of every file count */
|
|
421
|
+
fits: ChunkFit[];
|
|
422
|
+
};
|
|
423
|
+
/**
|
|
424
|
+
* The device cost of splitting one page's scripts. A window's joules are its package energy less the
|
|
425
|
+
* idle draw of its round, over its navigations, as in `firstViewFigures`. Each file count's figure is
|
|
426
|
+
* the median over rounds. The fit is a least-squares line of joules on requests across the file
|
|
427
|
+
* counts of one delay; its intervals come from a bootstrap over rounds with a fixed seed. Byte
|
|
428
|
+
* penalties are against the one-file arm of the same delay.
|
|
429
|
+
*/
|
|
430
|
+
export declare function chunkSplitFigures(measurement: Measurement): ChunkSplitFigures;
|
|
431
|
+
/** the repeat-view figures of a `first-view-warm` reading, against the cold views of `first-view` */
|
|
432
|
+
export type WarmFigures = {
|
|
433
|
+
rounds: number;
|
|
434
|
+
/** pages measured in both readings */
|
|
435
|
+
pages: number;
|
|
436
|
+
/** windows over the contamination limit in the repeat reading, dropped before any figure */
|
|
437
|
+
dropped: number;
|
|
438
|
+
/** metered joules per repeat view, per page's median over rounds, above idle */
|
|
439
|
+
joules: {
|
|
440
|
+
mean: number;
|
|
441
|
+
median: number;
|
|
442
|
+
};
|
|
443
|
+
/** metered joules per cold first view of the same pages, from the cold reading */
|
|
444
|
+
coldJoules: {
|
|
445
|
+
mean: number;
|
|
446
|
+
median: number;
|
|
447
|
+
};
|
|
448
|
+
/** per page, repeat over cold; mean and median over the pages */
|
|
449
|
+
ratio: {
|
|
450
|
+
mean: number;
|
|
451
|
+
median: number;
|
|
452
|
+
};
|
|
453
|
+
/** median over pages of each term's share of TaskDuration, pooled over a page's navigations */
|
|
454
|
+
taskShare: {
|
|
455
|
+
script: number;
|
|
456
|
+
layout: number;
|
|
457
|
+
recalc: number;
|
|
458
|
+
};
|
|
459
|
+
/** pages whose repeat navigation fetched more than half the bytes its cold view fetched */
|
|
460
|
+
refetch: {
|
|
461
|
+
pages: number;
|
|
462
|
+
share: number;
|
|
463
|
+
};
|
|
464
|
+
};
|
|
465
|
+
/**
|
|
466
|
+
* The repeat-view figures of a `first-view-warm` reading. A window's joules are its package energy
|
|
467
|
+
* less the idle draw of its round, over its navigations, as in `firstViewFigures`; the cold figure
|
|
468
|
+
* of each page is taken the same way from the cold reading. A page counts when both readings measured
|
|
469
|
+
* it. The term shares divide each page's summed script, layout and style time by its summed task
|
|
470
|
+
* time; the three terms are reported on their own because they may overlap.
|
|
471
|
+
*/
|
|
472
|
+
export declare function warmFigures(warm: Measurement, cold: Measurement): WarmFigures;
|
|
473
|
+
/** a coefficient with its 95% bootstrap interval, the 2.5th and 97.5th percentiles of the resamples */
|
|
474
|
+
export type Estimate = {
|
|
475
|
+
value: number;
|
|
476
|
+
low: number;
|
|
477
|
+
high: number;
|
|
478
|
+
};
|
|
479
|
+
/** a least-squares fit over pages with each coefficient's interval; null when it is not estimable */
|
|
480
|
+
export type FitFigures = {
|
|
481
|
+
pages: number;
|
|
482
|
+
/** resamples that fit; a resample with collinear columns has no unique fit and is dropped */
|
|
483
|
+
replicates: number;
|
|
484
|
+
residualSe: number;
|
|
485
|
+
r2: number;
|
|
486
|
+
coef: Record<string, Estimate>;
|
|
487
|
+
};
|
|
488
|
+
export type FirstViewFit = {
|
|
489
|
+
pages: number;
|
|
490
|
+
/** median over pages of the metered joules per first view, above idle */
|
|
491
|
+
joulesMedian: number;
|
|
492
|
+
/** Pearson correlation of each page's joules with its total wire MB */
|
|
493
|
+
corrTotalMb: number;
|
|
494
|
+
/** intercept, image, script and other MB */
|
|
495
|
+
classFit: FitFigures | null;
|
|
496
|
+
/** intercept and total MB */
|
|
497
|
+
bytesFit: FitFigures | null;
|
|
498
|
+
/** intercept, total MB and requests */
|
|
499
|
+
requestFit: FitFigures | null;
|
|
500
|
+
/** intercept, image, script, other MB and requests */
|
|
501
|
+
classRequestFit: FitFigures | null;
|
|
502
|
+
};
|
|
503
|
+
/**
|
|
504
|
+
* The class, bytes and request fits of a `first-view` reading, each with bootstrap intervals over
|
|
505
|
+
* pages. `without` lists hosts whose pages are left out, for a sensitivity check. The request fits
|
|
506
|
+
* need a request count on every page and are null otherwise.
|
|
507
|
+
*/
|
|
508
|
+
export declare function firstViewFit(measurement: Measurement, without?: readonly string[]): FirstViewFit;
|