@milaboratories/pl-middle-layer 2.2.0 → 2.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/dist/middle_layer/block_status_fold.cjs +427 -0
- package/dist/middle_layer/block_status_fold.cjs.map +1 -0
- package/dist/middle_layer/block_status_fold.js +416 -0
- package/dist/middle_layer/block_status_fold.js.map +1 -0
- package/dist/middle_layer/block_status_tree.cjs +317 -0
- package/dist/middle_layer/block_status_tree.cjs.map +1 -0
- package/dist/middle_layer/block_status_tree.js +313 -0
- package/dist/middle_layer/block_status_tree.js.map +1 -0
- package/dist/middle_layer/block_status_tree_fold.cjs +96 -0
- package/dist/middle_layer/block_status_tree_fold.cjs.map +1 -0
- package/dist/middle_layer/block_status_tree_fold.js +95 -0
- package/dist/middle_layer/block_status_tree_fold.js.map +1 -0
- package/dist/middle_layer/build_stamp.cjs +1 -1
- package/dist/middle_layer/build_stamp.js +1 -1
- package/dist/middle_layer/project.cjs +93 -2
- package/dist/middle_layer/project.cjs.map +1 -1
- package/dist/middle_layer/project.d.ts +34 -1
- package/dist/middle_layer/project.d.ts.map +1 -1
- package/dist/middle_layer/project.js +94 -3
- package/dist/middle_layer/project.js.map +1 -1
- package/dist/model/project_model.cjs +27 -0
- package/dist/model/project_model.cjs.map +1 -1
- package/dist/model/project_model.js +25 -1
- package/dist/model/project_model.js.map +1 -1
- package/dist/mutator/project.cjs +2 -1
- package/dist/mutator/project.cjs.map +1 -1
- package/dist/mutator/project.d.ts.map +1 -1
- package/dist/mutator/project.js +3 -2
- package/dist/mutator/project.js.map +1 -1
- package/dist/mutator/template/render_block.cjs +24 -0
- package/dist/mutator/template/render_block.cjs.map +1 -1
- package/dist/mutator/template/render_block.js +23 -2
- package/dist/mutator/template/render_block.js.map +1 -1
- package/package.json +15 -15
- package/src/middle_layer/block_status_bench.test.ts +288 -0
- package/src/middle_layer/block_status_fold.test.ts +635 -0
- package/src/middle_layer/block_status_fold.ts +625 -0
- package/src/middle_layer/block_status_test_utils.ts +62 -0
- package/src/middle_layer/block_status_tree.test.ts +276 -0
- package/src/middle_layer/block_status_tree.ts +443 -0
- package/src/middle_layer/block_status_tree_fold.test.ts +198 -0
- package/src/middle_layer/block_status_tree_fold.ts +150 -0
- package/src/middle_layer/project.ts +144 -2
- package/src/middle_layer/project_pruning.test.ts +59 -0
- package/src/model/project_model.ts +30 -0
- package/src/mutator/project.ts +7 -1
- package/src/mutator/project_action_context.test.ts +13 -3
- package/src/mutator/template/render_block.ts +32 -2
|
@@ -33,6 +33,27 @@ function createBlockActionContext(tx, baggage) {
|
|
|
33
33
|
"run-id": (0, node_crypto.randomUUID)()
|
|
34
34
|
}));
|
|
35
35
|
}
|
|
36
|
+
/** The namespace the creator of a context reports under, as the backend reserves it. */
|
|
37
|
+
const ActionContextCreatorNamespace = "core";
|
|
38
|
+
/** The reason recorded when the user stops a run. */
|
|
39
|
+
const BlockRunCancelledReason = "cancelled";
|
|
40
|
+
/**
|
|
41
|
+
* Marks a block run's root action context as cancelled by the user.
|
|
42
|
+
*
|
|
43
|
+
* Stopping a block destroys its render, and a destroyed render reports nothing, so without this
|
|
44
|
+
* every node of a stopped run would read as live forever. The middle layer created the context, so
|
|
45
|
+
* it reports under the creator's namespace, with the context itself as the reporting resource and
|
|
46
|
+
* this machine's clock, the same key layout the backend's reporters use.
|
|
47
|
+
*/
|
|
48
|
+
function recordBlockRunCancelled(tx, context) {
|
|
49
|
+
const reporter = (0, _milaboratories_pl_client.isResourceId)(context) ? String((0, _milaboratories_pl_client.parseSignedResourceId)(context).globalId) : "0";
|
|
50
|
+
const ns = (BigInt(Date.now()) * 1000000n).toString();
|
|
51
|
+
tx.setKValue(context, `transition/${ActionContextCreatorNamespace}/${reporter}/${ns}`, JSON.stringify({
|
|
52
|
+
state: "Terminated",
|
|
53
|
+
detail: "",
|
|
54
|
+
reason: BlockRunCancelledReason
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
36
57
|
/**
|
|
37
58
|
* Creates the heavy block render, and with `baggage` its root action context in the same
|
|
38
59
|
* transaction. Returns `actionContext`: the render is garbage collected after its outputs resolve,
|
|
@@ -60,14 +81,17 @@ function createBContextFromUpstreams(tx, upstreamCtxs) {
|
|
|
60
81
|
tx.lock(ctx);
|
|
61
82
|
return ctx;
|
|
62
83
|
}
|
|
84
|
+
exports.ActionContextCreatorNamespace = ActionContextCreatorNamespace;
|
|
63
85
|
exports.ActionContextLinkCapability = ActionContextLinkCapability;
|
|
64
86
|
exports.ActionContextType = ActionContextType;
|
|
65
87
|
exports.BContext = BContext;
|
|
66
88
|
exports.BContextEnd = BContextEnd;
|
|
67
89
|
exports.BContextMultiParentPrefix = BContextMultiParentPrefix;
|
|
90
|
+
exports.BlockRunCancelledReason = BlockRunCancelledReason;
|
|
68
91
|
exports.HeavyBlockOutputNames = HeavyBlockOutputNames;
|
|
69
92
|
exports.createBContextEnd = createBContextEnd;
|
|
70
93
|
exports.createBContextFromUpstreams = createBContextFromUpstreams;
|
|
71
94
|
exports.createRenderHeavyBlock = createRenderHeavyBlock;
|
|
95
|
+
exports.recordBlockRunCancelled = recordBlockRunCancelled;
|
|
72
96
|
|
|
73
97
|
//# sourceMappingURL=render_block.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render_block.cjs","names":["randomUUID","createRenderTemplateWithResource","field","Pl"],"sources":["../../../src/mutator/template/render_block.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"render_block.cjs","names":["randomUUID","isResourceId","parseSignedResourceId","createRenderTemplateWithResource","field","Pl"],"sources":["../../../src/mutator/template/render_block.ts"],"sourcesContent":["import type {\n AnyRef,\n AnyResourceRef,\n PlTransaction,\n ResourceRef,\n ResourceType,\n} from \"@milaboratories/pl-client\";\nimport { field, isResourceId, parseSignedResourceId, Pl } from \"@milaboratories/pl-client\";\nimport { randomUUID } from \"node:crypto\";\nimport { createRenderTemplateWithResource } from \"./render_template\";\n\nexport const BContextEnd: ResourceType = { name: \"BContextEnd\", version: \"1\" };\nexport const BContext: ResourceType = { name: \"BContext\", version: \"1\" };\nexport const BContextId = \"id\";\nexport const BContextParent = \"parent\";\nexport const BContextMultiParentPrefix = \"parent/\";\n\n// TODO: add implementation for dual context heavy block.\n// export type BlockType =\n// | 'LightBlock'\n// | 'HeavyBlock'\n// | 'DualContextHeavyBlock';\n// moved to project model ==>>>\n\nexport type HeavyBlockInputs = {\n args: AnyRef;\n blockId: AnyRef;\n isProduction: AnyRef;\n context: AnyRef;\n};\n\nexport type HeavyBlockOutputs = {\n context: AnyRef;\n result: AnyRef;\n};\n\nexport const HeavyBlockOutputNames: (keyof HeavyBlockOutputs)[] = [\"context\", \"result\"];\n\n/** Baggage of the root action context of a block render. See the block action context spec. */\nexport type BlockActionContextBaggage = {\n /** Display name of the block. */\n name: string;\n /** JSON of the block pack spec. */\n blockPack: string;\n blockId: string;\n};\n\n/** Resource type of a block action context. See ActionContextV1Type in the backend. */\nexport const ActionContextType: ResourceType = { name: \"ActionContext\", version: \"1\" };\n\n/** The capability under which the backend accepts the \"actionContext\" link on a render. */\nexport const ActionContextLinkCapability = \"optionalFieldsInSchemas:v1\";\n\n/**\n * Creates the root action context of a block render: an ActionContext resource carrying the\n * baggage, with a new random `run-id`, since each render is one run of the block and the contexts\n * the templates create copy it. Undefined without baggage, or on a backend that cannot take the link.\n */\nfunction createBlockActionContext(\n tx: PlTransaction,\n baggage: BlockActionContextBaggage | undefined,\n): ResourceRef | undefined {\n if (baggage === undefined || !tx.hasCapability(ActionContextLinkCapability)) return undefined;\n return tx.createEphemeral(\n ActionContextType,\n JSON.stringify({\n name: baggage.name,\n \"block-pack\": baggage.blockPack,\n \"block-id\": baggage.blockId,\n \"run-id\": randomUUID(),\n }),\n );\n}\n\n/** The namespace the creator of a context reports under, as the backend reserves it. */\nexport const ActionContextCreatorNamespace = \"core\";\n\n/** The reason recorded when the user stops a run. */\nexport const BlockRunCancelledReason = \"cancelled\";\n\n/**\n * Marks a block run's root action context as cancelled by the user.\n *\n * Stopping a block destroys its render, and a destroyed render reports nothing, so without this\n * every node of a stopped run would read as live forever. The middle layer created the context, so\n * it reports under the creator's namespace, with the context itself as the reporting resource and\n * this machine's clock, the same key layout the backend's reporters use.\n */\nexport function recordBlockRunCancelled(tx: PlTransaction, context: AnyResourceRef): void {\n const reporter = isResourceId(context) ? String(parseSignedResourceId(context).globalId) : \"0\";\n const ns = (BigInt(Date.now()) * 1_000_000n).toString();\n tx.setKValue(\n context,\n `transition/${ActionContextCreatorNamespace}/${reporter}/${ns}`,\n JSON.stringify({ state: \"Terminated\", detail: \"\", reason: BlockRunCancelledReason }),\n );\n}\n\n/**\n * Creates the heavy block render, and with `baggage` its root action context in the same\n * transaction. Returns `actionContext`: the render is garbage collected after its outputs resolve,\n * so the caller must hold the context to keep it.\n */\nexport function createRenderHeavyBlock(\n tx: PlTransaction,\n tpl: AnyRef,\n inputs: HeavyBlockInputs,\n baggage?: BlockActionContextBaggage,\n): HeavyBlockOutputs & { actionContext?: ResourceRef } {\n const actionContext = createBlockActionContext(tx, baggage);\n const { outputs } = createRenderTemplateWithResource(\n tx,\n tpl,\n true,\n inputs,\n HeavyBlockOutputNames,\n actionContext,\n );\n return actionContext === undefined ? outputs : { ...outputs, actionContext };\n}\n\nexport type LightBlockInputs = {\n args: AnyRef;\n blockId: AnyRef;\n stagingContext: AnyRef;\n productionContext: AnyRef;\n};\n\nexport type LightBlockOutput = {\n result: AnyRef;\n};\n\nexport const LightBlockOutputNames: (keyof LightBlockOutput)[] = [\"result\"];\n\n/**\n * Creates the light block render, with the same action context as a heavy one, so template code\n * of either kind knows its block and run.\n */\nexport function createRenderLightBlock(\n tx: PlTransaction,\n tpl: ResourceRef,\n inputs: LightBlockInputs,\n baggage?: BlockActionContextBaggage,\n): LightBlockOutput & { actionContext?: ResourceRef } {\n const actionContext = createBlockActionContext(tx, baggage);\n const { outputs } = createRenderTemplateWithResource(\n tx,\n tpl,\n true,\n inputs,\n LightBlockOutputNames,\n actionContext,\n );\n return actionContext === undefined ? outputs : { ...outputs, actionContext };\n}\n\nexport function createBContextEnd(tx: PlTransaction): ResourceRef {\n const ctx = tx.createEphemeral(BContextEnd);\n tx.lock(ctx);\n return ctx;\n}\n\nexport function createBContextFromUpstreams(tx: PlTransaction, upstreamCtxs: AnyRef[]): AnyRef {\n if (upstreamCtxs.length === 0) return createBContextEnd(tx);\n\n if (upstreamCtxs.length === 1) return upstreamCtxs[0];\n\n const ctx = tx.createEphemeral(BContext);\n\n // setting id\n tx.createField(field(ctx, BContextId), \"Input\", Pl.createPlString(tx, randomUUID()));\n\n // setting parents\n for (let i = 0; i < upstreamCtxs.length; i++)\n tx.createField(field(ctx, `${BContextMultiParentPrefix}${i}`), \"Input\", upstreamCtxs[i]);\n\n tx.lock(ctx);\n\n return ctx;\n}\n"],"mappings":";;;;AAWA,MAAa,cAA4B;CAAE,MAAM;CAAe,SAAS;AAAI;AAC7E,MAAa,WAAyB;CAAE,MAAM;CAAY,SAAS;AAAI;AAGvE,MAAa,4BAA4B;AAqBzC,MAAa,wBAAqD,CAAC,WAAW,QAAQ;;AAYtF,MAAa,oBAAkC;CAAE,MAAM;CAAiB,SAAS;AAAI;;AAGrF,MAAa,8BAA8B;;;;;;AAO3C,SAAS,yBACP,IACA,SACyB;CACzB,IAAI,YAAY,KAAA,KAAa,CAAC,GAAG,cAAA,4BAAyC,GAAG,OAAO,KAAA;CACpF,OAAO,GAAG,gBACR,mBACA,KAAK,UAAU;EACb,MAAM,QAAQ;EACd,cAAc,QAAQ;EACtB,YAAY,QAAQ;EACpB,WAAA,GAAUA,YAAAA,WAAAA,CAAW;CACvB,CAAC,CACH;AACF;;AAGA,MAAa,gCAAgC;;AAG7C,MAAa,0BAA0B;;;;;;;;;AAUvC,SAAgB,wBAAwB,IAAmB,SAA+B;CACxF,MAAM,YAAA,GAAWC,0BAAAA,aAAAA,CAAa,OAAO,IAAI,QAAA,GAAOC,0BAAAA,sBAAAA,CAAsB,OAAO,CAAC,CAAC,QAAQ,IAAI;CAC3F,MAAM,MAAM,OAAO,KAAK,IAAI,CAAC,IAAI,SAAA,CAAY,SAAS;CACtD,GAAG,UACD,SACA,cAAc,8BAA8B,GAAG,SAAS,GAAG,MAC3D,KAAK,UAAU;EAAE,OAAO;EAAc,QAAQ;EAAI,QAAQ;CAAwB,CAAC,CACrF;AACF;;;;;;AAOA,SAAgB,uBACd,IACA,KACA,QACA,SACqD;CACrD,MAAM,gBAAgB,yBAAyB,IAAI,OAAO;CAC1D,MAAM,EAAE,YAAYC,wBAAAA,iCAClB,IACA,KACA,MACA,QACA,uBACA,aACF;CACA,OAAO,kBAAkB,KAAA,IAAY,UAAU;EAAE,GAAG;EAAS;CAAc;AAC7E;AAqCA,SAAgB,kBAAkB,IAAgC;CAChE,MAAM,MAAM,GAAG,gBAAgB,WAAW;CAC1C,GAAG,KAAK,GAAG;CACX,OAAO;AACT;AAEA,SAAgB,4BAA4B,IAAmB,cAAgC;CAC7F,IAAI,aAAa,WAAW,GAAG,OAAO,kBAAkB,EAAE;CAE1D,IAAI,aAAa,WAAW,GAAG,OAAO,aAAa;CAEnD,MAAM,MAAM,GAAG,gBAAgB,QAAQ;CAGvC,GAAG,aAAA,GAAYC,0BAAAA,MAAAA,CAAM,KAAA,IAAe,GAAG,SAASC,0BAAAA,GAAG,eAAe,KAAA,GAAIL,YAAAA,WAAAA,CAAW,CAAC,CAAC;CAGnF,KAAK,IAAI,IAAI,GAAG,IAAI,aAAa,QAAQ,KACvC,GAAG,aAAA,GAAYI,0BAAAA,MAAAA,CAAM,KAAK,GAAG,4BAA4B,GAAG,GAAG,SAAS,aAAa,EAAE;CAEzF,GAAG,KAAK,GAAG;CAEX,OAAO;AACT"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRenderTemplateWithResource } from "./render_template.js";
|
|
2
|
-
import { Pl, field } from "@milaboratories/pl-client";
|
|
2
|
+
import { Pl, field, isResourceId, parseSignedResourceId } from "@milaboratories/pl-client";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
4
|
// src/mutator/template/render_block.ts
|
|
5
5
|
const BContextEnd = {
|
|
@@ -33,6 +33,27 @@ function createBlockActionContext(tx, baggage) {
|
|
|
33
33
|
"run-id": randomUUID()
|
|
34
34
|
}));
|
|
35
35
|
}
|
|
36
|
+
/** The namespace the creator of a context reports under, as the backend reserves it. */
|
|
37
|
+
const ActionContextCreatorNamespace = "core";
|
|
38
|
+
/** The reason recorded when the user stops a run. */
|
|
39
|
+
const BlockRunCancelledReason = "cancelled";
|
|
40
|
+
/**
|
|
41
|
+
* Marks a block run's root action context as cancelled by the user.
|
|
42
|
+
*
|
|
43
|
+
* Stopping a block destroys its render, and a destroyed render reports nothing, so without this
|
|
44
|
+
* every node of a stopped run would read as live forever. The middle layer created the context, so
|
|
45
|
+
* it reports under the creator's namespace, with the context itself as the reporting resource and
|
|
46
|
+
* this machine's clock, the same key layout the backend's reporters use.
|
|
47
|
+
*/
|
|
48
|
+
function recordBlockRunCancelled(tx, context) {
|
|
49
|
+
const reporter = isResourceId(context) ? String(parseSignedResourceId(context).globalId) : "0";
|
|
50
|
+
const ns = (BigInt(Date.now()) * 1000000n).toString();
|
|
51
|
+
tx.setKValue(context, `transition/${ActionContextCreatorNamespace}/${reporter}/${ns}`, JSON.stringify({
|
|
52
|
+
state: "Terminated",
|
|
53
|
+
detail: "",
|
|
54
|
+
reason: BlockRunCancelledReason
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
36
57
|
/**
|
|
37
58
|
* Creates the heavy block render, and with `baggage` its root action context in the same
|
|
38
59
|
* transaction. Returns `actionContext`: the render is garbage collected after its outputs resolve,
|
|
@@ -60,6 +81,6 @@ function createBContextFromUpstreams(tx, upstreamCtxs) {
|
|
|
60
81
|
tx.lock(ctx);
|
|
61
82
|
return ctx;
|
|
62
83
|
}
|
|
63
|
-
export { ActionContextLinkCapability, ActionContextType, BContext, BContextEnd, BContextMultiParentPrefix, HeavyBlockOutputNames, createBContextEnd, createBContextFromUpstreams, createRenderHeavyBlock };
|
|
84
|
+
export { ActionContextCreatorNamespace, ActionContextLinkCapability, ActionContextType, BContext, BContextEnd, BContextMultiParentPrefix, BlockRunCancelledReason, HeavyBlockOutputNames, createBContextEnd, createBContextFromUpstreams, createRenderHeavyBlock, recordBlockRunCancelled };
|
|
64
85
|
|
|
65
86
|
//# sourceMappingURL=render_block.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render_block.js","names":[],"sources":["../../../src/mutator/template/render_block.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"render_block.js","names":[],"sources":["../../../src/mutator/template/render_block.ts"],"sourcesContent":["import type {\n AnyRef,\n AnyResourceRef,\n PlTransaction,\n ResourceRef,\n ResourceType,\n} from \"@milaboratories/pl-client\";\nimport { field, isResourceId, parseSignedResourceId, Pl } from \"@milaboratories/pl-client\";\nimport { randomUUID } from \"node:crypto\";\nimport { createRenderTemplateWithResource } from \"./render_template\";\n\nexport const BContextEnd: ResourceType = { name: \"BContextEnd\", version: \"1\" };\nexport const BContext: ResourceType = { name: \"BContext\", version: \"1\" };\nexport const BContextId = \"id\";\nexport const BContextParent = \"parent\";\nexport const BContextMultiParentPrefix = \"parent/\";\n\n// TODO: add implementation for dual context heavy block.\n// export type BlockType =\n// | 'LightBlock'\n// | 'HeavyBlock'\n// | 'DualContextHeavyBlock';\n// moved to project model ==>>>\n\nexport type HeavyBlockInputs = {\n args: AnyRef;\n blockId: AnyRef;\n isProduction: AnyRef;\n context: AnyRef;\n};\n\nexport type HeavyBlockOutputs = {\n context: AnyRef;\n result: AnyRef;\n};\n\nexport const HeavyBlockOutputNames: (keyof HeavyBlockOutputs)[] = [\"context\", \"result\"];\n\n/** Baggage of the root action context of a block render. See the block action context spec. */\nexport type BlockActionContextBaggage = {\n /** Display name of the block. */\n name: string;\n /** JSON of the block pack spec. */\n blockPack: string;\n blockId: string;\n};\n\n/** Resource type of a block action context. See ActionContextV1Type in the backend. */\nexport const ActionContextType: ResourceType = { name: \"ActionContext\", version: \"1\" };\n\n/** The capability under which the backend accepts the \"actionContext\" link on a render. */\nexport const ActionContextLinkCapability = \"optionalFieldsInSchemas:v1\";\n\n/**\n * Creates the root action context of a block render: an ActionContext resource carrying the\n * baggage, with a new random `run-id`, since each render is one run of the block and the contexts\n * the templates create copy it. Undefined without baggage, or on a backend that cannot take the link.\n */\nfunction createBlockActionContext(\n tx: PlTransaction,\n baggage: BlockActionContextBaggage | undefined,\n): ResourceRef | undefined {\n if (baggage === undefined || !tx.hasCapability(ActionContextLinkCapability)) return undefined;\n return tx.createEphemeral(\n ActionContextType,\n JSON.stringify({\n name: baggage.name,\n \"block-pack\": baggage.blockPack,\n \"block-id\": baggage.blockId,\n \"run-id\": randomUUID(),\n }),\n );\n}\n\n/** The namespace the creator of a context reports under, as the backend reserves it. */\nexport const ActionContextCreatorNamespace = \"core\";\n\n/** The reason recorded when the user stops a run. */\nexport const BlockRunCancelledReason = \"cancelled\";\n\n/**\n * Marks a block run's root action context as cancelled by the user.\n *\n * Stopping a block destroys its render, and a destroyed render reports nothing, so without this\n * every node of a stopped run would read as live forever. The middle layer created the context, so\n * it reports under the creator's namespace, with the context itself as the reporting resource and\n * this machine's clock, the same key layout the backend's reporters use.\n */\nexport function recordBlockRunCancelled(tx: PlTransaction, context: AnyResourceRef): void {\n const reporter = isResourceId(context) ? String(parseSignedResourceId(context).globalId) : \"0\";\n const ns = (BigInt(Date.now()) * 1_000_000n).toString();\n tx.setKValue(\n context,\n `transition/${ActionContextCreatorNamespace}/${reporter}/${ns}`,\n JSON.stringify({ state: \"Terminated\", detail: \"\", reason: BlockRunCancelledReason }),\n );\n}\n\n/**\n * Creates the heavy block render, and with `baggage` its root action context in the same\n * transaction. Returns `actionContext`: the render is garbage collected after its outputs resolve,\n * so the caller must hold the context to keep it.\n */\nexport function createRenderHeavyBlock(\n tx: PlTransaction,\n tpl: AnyRef,\n inputs: HeavyBlockInputs,\n baggage?: BlockActionContextBaggage,\n): HeavyBlockOutputs & { actionContext?: ResourceRef } {\n const actionContext = createBlockActionContext(tx, baggage);\n const { outputs } = createRenderTemplateWithResource(\n tx,\n tpl,\n true,\n inputs,\n HeavyBlockOutputNames,\n actionContext,\n );\n return actionContext === undefined ? outputs : { ...outputs, actionContext };\n}\n\nexport type LightBlockInputs = {\n args: AnyRef;\n blockId: AnyRef;\n stagingContext: AnyRef;\n productionContext: AnyRef;\n};\n\nexport type LightBlockOutput = {\n result: AnyRef;\n};\n\nexport const LightBlockOutputNames: (keyof LightBlockOutput)[] = [\"result\"];\n\n/**\n * Creates the light block render, with the same action context as a heavy one, so template code\n * of either kind knows its block and run.\n */\nexport function createRenderLightBlock(\n tx: PlTransaction,\n tpl: ResourceRef,\n inputs: LightBlockInputs,\n baggage?: BlockActionContextBaggage,\n): LightBlockOutput & { actionContext?: ResourceRef } {\n const actionContext = createBlockActionContext(tx, baggage);\n const { outputs } = createRenderTemplateWithResource(\n tx,\n tpl,\n true,\n inputs,\n LightBlockOutputNames,\n actionContext,\n );\n return actionContext === undefined ? outputs : { ...outputs, actionContext };\n}\n\nexport function createBContextEnd(tx: PlTransaction): ResourceRef {\n const ctx = tx.createEphemeral(BContextEnd);\n tx.lock(ctx);\n return ctx;\n}\n\nexport function createBContextFromUpstreams(tx: PlTransaction, upstreamCtxs: AnyRef[]): AnyRef {\n if (upstreamCtxs.length === 0) return createBContextEnd(tx);\n\n if (upstreamCtxs.length === 1) return upstreamCtxs[0];\n\n const ctx = tx.createEphemeral(BContext);\n\n // setting id\n tx.createField(field(ctx, BContextId), \"Input\", Pl.createPlString(tx, randomUUID()));\n\n // setting parents\n for (let i = 0; i < upstreamCtxs.length; i++)\n tx.createField(field(ctx, `${BContextMultiParentPrefix}${i}`), \"Input\", upstreamCtxs[i]);\n\n tx.lock(ctx);\n\n return ctx;\n}\n"],"mappings":";;;;AAWA,MAAa,cAA4B;CAAE,MAAM;CAAe,SAAS;AAAI;AAC7E,MAAa,WAAyB;CAAE,MAAM;CAAY,SAAS;AAAI;AAGvE,MAAa,4BAA4B;AAqBzC,MAAa,wBAAqD,CAAC,WAAW,QAAQ;;AAYtF,MAAa,oBAAkC;CAAE,MAAM;CAAiB,SAAS;AAAI;;AAGrF,MAAa,8BAA8B;;;;;;AAO3C,SAAS,yBACP,IACA,SACyB;CACzB,IAAI,YAAY,KAAA,KAAa,CAAC,GAAG,cAAA,4BAAyC,GAAG,OAAO,KAAA;CACpF,OAAO,GAAG,gBACR,mBACA,KAAK,UAAU;EACb,MAAM,QAAQ;EACd,cAAc,QAAQ;EACtB,YAAY,QAAQ;EACpB,UAAU,WAAW;CACvB,CAAC,CACH;AACF;;AAGA,MAAa,gCAAgC;;AAG7C,MAAa,0BAA0B;;;;;;;;;AAUvC,SAAgB,wBAAwB,IAAmB,SAA+B;CACxF,MAAM,WAAW,aAAa,OAAO,IAAI,OAAO,sBAAsB,OAAO,CAAC,CAAC,QAAQ,IAAI;CAC3F,MAAM,MAAM,OAAO,KAAK,IAAI,CAAC,IAAI,SAAA,CAAY,SAAS;CACtD,GAAG,UACD,SACA,cAAc,8BAA8B,GAAG,SAAS,GAAG,MAC3D,KAAK,UAAU;EAAE,OAAO;EAAc,QAAQ;EAAI,QAAQ;CAAwB,CAAC,CACrF;AACF;;;;;;AAOA,SAAgB,uBACd,IACA,KACA,QACA,SACqD;CACrD,MAAM,gBAAgB,yBAAyB,IAAI,OAAO;CAC1D,MAAM,EAAE,YAAY,iCAClB,IACA,KACA,MACA,QACA,uBACA,aACF;CACA,OAAO,kBAAkB,KAAA,IAAY,UAAU;EAAE,GAAG;EAAS;CAAc;AAC7E;AAqCA,SAAgB,kBAAkB,IAAgC;CAChE,MAAM,MAAM,GAAG,gBAAgB,WAAW;CAC1C,GAAG,KAAK,GAAG;CACX,OAAO;AACT;AAEA,SAAgB,4BAA4B,IAAmB,cAAgC;CAC7F,IAAI,aAAa,WAAW,GAAG,OAAO,kBAAkB,EAAE;CAE1D,IAAI,aAAa,WAAW,GAAG,OAAO,aAAa;CAEnD,MAAM,MAAM,GAAG,gBAAgB,QAAQ;CAGvC,GAAG,YAAY,MAAM,KAAA,IAAe,GAAG,SAAS,GAAG,eAAe,IAAI,WAAW,CAAC,CAAC;CAGnF,KAAK,IAAI,IAAI,GAAG,IAAI,aAAa,QAAQ,KACvC,GAAG,YAAY,MAAM,KAAK,GAAG,4BAA4B,GAAG,GAAG,SAAS,aAAa,EAAE;CAEzF,GAAG,KAAK,GAAG;CAEX,OAAO;AACT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milaboratories/pl-middle-layer",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "Pl Middle Layer",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -19,26 +19,26 @@
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@milaboratories/columns-collection-driver": "0.2.
|
|
22
|
+
"@milaboratories/columns-collection-driver": "0.2.15",
|
|
23
23
|
"@milaboratories/computable": "2.9.10",
|
|
24
24
|
"@milaboratories/helpers": "1.14.7",
|
|
25
|
-
"@milaboratories/pf-driver": "1.9.
|
|
26
|
-
"@milaboratories/pf-spec-driver": "1.5.
|
|
25
|
+
"@milaboratories/pf-driver": "1.9.17",
|
|
26
|
+
"@milaboratories/pf-spec-driver": "1.5.17",
|
|
27
27
|
"@milaboratories/pframes-rs-node": "1.2.0",
|
|
28
|
-
"@milaboratories/pl-client": "3.22.
|
|
29
|
-
"@milaboratories/pl-crash-recorder": "0.3.
|
|
30
|
-
"@milaboratories/pl-drivers": "2.0.
|
|
31
|
-
"@milaboratories/pl-errors": "1.4.
|
|
28
|
+
"@milaboratories/pl-client": "3.22.1",
|
|
29
|
+
"@milaboratories/pl-crash-recorder": "0.3.11",
|
|
30
|
+
"@milaboratories/pl-drivers": "2.0.1",
|
|
31
|
+
"@milaboratories/pl-errors": "1.4.61",
|
|
32
32
|
"@milaboratories/pl-http": "1.2.6",
|
|
33
|
-
"@milaboratories/pl-model-backend": "1.4.
|
|
34
|
-
"@milaboratories/pl-model-common": "1.55.
|
|
35
|
-
"@milaboratories/pl-model-middle-layer": "1.
|
|
36
|
-
"@milaboratories/pl-tree": "1.
|
|
33
|
+
"@milaboratories/pl-model-backend": "1.4.46",
|
|
34
|
+
"@milaboratories/pl-model-common": "1.55.2",
|
|
35
|
+
"@milaboratories/pl-model-middle-layer": "1.39.0",
|
|
36
|
+
"@milaboratories/pl-tree": "1.18.0",
|
|
37
37
|
"@milaboratories/resolve-helper": "1.1.3",
|
|
38
38
|
"@milaboratories/ts-helpers": "1.9.1",
|
|
39
|
-
"@platforma-sdk/block-tools": "2.
|
|
40
|
-
"@platforma-sdk/model": "1.88.
|
|
41
|
-
"@platforma-sdk/workflow-tengo": "6.22.
|
|
39
|
+
"@platforma-sdk/block-tools": "2.19.1",
|
|
40
|
+
"@platforma-sdk/model": "1.88.15",
|
|
41
|
+
"@platforma-sdk/workflow-tengo": "6.22.2",
|
|
42
42
|
"canonicalize": "~2.1.0",
|
|
43
43
|
"denque": "^2.1.0",
|
|
44
44
|
"es-toolkit": "^1.39.10",
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How the block status fold scales with the size of a run, through the real read path: an in-memory
|
|
3
|
+
* pl-tree holding the action contexts, its accessors, and the computable over them. No backend.
|
|
4
|
+
*
|
|
5
|
+
* A run is a root with one branch per 1 000 jobs and the jobs under the branches. Each job carries
|
|
6
|
+
* the transitions a real one writes. Three changes are timed, each followed by a read:
|
|
7
|
+
*
|
|
8
|
+
* - a report: one new transition on one job, as a command reports its next state;
|
|
9
|
+
* - a new job: one more context under a branch, as a run fans out;
|
|
10
|
+
* - an expansion: the tree opens another branch (the tree reader only).
|
|
11
|
+
*
|
|
12
|
+
* The "full walk" reader folds the whole tree in one computable, as the fold did before it got one
|
|
13
|
+
* computable per context; it is the baseline.
|
|
14
|
+
*
|
|
15
|
+
* Off by default; run with
|
|
16
|
+
* `BLOCK_STATUS_BENCH=1 NODE_OPTIONS=--expose-gc npx vitest run src/middle_layer/block_status_bench`.
|
|
17
|
+
* With `--expose-gc` each run size starts after a collection, so the previous run's garbage does
|
|
18
|
+
* not land in its first read.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { Computable, WatchableValue } from "@milaboratories/computable";
|
|
22
|
+
import type { SignedResourceId } from "@milaboratories/pl-client";
|
|
23
|
+
import {
|
|
24
|
+
createSignedResourceId,
|
|
25
|
+
DefaultFinalResourceDataPredicate,
|
|
26
|
+
NullSignedResourceId,
|
|
27
|
+
} from "@milaboratories/pl-client";
|
|
28
|
+
import type { ExtendedResourceData, PlTreeEntry } from "@milaboratories/pl-tree";
|
|
29
|
+
import { PlTreeState } from "@milaboratories/pl-tree";
|
|
30
|
+
import { expect, test } from "vitest";
|
|
31
|
+
import { ActionContextType } from "../mutator/template/render_block";
|
|
32
|
+
import { foldSubtree, summarize } from "./block_status_fold";
|
|
33
|
+
import { actionContextNode, entrySummary, subtreeFold } from "./block_status_tree";
|
|
34
|
+
import { blockStatusTree } from "./block_status_tree_fold";
|
|
35
|
+
|
|
36
|
+
const JobsPerBranch = 1_000;
|
|
37
|
+
const Sizes = [1_000, 10_000, 100_000, 250_000];
|
|
38
|
+
/** Changes of each kind per run size; the table gives their median and slowest. */
|
|
39
|
+
const Changes = 20;
|
|
40
|
+
|
|
41
|
+
/** What a reader computes over the run, and how to open a context when it shows a tree. */
|
|
42
|
+
type Reader = { value: Computable<unknown>; expand?: (contextId: string) => void };
|
|
43
|
+
|
|
44
|
+
/** The whole tree folded in one computable: every change re-reads every context. */
|
|
45
|
+
function fullWalkOf(entry: PlTreeEntry): Reader {
|
|
46
|
+
return {
|
|
47
|
+
value: Computable.make((ctx) =>
|
|
48
|
+
summarize(foldSubtree(actionContextNode(ctx.accessor(entry).node()))),
|
|
49
|
+
),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** The summary as `watchBlockStatus` gives it: one computable per context. */
|
|
54
|
+
function summaryOf(entry: PlTreeEntry): Reader {
|
|
55
|
+
return { value: entrySummary(entry, true, (err) => console.error(err)) };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** The tree as `watchBlockStatusTree` gives it, with the root and the expanded contexts open. */
|
|
59
|
+
function treeOf(entry: PlTreeEntry): Reader {
|
|
60
|
+
const expanded = new WatchableValue<string[]>([]);
|
|
61
|
+
return {
|
|
62
|
+
value: Computable.make(
|
|
63
|
+
(ctx) => ({
|
|
64
|
+
expanded: expanded.getValue(ctx),
|
|
65
|
+
fold: subtreeFold(entry, new Set(), (e) => console.error(e)),
|
|
66
|
+
}),
|
|
67
|
+
{
|
|
68
|
+
postprocessValue: ({ expanded, fold }) => {
|
|
69
|
+
if (fold === undefined) throw new Error("the root did not fold");
|
|
70
|
+
return blockStatusTree(fold, summarize(fold), new Set(expanded));
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
),
|
|
74
|
+
expand: (contextId) => expanded.setValue([contextId], "bench expansion"),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const Readers = [
|
|
79
|
+
{ name: "full walk (before)", make: fullWalkOf },
|
|
80
|
+
{ name: "summary", make: summaryOf },
|
|
81
|
+
{ name: "tree", make: treeOf },
|
|
82
|
+
];
|
|
83
|
+
|
|
84
|
+
const t0 = 1_800_000_000_000_000_000n;
|
|
85
|
+
|
|
86
|
+
function transition(namespace: string, reporter: number, atNs: bigint, state: string) {
|
|
87
|
+
return {
|
|
88
|
+
key: `transition/${namespace}/${reporter}/${atNs}`,
|
|
89
|
+
value: Buffer.from(JSON.stringify({ state, detail: "", reason: "" })),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** A job somewhere in its life: done, running, queued or copying its input. */
|
|
94
|
+
function jobKv(id: number): ExtendedResourceData["kv"] {
|
|
95
|
+
const at = t0 + BigInt(id) * 1_000_000n;
|
|
96
|
+
const kv = [transition("render", id, at, "Running")];
|
|
97
|
+
switch (id % 10) {
|
|
98
|
+
case 0:
|
|
99
|
+
kv.push(transition("workdir", id + 1, at + 1n, "PopulatingWorkdir"));
|
|
100
|
+
kv.push({
|
|
101
|
+
key: `reading/workdir/${id + 1}/progress`,
|
|
102
|
+
value: Buffer.from('{"done":3,"total":8}'),
|
|
103
|
+
});
|
|
104
|
+
return kv;
|
|
105
|
+
case 1:
|
|
106
|
+
kv.push(transition("exec", id + 2, at + 2n, "WaitingSubmissionGate"));
|
|
107
|
+
return kv;
|
|
108
|
+
case 2:
|
|
109
|
+
case 3:
|
|
110
|
+
kv.push(transition("exec", id + 2, at + 2n, "Running"));
|
|
111
|
+
return kv;
|
|
112
|
+
default:
|
|
113
|
+
kv.push(transition("exec", id + 2, at + 2n, "Running"));
|
|
114
|
+
kv.push(transition("exec", id + 2, at + 3n, "Completed"));
|
|
115
|
+
kv.push(transition("render", id, at + 4n, "Completed"));
|
|
116
|
+
return kv;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function contextData(
|
|
121
|
+
rid: SignedResourceId,
|
|
122
|
+
name: string,
|
|
123
|
+
children: SignedResourceId[],
|
|
124
|
+
kv: ExtendedResourceData["kv"],
|
|
125
|
+
): ExtendedResourceData {
|
|
126
|
+
return {
|
|
127
|
+
id: rid,
|
|
128
|
+
originalResourceId: NullSignedResourceId,
|
|
129
|
+
canonicalId: new Uint8Array(0),
|
|
130
|
+
kind: "Structural",
|
|
131
|
+
type: ActionContextType,
|
|
132
|
+
data: Buffer.from(JSON.stringify({ name })),
|
|
133
|
+
error: NullSignedResourceId,
|
|
134
|
+
inputsLocked: false,
|
|
135
|
+
outputsLocked: false,
|
|
136
|
+
resourceReady: false,
|
|
137
|
+
final: false,
|
|
138
|
+
fields: children.map((child) => ({
|
|
139
|
+
name: `child/${String(child)}`,
|
|
140
|
+
type: "Dynamic",
|
|
141
|
+
value: child,
|
|
142
|
+
error: NullSignedResourceId,
|
|
143
|
+
status: "Resolved",
|
|
144
|
+
valueIsFinal: false,
|
|
145
|
+
})),
|
|
146
|
+
kv,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** A run of `size` contexts, and the jobs a report can land on. */
|
|
151
|
+
function buildRun(size: number) {
|
|
152
|
+
let next = 1;
|
|
153
|
+
/** The number behind each id, which the reporters' keys use. */
|
|
154
|
+
const numbers = new Map<SignedResourceId, number>();
|
|
155
|
+
const rid = () => {
|
|
156
|
+
const n = next++;
|
|
157
|
+
const id = createSignedResourceId(BigInt(n));
|
|
158
|
+
numbers.set(id, n);
|
|
159
|
+
return id;
|
|
160
|
+
};
|
|
161
|
+
const num = (id: SignedResourceId) => numbers.get(id)!;
|
|
162
|
+
const root = rid();
|
|
163
|
+
const resources = new Map<SignedResourceId, ExtendedResourceData>();
|
|
164
|
+
const jobs: SignedResourceId[] = [];
|
|
165
|
+
|
|
166
|
+
const branches: SignedResourceId[] = [];
|
|
167
|
+
const branchJobs = new Map<SignedResourceId, SignedResourceId[]>();
|
|
168
|
+
for (let made = 1; made < size;) {
|
|
169
|
+
const branch = rid();
|
|
170
|
+
branches.push(branch);
|
|
171
|
+
made++;
|
|
172
|
+
const children: SignedResourceId[] = [];
|
|
173
|
+
for (let j = 0; j < JobsPerBranch && made < size; j++, made++) {
|
|
174
|
+
const job = rid();
|
|
175
|
+
children.push(job);
|
|
176
|
+
jobs.push(job);
|
|
177
|
+
resources.set(job, contextData(job, `job ${j}`, [], jobKv(num(job))));
|
|
178
|
+
}
|
|
179
|
+
branchJobs.set(branch, children);
|
|
180
|
+
resources.set(
|
|
181
|
+
branch,
|
|
182
|
+
contextData(branch, `branch ${branches.length}`, children, [
|
|
183
|
+
transition("render", num(branch), t0, "Running"),
|
|
184
|
+
]),
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
resources.set(
|
|
188
|
+
root,
|
|
189
|
+
contextData(root, "root", branches, [transition("render", num(root), t0, "Running")]),
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
const tree = new PlTreeState(root, DefaultFinalResourceDataPredicate);
|
|
193
|
+
tree.updateFromResourceData([...resources.values()]);
|
|
194
|
+
|
|
195
|
+
/** One more job under the `i`-th branch, as a run fans out. */
|
|
196
|
+
const addJob = (i: number) => {
|
|
197
|
+
const branch = branches[i % branches.length];
|
|
198
|
+
const job = rid();
|
|
199
|
+
const jobData = contextData(job, `job ${num(job)}`, [], jobKv(num(job)));
|
|
200
|
+
const children = [...branchJobs.get(branch)!, job];
|
|
201
|
+
branchJobs.set(branch, children);
|
|
202
|
+
const grown = contextData(
|
|
203
|
+
branch,
|
|
204
|
+
`branch ${i % branches.length}`,
|
|
205
|
+
children,
|
|
206
|
+
resources.get(branch)!.kv,
|
|
207
|
+
);
|
|
208
|
+
resources.set(job, jobData);
|
|
209
|
+
resources.set(branch, grown);
|
|
210
|
+
tree.updateFromResourceData([jobData, grown]);
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
/** One more transition on a job, as a command reports its next state. */
|
|
214
|
+
const report = (i: number) => {
|
|
215
|
+
const job = jobs[(i * 7919) % jobs.length];
|
|
216
|
+
const data = resources.get(job)!;
|
|
217
|
+
const updated = {
|
|
218
|
+
...data,
|
|
219
|
+
kv: [
|
|
220
|
+
...data.kv,
|
|
221
|
+
transition("exec", num(job) + 2, t0 + 10_000_000_000n + BigInt(i), "Completed"),
|
|
222
|
+
],
|
|
223
|
+
};
|
|
224
|
+
resources.set(job, updated);
|
|
225
|
+
tree.updateFromResourceData([updated]);
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
return { tree, branches, report, addJob };
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
async function timed(fn: () => Promise<unknown>): Promise<number> {
|
|
232
|
+
const start = performance.now();
|
|
233
|
+
await fn();
|
|
234
|
+
return performance.now() - start;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/** Times `changes` changes, each followed by a read: "median / slowest" in ms. */
|
|
238
|
+
async function perChange(reader: Reader, change: (i: number) => void): Promise<string> {
|
|
239
|
+
const ms: number[] = [];
|
|
240
|
+
for (let i = 0; i < Changes; i++) {
|
|
241
|
+
change(i);
|
|
242
|
+
ms.push(await timed(() => reader.value.getValue()));
|
|
243
|
+
}
|
|
244
|
+
ms.sort((a, b) => a - b);
|
|
245
|
+
return `${fmt(ms[Math.floor(ms.length / 2)])} / ${fmt(ms[ms.length - 1])}`;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function fmt(ms: number): string {
|
|
249
|
+
if (ms >= 1000) return `${(ms / 1000).toFixed(1)} s`;
|
|
250
|
+
return ms < 10 ? ms.toFixed(2) : ms.toFixed(0);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
test.skipIf(process.env.BLOCK_STATUS_BENCH === undefined)(
|
|
254
|
+
"block status fold: first read and each kind of change, by run size",
|
|
255
|
+
{ timeout: 1_800_000 },
|
|
256
|
+
async () => {
|
|
257
|
+
const rows: string[] = [];
|
|
258
|
+
for (const { name, make } of Readers)
|
|
259
|
+
for (const size of Sizes) {
|
|
260
|
+
globalThis.gc?.();
|
|
261
|
+
const run = buildRun(size);
|
|
262
|
+
const reader = make(run.tree.entry());
|
|
263
|
+
|
|
264
|
+
const first = await timed(() => reader.value.getValue());
|
|
265
|
+
const report = await perChange(reader, run.report);
|
|
266
|
+
const newJob = await perChange(reader, run.addJob);
|
|
267
|
+
const { expand } = reader;
|
|
268
|
+
const expansion =
|
|
269
|
+
expand === undefined
|
|
270
|
+
? "n/a"
|
|
271
|
+
: await perChange(reader, (i) => expand(String(run.branches[i % run.branches.length])));
|
|
272
|
+
expect(await reader.value.getValue()).toBeDefined();
|
|
273
|
+
rows.push(
|
|
274
|
+
`| ${name} | ${size.toLocaleString("en")} | ${fmt(first)} | ${report} | ${newJob} | ${expansion} |`,
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
console.log(
|
|
279
|
+
[
|
|
280
|
+
`Times in ms, "median / slowest" of ${Changes} changes each.`,
|
|
281
|
+
"",
|
|
282
|
+
"| Reader | Contexts | First read | Report on a job | New job | Expand a branch |",
|
|
283
|
+
"|---|---:|---:|---:|---:|---:|",
|
|
284
|
+
...rows,
|
|
285
|
+
].join("\n"),
|
|
286
|
+
);
|
|
287
|
+
},
|
|
288
|
+
);
|