@valerypopoff/rivet2-core 2.0.10 → 2.0.11

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.
@@ -3703,6 +3703,7 @@ var GraphProcessor = class _GraphProcessor {
3703
3703
  #runtimeCache;
3704
3704
  #cacheLoadedProjects;
3705
3705
  #scheduler;
3706
+ #runtimeProfiler;
3706
3707
  #captureNodeTimings;
3707
3708
  #useSeededExecutionPlanOnNextRun = false;
3708
3709
  id = (0, import_non_secure4.nanoid)();
@@ -3770,6 +3771,34 @@ var GraphProcessor = class _GraphProcessor {
3770
3771
  }
3771
3772
  return Math.max(0, getMonotonicTimeMs() - start);
3772
3773
  }
3774
+ #startRuntimeProfile() {
3775
+ return this.#runtimeProfiler ? getMonotonicTimeMs() : void 0;
3776
+ }
3777
+ #finishRuntimeProfile(bucket, start) {
3778
+ if (start == null || !this.#runtimeProfiler) {
3779
+ return;
3780
+ }
3781
+ try {
3782
+ this.#runtimeProfiler.addDuration(bucket, Math.max(0, getMonotonicTimeMs() - start));
3783
+ } catch {
3784
+ }
3785
+ }
3786
+ #profileRuntimeSync(bucket, run) {
3787
+ const start = this.#startRuntimeProfile();
3788
+ try {
3789
+ return run();
3790
+ } finally {
3791
+ this.#finishRuntimeProfile(bucket, start);
3792
+ }
3793
+ }
3794
+ async #profileRuntimeAsync(bucket, run) {
3795
+ const start = this.#startRuntimeProfile();
3796
+ try {
3797
+ return await run();
3798
+ } finally {
3799
+ this.#finishRuntimeProfile(bucket, start);
3800
+ }
3801
+ }
3773
3802
  constructor(project, graphId, registry, includeTrace, options2) {
3774
3803
  this.#project = project;
3775
3804
  const graph = resolveProcessorGraph(project, graphId);
@@ -3787,6 +3816,7 @@ var GraphProcessor = class _GraphProcessor {
3787
3816
  this.#runtimeCache = options2 == null ? void 0 : options2.runtimeCache;
3788
3817
  this.#cacheLoadedProjects = (options2 == null ? void 0 : options2.cacheLoadedProjects) ?? false;
3789
3818
  this.#scheduler = (options2 == null ? void 0 : options2.scheduler) ?? "compatible";
3819
+ this.#runtimeProfiler = options2 == null ? void 0 : options2.runtimeProfiler;
3790
3820
  this.#captureNodeTimings = (options2 == null ? void 0 : options2.captureNodeTimings) ?? false;
3791
3821
  this.#emitter.bindMethods(this, ["on", "off", "once", "onAny", "offAny"]);
3792
3822
  this.setExternalFunction("echo", async (value) => ({ type: "any", value }));
@@ -3800,29 +3830,34 @@ var GraphProcessor = class _GraphProcessor {
3800
3830
  }
3801
3831
  #preprocessGraph() {
3802
3832
  var _a;
3803
- const runtimeCache = this.#canUseRuntimeExecutionPlanCache() ? this.#runtimeCache : void 0;
3804
- const shouldUseRuntimeCache = runtimeCache != null;
3805
- const cachedPlan = (_a = runtimeCache == null ? void 0 : runtimeCache.executionPlans) == null ? void 0 : _a.get(this.#graph);
3806
- if (cachedPlan) {
3807
- this.#applyPreprocessedGraph(cachedPlan, { recreateNodeInstances: true });
3808
- return;
3809
- }
3810
- const preprocessedGraph = preprocessGraphState({
3811
- graph: this.#graph,
3812
- loadedProjects: this.#loadedProjects,
3813
- project: this.#project,
3814
- registry: this.#registry,
3815
- warnOnInvalidGraph: this.warnOnInvalidGraph,
3816
- buildExecutionPlan: shouldUseRuntimeCache,
3817
- definitionContext: this.#runtimeCache ? {
3818
- getGraphBoundary: (project, graphId) => this.#getGraphBoundary(project, graphId)
3819
- } : void 0
3820
- });
3821
- if (shouldUseRuntimeCache && isGraphExecutionPlan(preprocessedGraph)) {
3822
- runtimeCache.executionPlans ??= /* @__PURE__ */ new WeakMap();
3823
- runtimeCache.executionPlans.set(this.#graph, toReusableGraphExecutionPlan(preprocessedGraph));
3833
+ const profileStart = this.#startRuntimeProfile();
3834
+ try {
3835
+ const runtimeCache = this.#canUseRuntimeExecutionPlanCache() ? this.#runtimeCache : void 0;
3836
+ const shouldUseRuntimeCache = runtimeCache != null;
3837
+ const cachedPlan = (_a = runtimeCache == null ? void 0 : runtimeCache.executionPlans) == null ? void 0 : _a.get(this.#graph);
3838
+ if (cachedPlan) {
3839
+ this.#applyPreprocessedGraph(cachedPlan, { recreateNodeInstances: true });
3840
+ return;
3841
+ }
3842
+ const preprocessedGraph = preprocessGraphState({
3843
+ graph: this.#graph,
3844
+ loadedProjects: this.#loadedProjects,
3845
+ project: this.#project,
3846
+ registry: this.#registry,
3847
+ warnOnInvalidGraph: this.warnOnInvalidGraph,
3848
+ buildExecutionPlan: shouldUseRuntimeCache,
3849
+ definitionContext: this.#runtimeCache ? {
3850
+ getGraphBoundary: (project, graphId) => this.#getGraphBoundary(project, graphId)
3851
+ } : void 0
3852
+ });
3853
+ if (shouldUseRuntimeCache && isGraphExecutionPlan(preprocessedGraph)) {
3854
+ runtimeCache.executionPlans ??= /* @__PURE__ */ new WeakMap();
3855
+ runtimeCache.executionPlans.set(this.#graph, toReusableGraphExecutionPlan(preprocessedGraph));
3856
+ }
3857
+ this.#applyPreprocessedGraph(preprocessedGraph);
3858
+ } finally {
3859
+ this.#finishRuntimeProfile("preprocessGraph", profileStart);
3824
3860
  }
3825
- this.#applyPreprocessedGraph(preprocessedGraph);
3826
3861
  }
3827
3862
  #canUseRuntimeExecutionPlanCache() {
3828
3863
  return this.#canUseRuntimeExecutionPlanCacheFor(this.#project, this.#isSubProcessor);
@@ -4119,30 +4154,28 @@ var GraphProcessor = class _GraphProcessor {
4119
4154
  throw new Error("Cannot process graph while already processing");
4120
4155
  }
4121
4156
  try {
4122
- this.#initializeGraphRun(context, inputs, contextValues);
4123
- await this.#loadProjectReferences();
4124
- this.#prepareNodeProcessContextBase();
4157
+ this.#profileRuntimeSync("initializeGraphRun", () => this.#initializeGraphRun(context, inputs, contextValues));
4158
+ await this.#profileRuntimeAsync("loadProjectReferences", () => this.#loadProjectReferences());
4159
+ this.#profileRuntimeSync("prepareNodeProcessContextBase", () => this.#prepareNodeProcessContextBase());
4125
4160
  const shouldUseSeededExecutionPlan = this.#seededExecutionPlanForNextRun() != null;
4126
4161
  this.#useSeededExecutionPlanOnNextRun = false;
4127
4162
  if (!shouldUseSeededExecutionPlan) {
4128
4163
  this.#preprocessGraph();
4129
4164
  }
4130
- await this.#emitGraphStart();
4131
- await this.#emitPreloadedNodeResults();
4132
- await this.#waitUntilUnpaused();
4165
+ await this.#profileRuntimeAsync("emitGraphStart", () => this.#emitGraphStart());
4166
+ await this.#profileRuntimeAsync("emitPreloadedNodeResults", () => this.#emitPreloadedNodeResults());
4167
+ await this.#profileRuntimeAsync("waitUntilUnpaused", () => this.#waitUntilUnpaused());
4133
4168
  if (this.#canUseFastAcyclicScheduler()) {
4134
- await this.#processFastAcyclicGraph();
4169
+ await this.#profileRuntimeAsync("processFastAcyclicGraph", () => this.#processFastAcyclicGraph());
4135
4170
  } else {
4136
- await this.#queueStartNodes(getStartNodes(this.#executionState, this.#graph.nodes, this.runToNodeIds));
4137
- await this.#processingQueue.onIdle();
4138
- this.#markUnqueuedNodesIgnored();
4171
+ await this.#profileRuntimeAsync("processCompatibleGraph", () => this.#processCompatibleGraph());
4139
4172
  }
4140
- await this.#throwIfGraphErrored();
4141
- return await this.#finalizeGraphRun();
4173
+ await this.#profileRuntimeAsync("throwIfGraphErrored", () => this.#throwIfGraphErrored());
4174
+ return await this.#profileRuntimeAsync("finalizeGraphRun", () => this.#finalizeGraphRun());
4142
4175
  } finally {
4143
4176
  this.#running = false;
4144
4177
  this.#cleanupTokenizerErrorListener();
4145
- await this.#emitFinishIfNeeded();
4178
+ await this.#profileRuntimeAsync("emitFinish", () => this.#emitFinishIfNeeded());
4146
4179
  }
4147
4180
  }
4148
4181
  async #emitFinishIfNeeded() {
@@ -4256,6 +4289,11 @@ var GraphProcessor = class _GraphProcessor {
4256
4289
  });
4257
4290
  }
4258
4291
  }
4292
+ async #processCompatibleGraph() {
4293
+ await this.#queueStartNodes(getStartNodes(this.#executionState, this.#graph.nodes, this.runToNodeIds));
4294
+ await this.#processingQueue.onIdle();
4295
+ this.#markUnqueuedNodesIgnored();
4296
+ }
4259
4297
  #canUseFastAcyclicScheduler() {
4260
4298
  if (this.#scheduler !== "fast-acyclic") {
4261
4299
  return false;
@@ -4277,14 +4315,29 @@ var GraphProcessor = class _GraphProcessor {
4277
4315
  });
4278
4316
  }
4279
4317
  async #processFastAcyclicGraph() {
4318
+ const relevantNodeIds = /* @__PURE__ */ new Set();
4319
+ const nodesToVisit = [...getStartNodes(this.#executionState, this.#graph.nodes)];
4320
+ for (let index = 0; index < nodesToVisit.length; index += 1) {
4321
+ const node = nodesToVisit[index];
4322
+ if (relevantNodeIds.has(node.id)) {
4323
+ continue;
4324
+ }
4325
+ relevantNodeIds.add(node.id);
4326
+ nodesToVisit.push(...getInputNodesTo(this.#executionState, node));
4327
+ }
4328
+ const inputNodeIdsByNode = /* @__PURE__ */ new Map();
4280
4329
  const remainingInputsByNode = /* @__PURE__ */ new Map();
4281
4330
  const readyNodes = [];
4282
4331
  const queuedNodeIds = /* @__PURE__ */ new Set();
4283
4332
  for (const node of this.#graph.nodes) {
4333
+ if (!relevantNodeIds.has(node.id)) {
4334
+ continue;
4335
+ }
4284
4336
  const inputNodeIds = /* @__PURE__ */ new Set();
4285
4337
  for (const inputNode of getInputNodesTo(this.#executionState, node)) {
4286
4338
  inputNodeIds.add(inputNode.id);
4287
4339
  }
4340
+ inputNodeIdsByNode.set(node.id, inputNodeIds);
4288
4341
  const inputCount = inputNodeIds.size;
4289
4342
  remainingInputsByNode.set(node.id, inputCount);
4290
4343
  if (inputCount === 0) {
@@ -4295,8 +4348,12 @@ var GraphProcessor = class _GraphProcessor {
4295
4348
  await new Promise((resolve, reject) => {
4296
4349
  let activeCount = 0;
4297
4350
  let settled = false;
4298
- const queueReadyOutputs = (outputNodes) => {
4351
+ const queueReadyOutputs = (node, outputNodes) => {
4352
+ var _a;
4299
4353
  for (const outputNode of outputNodes) {
4354
+ if (!relevantNodeIds.has(outputNode.id) || !((_a = inputNodeIdsByNode.get(outputNode.id)) == null ? void 0 : _a.has(node.id))) {
4355
+ continue;
4356
+ }
4300
4357
  const remainingInputs = (remainingInputsByNode.get(outputNode.id) ?? 0) - 1;
4301
4358
  remainingInputsByNode.set(outputNode.id, remainingInputs);
4302
4359
  if (remainingInputs <= 0 && !queuedNodeIds.has(outputNode.id)) {
@@ -4321,7 +4378,7 @@ var GraphProcessor = class _GraphProcessor {
4321
4378
  while (activeCount < this.#concurrency.nodeConcurrency && readyNodes.length > 0) {
4322
4379
  const node = readyNodes.shift();
4323
4380
  activeCount += 1;
4324
- void this.#processNodeIfAllInputsAvailable(node, { queueOutputNodes: false }).then(queueReadyOutputs).then(() => {
4381
+ void this.#processNodeIfAllInputsAvailable(node, { queueOutputNodes: false }).then((outputNodes) => queueReadyOutputs(node, outputNodes)).then(() => {
4325
4382
  activeCount -= 1;
4326
4383
  pump();
4327
4384
  settle();
@@ -4450,48 +4507,57 @@ ${erroredNodes.map(([nodeId]) => `- ${this.#nodesById[nodeId].title} (${nodeId})
4450
4507
  }
4451
4508
  async #fetchNodeDataAndProcessNode(node) {
4452
4509
  var _a;
4453
- if (this.#currentlyProcessing.has(node.id) || this.#queuedNodes.has(node.id)) {
4454
- return;
4455
- }
4456
- if (this.#nodeResults.has(node.id) || this.#erroredNodes.has(node.id)) {
4457
- return;
4458
- }
4459
- const inputNodes = getInputNodesTo(this.#executionState, node);
4460
- if (this.#hasErroredInputNode(node, inputNodes)) {
4461
- return;
4462
- }
4463
- this.#emitTraceEvent(`Node ${node.title} has input nodes: ${inputNodes.map((n) => n.title).join(", ")}`);
4464
- const attachedData = this.#getAttachedDataTo(node);
4465
- if (node.type === "raceInputs" || attachedData.races) {
4466
- for (const inputNode of inputNodes) {
4467
- const inputNodeAttachedData = this.#getAttachedDataTo(inputNode);
4468
- const raceIds = /* @__PURE__ */ new Set([...((_a = attachedData.races) == null ? void 0 : _a.raceIds) ?? []]);
4469
- if (node.type === "raceInputs") {
4470
- raceIds.add(`race-${node.id}`);
4510
+ const profileStart = this.#startRuntimeProfile();
4511
+ try {
4512
+ if (this.#currentlyProcessing.has(node.id) || this.#queuedNodes.has(node.id)) {
4513
+ return;
4514
+ }
4515
+ if (this.#nodeResults.has(node.id) || this.#erroredNodes.has(node.id)) {
4516
+ return;
4517
+ }
4518
+ const inputNodesProfileStart = this.#startRuntimeProfile();
4519
+ const inputNodes = getInputNodesTo(this.#executionState, node);
4520
+ this.#finishRuntimeProfile("getInputNodesTo", inputNodesProfileStart);
4521
+ if (this.#hasErroredInputNode(node, inputNodes)) {
4522
+ return;
4523
+ }
4524
+ this.#emitTraceEvent(`Node ${node.title} has input nodes: ${inputNodes.map((n) => n.title).join(", ")}`);
4525
+ const attachedData = this.#getAttachedDataTo(node);
4526
+ if (node.type === "raceInputs" || attachedData.races) {
4527
+ for (const inputNode of inputNodes) {
4528
+ const inputNodeAttachedData = this.#getAttachedDataTo(inputNode);
4529
+ const raceIds = /* @__PURE__ */ new Set([...((_a = attachedData.races) == null ? void 0 : _a.raceIds) ?? []]);
4530
+ if (node.type === "raceInputs") {
4531
+ raceIds.add(`race-${node.id}`);
4532
+ }
4533
+ inputNodeAttachedData.races = {
4534
+ propagate: false,
4535
+ raceIds: [...raceIds],
4536
+ completed: false
4537
+ };
4471
4538
  }
4472
- inputNodeAttachedData.races = {
4473
- propagate: false,
4474
- raceIds: [...raceIds],
4475
- completed: false
4476
- };
4477
4539
  }
4540
+ this.#queuedNodes.add(node.id);
4541
+ void this.#processingQueue.addAll(
4542
+ inputNodes.map((inputNode) => {
4543
+ return async () => {
4544
+ this.#emitTraceEvent(`Fetching required data for node ${inputNode.title} (${inputNode.id})`);
4545
+ await this.#fetchNodeDataAndProcessNode(inputNode);
4546
+ };
4547
+ })
4548
+ );
4549
+ await this.#processNodeIfAllInputsAvailable(node);
4550
+ } finally {
4551
+ this.#finishRuntimeProfile("fetchNodeDataAndProcessNode", profileStart);
4478
4552
  }
4479
- this.#queuedNodes.add(node.id);
4480
- void this.#processingQueue.addAll(
4481
- inputNodes.map((inputNode) => {
4482
- return async () => {
4483
- this.#emitTraceEvent(`Fetching required data for node ${inputNode.title} (${inputNode.id})`);
4484
- await this.#fetchNodeDataAndProcessNode(inputNode);
4485
- };
4486
- })
4487
- );
4488
- await this.#processNodeIfAllInputsAvailable(node);
4489
4553
  }
4490
4554
  /** If all inputs are present, all conditions met, processes the node. */
4491
4555
  async #processNodeIfAllInputsAvailable(node, options2 = {}) {
4492
4556
  const { queueOutputNodes = true } = options2;
4493
4557
  const builtInNode = node;
4558
+ const inputNodesProfileStart = this.#startRuntimeProfile();
4494
4559
  const inputNodes = getInputNodesTo(this.#executionState, node);
4560
+ this.#finishRuntimeProfile("getInputNodesTo", inputNodesProfileStart);
4495
4561
  if (this.#shouldSkipNodeProcessing(node, inputNodes)) {
4496
4562
  return [];
4497
4563
  }
@@ -4499,7 +4565,9 @@ ${erroredNodes.map(([nodeId]) => `- ${this.#nodesById[nodeId].title} (${nodeId})
4499
4565
  if (this.#shouldSkipCompletedRaceNode(node, attachedData)) {
4500
4566
  return [];
4501
4567
  }
4568
+ const inputValuesProfileStart = this.#startRuntimeProfile();
4502
4569
  const inputValues = this.#getInputValuesForNode(node);
4570
+ this.#finishRuntimeProfile("getInputValuesForNode", inputValuesProfileStart);
4503
4571
  const loopExclusion = this.#excludedDueToControlFlow(
4504
4572
  node,
4505
4573
  inputValues,
@@ -4530,7 +4598,13 @@ ${erroredNodes.map(([nodeId]) => `- ${this.#nodesById[nodeId].title} (${nodeId})
4530
4598
  if (this.#beginNodeProcessing(node, attachedData) === false) {
4531
4599
  return [];
4532
4600
  }
4533
- const processResult = await this.#processNode(node);
4601
+ const processProfileStart = this.#startRuntimeProfile();
4602
+ let processResult;
4603
+ try {
4604
+ processResult = await this.#processNode(node);
4605
+ } finally {
4606
+ this.#finishRuntimeProfile("nodeDispatch", processProfileStart);
4607
+ }
4534
4608
  const { processId } = processResult;
4535
4609
  if (this.slowMode) {
4536
4610
  await new Promise((resolve) => setTimeout(resolve, 250));
@@ -4539,7 +4613,9 @@ ${erroredNodes.map(([nodeId]) => `- ${this.#nodesById[nodeId].title} (${nodeId})
4539
4613
  this.#visitedNodes.add(node.id);
4540
4614
  this.#currentlyProcessing.delete(node.id);
4541
4615
  this.#remainingNodes.delete(node.id);
4616
+ const outputNodesProfileStart = this.#startRuntimeProfile();
4542
4617
  const outputNodes = getOutputNodesFrom(this.#executionState, node);
4618
+ this.#finishRuntimeProfile("getOutputNodesFrom", outputNodesProfileStart);
4543
4619
  this.#handleLoopControllerPostProcess(node, attachedData);
4544
4620
  this.#handleCompletedRace(node);
4545
4621
  const childLoopInfoError = this.#assignChildLoopInfo(node, builtInNode, attachedData);
@@ -4549,7 +4625,9 @@ ${erroredNodes.map(([nodeId]) => `- ${this.#nodesById[nodeId].title} (${nodeId})
4549
4625
  }
4550
4626
  this.#propagateAttachedDataToOutputNodes(node, attachedData, outputNodes.connectionsToNodes);
4551
4627
  if (queueOutputNodes && processResult.shouldQueueOutputNodes) {
4628
+ const queueOutputsProfileStart = this.#startRuntimeProfile();
4552
4629
  this.#queueOutputNodes(node, outputNodes.nodes);
4630
+ this.#finishRuntimeProfile("queueOutputNodes", queueOutputsProfileStart);
4553
4631
  }
4554
4632
  return processResult.shouldQueueOutputNodes ? outputNodes.nodes : [];
4555
4633
  }
@@ -4750,7 +4828,9 @@ ${erroredNodes.map(([nodeId]) => `- ${this.#nodesById[nodeId].title} (${nodeId})
4750
4828
  });
4751
4829
  }
4752
4830
  async #processNormalNode(node, processId) {
4831
+ const inputValuesProfileStart = this.#startRuntimeProfile();
4753
4832
  const inputValues = this.#getInputValuesForNode(node);
4833
+ this.#finishRuntimeProfile("getInputValuesForNode", inputValuesProfileStart);
4754
4834
  if (this.#excludedDueToControlFlow(node, inputValues, processId)) {
4755
4835
  return;
4756
4836
  }
@@ -4911,6 +4991,7 @@ ${erroredNodes.map(([nodeId]) => `- ${this.#nodesById[nodeId].title} (${nodeId})
4911
4991
  if (this.#abortController.signal.aborted) {
4912
4992
  nodeAbortController.abort(getAbortSignalReason(this.#abortController.signal));
4913
4993
  }
4994
+ const createContextProfileStart = this.#startRuntimeProfile();
4914
4995
  const context = this.#createNodeProcessContext(
4915
4996
  node,
4916
4997
  inputValues,
@@ -4919,10 +5000,16 @@ ${erroredNodes.map(([nodeId]) => `- ${this.#nodesById[nodeId].title} (${nodeId})
4919
5000
  nodeAbortController,
4920
5001
  partialOutput
4921
5002
  );
5003
+ this.#finishRuntimeProfile("createNodeProcessContext", createContextProfileStart);
4922
5004
  let results;
4923
5005
  try {
4924
5006
  await this.#waitUntilUnpaused();
4925
- results = await instance.process(inputValues, context);
5007
+ const implementationProfileStart = this.#startRuntimeProfile();
5008
+ try {
5009
+ results = await instance.process(inputValues, context);
5010
+ } finally {
5011
+ this.#finishRuntimeProfile("nodeImplementation", implementationProfileStart);
5012
+ }
4926
5013
  } finally {
4927
5014
  this.#unregisterNodeAbortController(node.id, nodeAbortController);
4928
5015
  }
@@ -4996,15 +5083,22 @@ ${erroredNodes.map(([nodeId]) => `- ${this.#nodesById[nodeId].title} (${nodeId})
4996
5083
  const subprocessorProject = project ?? this.#project;
4997
5084
  const subprocessorGraph = resolveProcessorGraph(subprocessorProject, subGraphId);
4998
5085
  const initialExecutionPlan = subprocessorGraph && this.#canUseRuntimeExecutionPlanCacheFor(subprocessorProject, true) ? (_b = (_a = this.#runtimeCache) == null ? void 0 : _a.executionPlans) == null ? void 0 : _b.get(subprocessorGraph) : void 0;
4999
- const processor = new _GraphProcessor(subprocessorProject, subGraphId, this.#registry, this.#includeTrace, {
5000
- cacheLoadedProjects: this.#cacheLoadedProjects,
5001
- captureNodeTimings: this.#captureNodeTimings,
5002
- concurrency: this.#concurrency,
5003
- executionPlanCacheMode: this.#executionPlanCacheMode,
5004
- initialExecutionPlan,
5005
- runtimeCache: this.#runtimeCache,
5006
- scheduler: this.#scheduler
5007
- });
5086
+ const createProfileStart = this.#startRuntimeProfile();
5087
+ let processor;
5088
+ try {
5089
+ processor = new _GraphProcessor(subprocessorProject, subGraphId, this.#registry, this.#includeTrace, {
5090
+ cacheLoadedProjects: this.#cacheLoadedProjects,
5091
+ captureNodeTimings: this.#captureNodeTimings,
5092
+ concurrency: this.#concurrency,
5093
+ executionPlanCacheMode: this.#executionPlanCacheMode,
5094
+ initialExecutionPlan,
5095
+ runtimeCache: this.#runtimeCache,
5096
+ runtimeProfiler: this.#runtimeProfiler,
5097
+ scheduler: this.#scheduler
5098
+ });
5099
+ } finally {
5100
+ this.#finishRuntimeProfile("createSubProcessor", createProfileStart);
5101
+ }
5008
5102
  processor.executor = this.executor;
5009
5103
  processor.#isSubProcessor = true;
5010
5104
  processor.#executionCache = this.#executionCache;
@@ -5018,32 +5112,42 @@ ${erroredNodes.map(([nodeId]) => `- ${this.#nodesById[nodeId].title} (${nodeId})
5018
5112
  index,
5019
5113
  processId
5020
5114
  };
5021
- wireSubprocessorEvents(processor, this.#emitter, {
5022
- isPaused: () => this.#isPaused,
5023
- pause: () => {
5024
- void this.pause();
5025
- },
5026
- resume: () => {
5027
- void this.resume();
5028
- }
5029
- });
5115
+ const wireEventsProfileStart = this.#startRuntimeProfile();
5116
+ try {
5117
+ wireSubprocessorEvents(processor, this.#emitter, {
5118
+ isPaused: () => this.#isPaused,
5119
+ pause: () => {
5120
+ void this.pause();
5121
+ },
5122
+ resume: () => {
5123
+ void this.resume();
5124
+ }
5125
+ });
5126
+ } finally {
5127
+ this.#finishRuntimeProfile("wireSubProcessorEvents", wireEventsProfileStart);
5128
+ }
5030
5129
  this.#subprocessors.add(processor);
5031
- wireSubprocessorLifecycle(processor, {
5032
- signal,
5033
- parentAbortSignal: this.#abortController.signal,
5034
- onParentPause: (listener) => {
5035
- this.on("pause", listener);
5036
- return () => {
5037
- this.off("pause", listener);
5038
- };
5039
- },
5040
- onParentResume: (listener) => {
5041
- this.on("resume", listener);
5042
- return () => {
5043
- this.off("resume", listener);
5044
- };
5045
- }
5046
- });
5130
+ const wireLifecycleProfileStart = this.#startRuntimeProfile();
5131
+ try {
5132
+ wireSubprocessorLifecycle(processor, {
5133
+ signal,
5134
+ parentAbortSignal: this.#abortController.signal,
5135
+ onParentPause: (listener) => {
5136
+ this.on("pause", listener);
5137
+ return () => {
5138
+ this.off("pause", listener);
5139
+ };
5140
+ },
5141
+ onParentResume: (listener) => {
5142
+ this.on("resume", listener);
5143
+ return () => {
5144
+ this.off("resume", listener);
5145
+ };
5146
+ }
5147
+ });
5148
+ } finally {
5149
+ this.#finishRuntimeProfile("wireSubProcessorLifecycle", wireLifecycleProfileStart);
5150
+ }
5047
5151
  return processor;
5048
5152
  }
5049
5153
  async #requestUserInput(node, inputStrings, inputValues, renderingType, processId) {
@@ -30024,6 +30128,7 @@ function coreCreateProcessor(project, options2, internalOptions = {}) {
30024
30128
  concurrency: options2.concurrency,
30025
30129
  executionPlanCacheMode: internalOptions.executionPlanCacheMode,
30026
30130
  runtimeCache: internalOptions.runtimeCache,
30131
+ runtimeProfiler: internalOptions.runtimeProfiler,
30027
30132
  scheduler: internalOptions.scheduler
30028
30133
  }
30029
30134
  );