@loadmap/react 0.30.1 → 0.32.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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { compare, headroom, sourceText } from "@loadmap/core";
|
|
2
|
-
import { capital, compact, fmt, monthOf, multiple, multiples, pct, secs } from "@loadmap/core/format";
|
|
2
|
+
import { capital, compact, duration, fmt, monthOf, multiple, multiples, pct, secs } from "@loadmap/core/format";
|
|
3
3
|
import { anchor, directionOf, labelsAt, layout, legPath, localElk, pointAt, structureKey } from "@loadmap/layout";
|
|
4
4
|
import { Suspense, lazy, memo, useCallback, useEffect, useId, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
5
5
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -211,7 +211,7 @@ function stepDetail(a, b, components) {
|
|
|
211
211
|
}).filter(Boolean).join(" · ");
|
|
212
212
|
}
|
|
213
213
|
// src/Diagram.tsx
|
|
214
|
-
const Detail = lazy(() => import("./later-
|
|
214
|
+
const Detail = lazy(() => import("./later-Dxo79dBg.js").then((m) => ({ default: m.Detail })));
|
|
215
215
|
const STATE_STROKE = {
|
|
216
216
|
off: "var(--lm-line)",
|
|
217
217
|
ok: "var(--lm-ok)",
|
|
@@ -809,30 +809,40 @@ function RateStrokes({ lm, scene }) {
|
|
|
809
809
|
const max = Math.max(1e-9, ...Object.values(ev.flows));
|
|
810
810
|
const out = [];
|
|
811
811
|
for (const f of Object.keys(flows)) {
|
|
812
|
-
const
|
|
813
|
-
const
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
to
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
812
|
+
const legs = [];
|
|
813
|
+
for (const way of ev.paths[f] ?? []) {
|
|
814
|
+
const seq = [scene.flowFrom[f], ...way.stages.map((s) => scene.stageNode[s])].filter((n, i, a) => n && n !== a[i - 1]);
|
|
815
|
+
const rate = (ev.flows[f] ?? 0) * way.share;
|
|
816
|
+
for (const [i, to] of seq.slice(1).entries()) legs.push([
|
|
817
|
+
seq[i],
|
|
818
|
+
to,
|
|
819
|
+
rate
|
|
820
|
+
]);
|
|
821
|
+
const last = way.stages.at(-1);
|
|
822
|
+
const st = last ? ev.stages[last] : void 0;
|
|
823
|
+
if (st?.kind === "fanout") for (const b of st.to[f] ?? []) legs.push([
|
|
824
|
+
scene.stageNode[last],
|
|
825
|
+
scene.stageNode[b.stage],
|
|
826
|
+
rate * b.share
|
|
827
|
+
]);
|
|
828
|
+
}
|
|
829
|
+
const on = /* @__PURE__ */ new Map();
|
|
826
830
|
for (const [from, to, r] of legs) {
|
|
827
831
|
const e = scene.edges.find((x) => x.from === from && x.to === to);
|
|
828
|
-
if (e)
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
}, `${f}:${e.id}`));
|
|
832
|
+
if (!e) continue;
|
|
833
|
+
const had = on.get(e.id);
|
|
834
|
+
on.set(e.id, {
|
|
835
|
+
points: e.points,
|
|
836
|
+
r: (had?.r ?? 0) + r
|
|
837
|
+
});
|
|
835
838
|
}
|
|
839
|
+
for (const [id, { points, r }] of on) out.push(/* @__PURE__ */ jsx("path", {
|
|
840
|
+
d: pathOf(points),
|
|
841
|
+
fill: "none",
|
|
842
|
+
stroke: tokenColor(flows[f].color),
|
|
843
|
+
strokeOpacity: ".45",
|
|
844
|
+
strokeWidth: 1.5 + 6 * Math.min(r, max) / max
|
|
845
|
+
}, `${f}:${id}`));
|
|
836
846
|
}
|
|
837
847
|
return /* @__PURE__ */ jsx("g", { children: out });
|
|
838
848
|
}
|
|
@@ -854,6 +864,8 @@ function Node({ n, state, title, sub, lm, focused, selected, handlers }) {
|
|
|
854
864
|
const st = n.kind === "pool" ? lm.ev.stages[n.stages[0] ?? ""] : void 0;
|
|
855
865
|
const running = st?.kind === "workers" ? st.running : n.members.length;
|
|
856
866
|
const idle = (i) => i >= running && i < (st?.kind === "workers" ? st.pods : n.members.length);
|
|
867
|
+
const a = st?.kind === "workers" ? st.assignment : void 0;
|
|
868
|
+
const unassigned = (i) => a != null && i < a.weights.length && a.weights[i] === 0;
|
|
857
869
|
const e = 6;
|
|
858
870
|
const grow = n.fade == null ? void 0 : `translate(${n.x + n.w / 2} ${n.y + n.h / 2}) scale(${.92 + .08 * n.fade}) translate(${-n.x - n.w / 2} ${-n.y - n.h / 2})`;
|
|
859
871
|
return /* @__PURE__ */ jsxs("g", {
|
|
@@ -941,7 +953,9 @@ function Node({ n, state, title, sub, lm, focused, selected, handlers }) {
|
|
|
941
953
|
rx: "2",
|
|
942
954
|
fill: "var(--lm-surface)",
|
|
943
955
|
stroke: "currentColor",
|
|
944
|
-
strokeOpacity: ".45"
|
|
956
|
+
strokeOpacity: unassigned(s.index) ? ".3" : ".45",
|
|
957
|
+
strokeDasharray: unassigned(s.index) ? "2 2" : void 0,
|
|
958
|
+
"data-unassigned": unassigned(s.index) || void 0
|
|
945
959
|
}), /* @__PURE__ */ jsx("rect", {
|
|
946
960
|
"data-slot": s.index,
|
|
947
961
|
"data-stage": n.stages[0],
|
|
@@ -1879,18 +1893,25 @@ function Limits({ lm, title = "Where it runs out, in order" }) {
|
|
|
1879
1893
|
className: "lm-lim",
|
|
1880
1894
|
"data-component": c.id,
|
|
1881
1895
|
children: [
|
|
1882
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1896
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1897
|
+
/* @__PURE__ */ jsxs("b", { children: [
|
|
1898
|
+
c.name,
|
|
1899
|
+
c === ev.firstLimit && /* @__PURE__ */ jsx("span", {
|
|
1900
|
+
className: "lm-tag",
|
|
1901
|
+
"data-kind": "first",
|
|
1902
|
+
children: "limit"
|
|
1903
|
+
}),
|
|
1904
|
+
/* @__PURE__ */ jsx(CapTag, { c: c.capacity })
|
|
1905
|
+
] }),
|
|
1906
|
+
/* @__PURE__ */ jsx("span", {
|
|
1907
|
+
className: "lm-sub",
|
|
1908
|
+
children: c.missing != null ? `No published benchmark ${c.missing}.` : c.describe ?? (c.capacity ? `${fmt(c.capacity.value)} ${c.capacity.unit}` : "switched off")
|
|
1888
1909
|
}),
|
|
1889
|
-
/* @__PURE__ */ jsx(
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1910
|
+
c.spread && c.util != null && /* @__PURE__ */ jsx("span", {
|
|
1911
|
+
className: "lm-sub lm-spread",
|
|
1912
|
+
children: c.spread.text
|
|
1913
|
+
})
|
|
1914
|
+
] }),
|
|
1894
1915
|
/* @__PURE__ */ jsxs("div", {
|
|
1895
1916
|
className: "lm-track",
|
|
1896
1917
|
role: "img",
|
|
@@ -1935,7 +1956,7 @@ function Meters({ lm }) {
|
|
|
1935
1956
|
const flowLabel = (f) => model.def.flows[f]?.label ?? f;
|
|
1936
1957
|
const items = [];
|
|
1937
1958
|
for (const s of Object.values(ev.stages)) {
|
|
1938
|
-
if (s.kind === "queue") for (const f of model.flowIds.filter((x) => ev.
|
|
1959
|
+
if (s.kind === "queue") for (const f of model.flowIds.filter((x) => ev.paths[x]?.some((p) => p.stages.includes(s.id)))) {
|
|
1939
1960
|
const q = sim.queue(s.id, f);
|
|
1940
1961
|
const rules = ev.overload[f] ?? {};
|
|
1941
1962
|
items.push({
|
|
@@ -1978,7 +1999,7 @@ function Meters({ lm }) {
|
|
|
1978
1999
|
label: `answered at ${s.label} /s (${pct(s.hit)} hits)`,
|
|
1979
2000
|
state: "ok"
|
|
1980
2001
|
});
|
|
1981
|
-
if ((s.kind === "pass" || s.kind === "limit" || s.kind === "cache") && sim.shed(s.id) > 0) items.push({
|
|
2002
|
+
if ((s.kind === "pass" || s.kind === "limit" || s.kind === "cache" || s.kind === "split") && sim.shed(s.id) > 0) items.push({
|
|
1982
2003
|
key: `${s.id}/shed`,
|
|
1983
2004
|
value: pct(sim.shed(s.id)),
|
|
1984
2005
|
label: `rejected at ${s.label}`,
|
|
@@ -2002,6 +2023,24 @@ function Meters({ lm }) {
|
|
|
2002
2023
|
state: r.failed > .005 ? "over" : "ok"
|
|
2003
2024
|
});
|
|
2004
2025
|
}
|
|
2026
|
+
for (const f of model.flowIds) {
|
|
2027
|
+
const l = ev.latency[f];
|
|
2028
|
+
if (!l) continue;
|
|
2029
|
+
const scenario = model.scenarioOf(lm.values)?.label;
|
|
2030
|
+
const goal = model.expectations.find((e) => e.flow === f && e.p99 != null && (e.scenario == null || e.scenario === scenario) && (e.target == null || lm.values.load <= e.target))?.p99;
|
|
2031
|
+
items.push({
|
|
2032
|
+
key: `${f}/p99`,
|
|
2033
|
+
value: duration(l.p99),
|
|
2034
|
+
label: `${flowLabel(f)} p99`,
|
|
2035
|
+
state: !Number.isFinite(l.p99) || goal != null && l.p99 > goal ? "over" : "ok"
|
|
2036
|
+
});
|
|
2037
|
+
if (l.timedOut != null) items.push({
|
|
2038
|
+
key: `${f}/late`,
|
|
2039
|
+
value: pct(l.timedOut),
|
|
2040
|
+
label: `${flowLabel(f)} timed out`,
|
|
2041
|
+
state: l.timedOut > .005 ? "over" : l.timedOut > 0 ? "warn" : "ok"
|
|
2042
|
+
});
|
|
2043
|
+
}
|
|
2005
2044
|
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("h3", { children: "Live" }), /* @__PURE__ */ jsx("div", {
|
|
2006
2045
|
className: "lm-meters",
|
|
2007
2046
|
children: items.map((m) => /* @__PURE__ */ jsxs("div", {
|
|
@@ -2211,7 +2250,7 @@ function Assumptions({ lm, extra = [] }) {
|
|
|
2211
2250
|
className: "lm-card",
|
|
2212
2251
|
children: [/* @__PURE__ */ jsx("h3", { children: "What this assumes" }), /* @__PURE__ */ jsxs("ul", {
|
|
2213
2252
|
className: "lm-facts",
|
|
2214
|
-
children: [extra.map((x, i) => /* @__PURE__ */ jsx("li", { children: x }, i)), lm.ev.assumptions.map((a) => /* @__PURE__ */ jsx("li", { children: describe(a) }, a.kind === "capacity" ? `c:${a.component}` : `${a.kind
|
|
2253
|
+
children: [extra.map((x, i) => /* @__PURE__ */ jsx("li", { children: x }, i)), lm.ev.assumptions.map((a) => /* @__PURE__ */ jsx("li", { children: describe(a) }, a.kind === "capacity" ? `c:${a.component}` : `${a.kind}:${a.name}`))]
|
|
2215
2254
|
})]
|
|
2216
2255
|
});
|
|
2217
2256
|
}
|
|
@@ -2253,6 +2292,11 @@ function describe(a) {
|
|
|
2253
2292
|
unread(c.unread)
|
|
2254
2293
|
] });
|
|
2255
2294
|
}
|
|
2295
|
+
if (a.kind === "connection") return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2296
|
+
/* @__PURE__ */ jsxs("b", { children: [a.name, ":"] }),
|
|
2297
|
+
" ",
|
|
2298
|
+
a.text
|
|
2299
|
+
] });
|
|
2256
2300
|
if (a.kind === "measurement") {
|
|
2257
2301
|
const { label, unit, value, missing, source } = a.measurement;
|
|
2258
2302
|
const name = label ?? a.name;
|
|
@@ -3015,7 +3059,7 @@ var Engine = class {
|
|
|
3015
3059
|
return this.colors[c] || c;
|
|
3016
3060
|
}
|
|
3017
3061
|
outcomeColor(outcome) {
|
|
3018
|
-
if (outcome === "dropped" || outcome === "rejected") return this.colors.drop || "#b7392e";
|
|
3062
|
+
if (outcome === "dropped" || outcome === "rejected" || outcome === "timedout") return this.colors.drop || "#b7392e";
|
|
3019
3063
|
if (outcome === "superseded" || outcome === "unread") return this.colors.muted || "#5d6d7c";
|
|
3020
3064
|
return this.colors.ok || "#2a7f5a";
|
|
3021
3065
|
}
|
|
@@ -3725,8 +3769,8 @@ function canvasMeasure(fontFamily) {
|
|
|
3725
3769
|
};
|
|
3726
3770
|
}
|
|
3727
3771
|
// src/Loadmap.tsx
|
|
3728
|
-
const Dock = lazy(() => import("./later-
|
|
3729
|
-
const VerdictLine = lazy(() => import("./later-
|
|
3772
|
+
const Dock = lazy(() => import("./later-Dxo79dBg.js").then((m) => ({ default: m.Dock })));
|
|
3773
|
+
const VerdictLine = lazy(() => import("./later-Dxo79dBg.js").then((m) => ({ default: m.VerdictLine })));
|
|
3730
3774
|
/** What the page's own switch says, on `<html>`: `data-theme`, or a `dark` or `light` class; null when it says nothing. */
|
|
3731
3775
|
function pageTheme() {
|
|
3732
3776
|
if (typeof document === "undefined") return null;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as useComparison, D as workerElk, O as Diagram, S as scenarioColor, _ as Verdict, a as usePageTheme, b as HeadroomChart, c as injectStyles, f as Controls, g as Meters, h as LoadRange, i as handleOf, l as Story, m as LoadBar, n as Loadmap, o as useLoadmap, p as Limits, r as LoadmapRoot, s as LOADMAP_CSS, t as LOADMAP_PANELS, u as Assumptions, x as Scenarios, y as Compare } from "./Loadmap-
|
|
1
|
+
import { C as useComparison, D as workerElk, O as Diagram, S as scenarioColor, _ as Verdict, a as usePageTheme, b as HeadroomChart, c as injectStyles, f as Controls, g as Meters, h as LoadRange, i as handleOf, l as Story, m as LoadBar, n as Loadmap, o as useLoadmap, p as Limits, r as LoadmapRoot, s as LOADMAP_CSS, t as LOADMAP_PANELS, u as Assumptions, x as Scenarios, y as Compare } from "./Loadmap-CoaUFl5d.js";
|
|
2
2
|
import { fitLinear } from "@loadmap/core/calibrate";
|
|
3
3
|
import { compact, fmt, multiple, pct, secs } from "@loadmap/core/format";
|
|
4
4
|
import { MEASURES, fromSnapshot, originText, parseSnapshot, summarize } from "@loadmap/core/measure";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as rankLabels, C as useComparison, E as whenRange, S as scenarioColor, T as useSize, d as CapTag, f as Controls, g as Meters, k as boxComponent, v as plusMinus, w as useHeadroom, y as Compare } from "./Loadmap-
|
|
1
|
+
import { A as rankLabels, C as useComparison, E as whenRange, S as scenarioColor, T as useSize, d as CapTag, f as Controls, g as Meters, k as boxComponent, v as plusMinus, w as useHeadroom, y as Compare } from "./Loadmap-CoaUFl5d.js";
|
|
2
2
|
import { reach } from "@loadmap/core";
|
|
3
3
|
import { compact, fmt, multiple, multiples, pct } from "@loadmap/core/format";
|
|
4
4
|
import { useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
@@ -418,6 +418,7 @@ function Detail({ lm, scene, id, board, detailId }) {
|
|
|
418
418
|
cap.unit,
|
|
419
419
|
cap.within ? ` ${plusMinus(cap)}` : ""
|
|
420
420
|
] }),
|
|
421
|
+
c.held && heldText(model, c.held) && /* @__PURE__ */ jsx("span", { children: heldText(model, c.held) }),
|
|
421
422
|
/* @__PURE__ */ jsxs("span", {
|
|
422
423
|
className: "lm-sub",
|
|
423
424
|
children: [
|
|
@@ -480,6 +481,15 @@ function Detail({ lm, scene, id, board, detailId }) {
|
|
|
480
481
|
]
|
|
481
482
|
});
|
|
482
483
|
}
|
|
484
|
+
/** How long a unit of each flow holds a slot: "held 20 ms per order". */
|
|
485
|
+
function heldText(model, held) {
|
|
486
|
+
const time = (s) => s < 1 ? `${fmt(s * 1e3)} ms` : s < 120 ? `${fmt(s)} s` : s < 7200 ? `${fmt(s / 60)} min` : `${fmt(s / 3600)} h`;
|
|
487
|
+
const per = Object.entries(held).filter(([, s]) => s > 0).map(([f, s]) => {
|
|
488
|
+
const flow = model.def.flows[f];
|
|
489
|
+
return `${time(s)} per ${flow?.unit ?? `unit of ${flow?.label ?? f}`}`;
|
|
490
|
+
});
|
|
491
|
+
return per.length ? `held ${per.join(", ")}` : "";
|
|
492
|
+
}
|
|
483
493
|
/** What a box's building blocks do at these values: pods running, cache answers, what a stage turns away. */
|
|
484
494
|
function blocks(lm, n) {
|
|
485
495
|
const out = [];
|
|
@@ -487,7 +497,7 @@ function blocks(lm, n) {
|
|
|
487
497
|
const s = lm.ev.stages[id];
|
|
488
498
|
if (s?.kind === "workers" && s.autoscale) out.push(`${s.running} of ${s.pods} pods running, each held near ${pct(s.autoscale.target)}`);
|
|
489
499
|
if (s?.kind === "cache") out.push(`${pct(s.hit)} answered here`);
|
|
490
|
-
if ((s?.kind === "pass" || s?.kind === "limit" || s?.kind === "cache") && s.shed > 0) out.push(`${pct(s.shed)} of what reaches it turned away`);
|
|
500
|
+
if ((s?.kind === "pass" || s?.kind === "limit" || s?.kind === "cache" || s?.kind === "split") && s.shed > 0) out.push(`${pct(s.shed)} of what reaches it turned away`);
|
|
491
501
|
}
|
|
492
502
|
return out;
|
|
493
503
|
}
|
package/dist/source.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as usePageTheme, c as injectStyles, n as Loadmap } from "./Loadmap-
|
|
1
|
+
import { a as usePageTheme, c as injectStyles, n as Loadmap } from "./Loadmap-CoaUFl5d.js";
|
|
2
2
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
import { compile, formatDiagnostic, loadCatalogFor, loadedCatalog, needsCatalog, sharedValues } from "@loadmap/dsl";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loadmap/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.32.0",
|
|
4
4
|
"description": "Interactive capacity models for React: an architecture diagram with moving dots, the limits ranked, the verdict, scenarios and headroom.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"loadmap",
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
"dist"
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@loadmap/core": "0.
|
|
43
|
-
"@loadmap/dsl": "0.
|
|
44
|
-
"@loadmap/sim": "0.
|
|
45
|
-
"@loadmap/layout": "0.
|
|
42
|
+
"@loadmap/core": "0.32.0",
|
|
43
|
+
"@loadmap/dsl": "0.32.0",
|
|
44
|
+
"@loadmap/sim": "0.32.0",
|
|
45
|
+
"@loadmap/layout": "0.32.0",
|
|
46
46
|
"elkjs": "^0.12.1"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|