Repository navigation
fix(core): run data stages tapped after the pipeline is built - #967
KetanReddy merged 4 commits into
Conversation
DataController builds its data pipeline the first time anything reads or writes data, and resolveDataStages was only called at that moment. A plugin that tapped resolveDataStages after another plugin had already read data from its own dataController tap was silently left out of the pipeline. Rebuild the pipeline whenever a stage is tapped after it was built. The data itself lives in the base LocalModel, and the PipelinedDataModel instance and its hooks are kept, so nothing written earlier is lost.
…solve-data-stages
Benchmark ResultsComparison against baseline from
|
| Benchmark | Current | Baseline | Change |
|---|---|---|---|
core/player/src/binding/__tests__/parser.bench.ts > parser benchmarks > Resolving binding: foo.bar |
813.81K ops/s | 925.06K ops/s | -12.0% |
core/player/src/binding/__tests__/parser.bench.ts > parser benchmarks > Resolving binding: foo.pets.1.name |
534.34K ops/s | 521.10K ops/s | +2.5% |
core/player/src/binding/__tests__/parser.bench.ts > parser benchmarks > Resolving binding: foo.pets.01.name |
535.53K ops/s | 503.37K ops/s | +6.4% ✅ |
core/player/src/binding/__tests__/parser.bench.ts > parser benchmarks > Resolving binding: foo.pets['01'].name |
441.13K ops/s | 501.47K ops/s | -12.0% |
core/player/src/binding/__tests__/parser.bench.ts > parser benchmarks > Resolving binding: foo.pets[01].name |
482.55K ops/s | 492.83K ops/s | -2.1% |
core/player/src/binding/__tests__/parser.bench.ts > parser benchmarks > Resolving binding: foo.pets[name = "frodo"].type |
288.23K ops/s | 279.80K ops/s | +3.0% |
core/player/src/binding/__tests__/parser.bench.ts > parser benchmarks > Resolving binding: foo.pets["name" = "sprinkles"].type |
209.51K ops/s | 235.69K ops/s | -11.1% |
core/player/src/binding/__tests__/parser.bench.ts > parser benchmarks > Resolving binding: foo.pets["isDog" = false].type |
283.08K ops/s | 308.07K ops/s | -8.1% |
core/player/src/binding/__tests__/parser.bench.ts > parser benchmarks > Resolving binding: foo.pets["isDog" = true].type |
311.01K ops/s | 318.65K ops/s | -2.4% |
core/player/src/binding/__tests__/parser.bench.ts > binding creation benchmarks > Resolving binding: foo.bar |
602.01K ops/s | 605.13K ops/s | -0.5% |
core/player/src/binding/__tests__/parser.bench.ts > binding creation benchmarks > Resolving binding: foo.pets.1.name |
399.54K ops/s | 389.77K ops/s | +2.5% |
core/player/src/binding/__tests__/parser.bench.ts > binding creation benchmarks > Resolving binding: foo.pets.01.name |
390.99K ops/s | 392.62K ops/s | -0.4% |
core/player/src/binding/__tests__/parser.bench.ts > binding creation benchmarks > Resolving binding: foo.pets['01'].name |
340.09K ops/s | 358.56K ops/s | -5.2% |
core/player/src/binding/__tests__/parser.bench.ts > binding creation benchmarks > Resolving binding: foo.pets[01].name |
392.68K ops/s | 393.40K ops/s | -0.2% |
core/player/src/binding/__tests__/parser.bench.ts > binding creation benchmarks > Resolving binding: foo.pets[name = "frodo"].type |
244.43K ops/s | 250.49K ops/s | -2.4% |
core/player/src/binding/__tests__/parser.bench.ts > binding creation benchmarks > Resolving binding: foo.pets["name" = "sprinkles"].type |
196.04K ops/s | 200.40K ops/s | -2.2% |
core/player/src/binding/__tests__/parser.bench.ts > binding creation benchmarks > Resolving binding: foo.pets["isDog" = false].type |
243.83K ops/s | 243.54K ops/s | +0.1% |
core/player/src/binding/__tests__/parser.bench.ts > binding creation benchmarks > Resolving binding: foo.pets["isDog" = true].type |
249.41K ops/s | 256.20K ops/s | -2.6% |
core/player/src/expressions/__tests__/performance.bench.ts > Expression Parsing/Execution Benchmark > Parsing: {{foo}} = 1 + 3 (sync) |
412.53K ops/s | 490.09K ops/s | -15.8% |
core/player/src/expressions/__tests__/performance.bench.ts > Expression Parsing/Execution Benchmark > Parsing: {{foo}} = 1 + 3 (async) |
287.57K ops/s | 398.74K ops/s | -27.9% |
core/player/src/expressions/__tests__/performance.bench.ts > Expression Parsing/Execution Benchmark > Parsing: conditional(true, true, false) (sync) |
376.65K ops/s | 501.45K ops/s | -24.9% |
core/player/src/expressions/__tests__/performance.bench.ts > Expression Parsing/Execution Benchmark > Parsing: conditional(true, true, false) (async) |
326.11K ops/s | 441.52K ops/s | -26.1% |
core/player/src/expressions/__tests__/performance.bench.ts > Expression Parsing/Execution Benchmark > Parsing: {{foo}} = conditional({{bar}} > 0, true, false) (sync) |
158.03K ops/s | 221.46K ops/s | -28.6% |
core/player/src/expressions/__tests__/performance.bench.ts > Expression Parsing/Execution Benchmark > Parsing: {{foo}} = conditional({{bar}} > 0, true, false) (async) |
148.86K ops/s | 206.12K ops/s | -27.8% |
core/player/src/expressions/__tests__/performance.bench.ts > Expression Parsing/Execution Benchmark > Parsing: {{foo}} = conditional(conditional(true = false, false, true), conditional(false = false, true, false), conditional(true = true, false, true)) (sync) |
128.67K ops/s | 153.99K ops/s | -16.4% |
core/player/src/expressions/__tests__/performance.bench.ts > Expression Parsing/Execution Benchmark > Parsing: {{foo}} = conditional(conditional(true = false, false, true), conditional(false = false, true, false), conditional(true = true, false, true)) (async) |
119.16K ops/s | 158.90K ops/s | -25.0% |
core/player/src/expressions/__tests__/performance.bench.ts > Expression Parsing/Execution Benchmark > Parsing: {{foo}} = await(asyncTestFunction(1)) (sync) |
N/A | N/A | N/A |
core/player/src/expressions/__tests__/performance.bench.ts > Expression Parsing/Execution Benchmark > Parsing: {{foo}} = await(asyncTestFunction(1)) (async) |
216.78K ops/s | 298.85K ops/s | -27.5% |
core/player/src/expressions/__tests__/performance.bench.ts > Expression Parsing/Execution Benchmark > Parsing: {{foo}} = asyncTestFunction(1) (sync) |
330.71K ops/s | 344.27K ops/s | -3.9% |
core/player/src/expressions/__tests__/performance.bench.ts > Expression Parsing/Execution Benchmark > Parsing: {{foo}} = asyncTestFunction(1) (async) |
285.07K ops/s | 314.43K ops/s | -9.3% |
core/player/src/expressions/__tests__/performance.bench.ts > Expression Parsing/Execution Benchmark > Parsing: asyncTestFunction(1) (sync) |
832.90K ops/s | 942.19K ops/s | -11.6% |
core/player/src/expressions/__tests__/performance.bench.ts > Expression Parsing/Execution Benchmark > Parsing: asyncTestFunction(1) (async) |
662.96K ops/s | 742.09K ops/s | -10.7% |
core/player/src/expressions/__tests__/performance.bench.ts > Expression Parsing/Execution Benchmark > Parsing: {{foo}} = conditional(!{{bar}} == false, await(asyncTestFunction(1)), false) (sync) |
182.10K ops/s | 193.03K ops/s | -5.7% |
core/player/src/expressions/__tests__/performance.bench.ts > Expression Parsing/Execution Benchmark > Parsing: {{foo}} = conditional(!{{bar}} == false, await(asyncTestFunction(1)), false) (async) |
169.78K ops/s | 177.43K ops/s | -4.3% |
core/player/src/view/resolver/__tests__/index.bench.ts > resolver benchmarks > initial resolve |
634.62 ops/s | 695.31 ops/s | -8.7% |
core/player/src/view/resolver/__tests__/index.bench.ts > resolver benchmarks > Resolving from cache |
18.50K ops/s | 21.96K ops/s | -15.8% |
core/player/src/view/resolver/__tests__/index.bench.ts > resolver benchmarks > data changes |
2.72K ops/s | 3.14K ops/s | -13.3% |
core/player/src/view/resolver/__tests__/index.bench.ts > resolver benchmarks > data changes slow |
606.01 ops/s | 660.60 ops/s | -8.3% |
plugins/async-node/core ⚠️
| Benchmark | Current | Baseline | Change |
|---|---|---|---|
plugins/async-node/core/src/__tests__/index.bench.ts > async node benchmarks > Resolve Async Node 1 times |
13.34K ops/s | 13.80K ops/s | -3.3% |
plugins/async-node/core/src/__tests__/index.bench.ts > async node benchmarks > Resolve Async Node 5 times |
13.17K ops/s | 11.81K ops/s | +11.6% ✅ |
plugins/async-node/core/src/__tests__/index.bench.ts > async node benchmarks > Resolve Async Node 10 times |
10.52K ops/s | 10.29K ops/s | +2.2% |
plugins/async-node/core/src/__tests__/index.bench.ts > async node benchmarks > Resolve Async Node 50 times |
3.01K ops/s | 3.26K ops/s | -7.9% |
plugins/async-node/core/src/__tests__/index.bench.ts > async node benchmarks > Resolve Async Node 100 times |
1.61K ops/s | 1.29K ops/s | +24.8% ✅ |
plugins/async-node/core/src/__tests__/transform.bench.ts > async transform benchmarks > Resolve Async Node 1 times |
7.55K ops/s | 7.74K ops/s | -2.4% |
plugins/async-node/core/src/__tests__/transform.bench.ts > async transform benchmarks > Resolve Async Node 5 times |
7.66K ops/s | 8.61K ops/s | -11.0% |
plugins/async-node/core/src/__tests__/transform.bench.ts > async transform benchmarks > Resolve Async Node 10 times |
5.95K ops/s | 7.56K ops/s | -21.3% |
plugins/async-node/core/src/__tests__/transform.bench.ts > async transform benchmarks > Resolve Async Node 50 times |
2.39K ops/s | 2.84K ops/s | -16.0% |
plugins/async-node/core/src/__tests__/transform.bench.ts > async transform benchmarks > Resolve Async Node 100 times |
1.27K ops/s | 1.48K ops/s | -14.1% |
react/player
| Benchmark | Current | Baseline | Change |
|---|---|---|---|
react/player/src/asset/__tests__/index.bench.tsx > ReactAsset benchmarks > Render asset nested in 1 ReactAssets |
550.87 ops/s | 581.40 ops/s | -5.3% |
react/player/src/asset/__tests__/index.bench.tsx > ReactAsset benchmarks > Bubble errors nested in 1 ReactAssets |
862.32 ops/s | 887.17 ops/s | -2.8% |
react/player/src/asset/__tests__/index.bench.tsx > ReactAsset benchmarks > Render asset nested in 5 ReactAssets |
602.45 ops/s | 601.54 ops/s | +0.2% |
react/player/src/asset/__tests__/index.bench.tsx > ReactAsset benchmarks > Bubble errors nested in 5 ReactAssets |
945.96 ops/s | 996.91 ops/s | -5.1% |
react/player/src/asset/__tests__/index.bench.tsx > ReactAsset benchmarks > Render asset nested in 10 ReactAssets |
573.42 ops/s | 600.54 ops/s | -4.5% |
react/player/src/asset/__tests__/index.bench.tsx > ReactAsset benchmarks > Bubble errors nested in 10 ReactAssets |
647.93 ops/s | 550.59 ops/s | +17.7% ✅ |
react/player/src/asset/__tests__/index.bench.tsx > ReactAsset benchmarks > Render asset nested in 50 ReactAssets |
451.38 ops/s | 425.02 ops/s | +6.2% ✅ |
react/player/src/asset/__tests__/index.bench.tsx > ReactAsset benchmarks > Bubble errors nested in 50 ReactAssets |
209.80 ops/s | 192.67 ops/s | +8.9% ✅ |
react/player/src/asset/__tests__/index.bench.tsx > ReactAsset benchmarks > Render asset nested in 100 ReactAssets |
371.21 ops/s | 346.42 ops/s | +7.2% ✅ |
react/player/src/asset/__tests__/index.bench.tsx > ReactAsset benchmarks > Bubble errors nested in 100 ReactAssets |
113.96 ops/s | 95.61 ops/s | +19.2% ✅ |
Bundle ReportChanges will increase total bundle size by 6.6kB (0.11%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: plugins/metrics/coreAssets Changed:
view changes for bundle: plugins/check-path/coreAssets Changed:
view changes for bundle: plugins/a2ui/coreAssets Changed:
view changes for bundle: core/playerAssets Changed:
view changes for bundle: plugins/markdown/coreAssets Changed:
view changes for bundle: plugins/reference-assets/coreAssets Changed:
view changes for bundle: plugins/async-node/coreAssets Changed:
view changes for bundle: plugins/beacon/coreAssets Changed:
view changes for bundle: plugins/external-state/coreAssets Changed:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## fix/binding-tracker-resolved-node-map #967 +/- ##
============================================================
============================================================
☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
|
||
| // The pipeline is built on first use, so a stage tapped after that would | ||
| // otherwise never run. | ||
| this.hooks.resolveDataStages.intercept({ |
There was a problem hiding this comment.
In general not a fan of intercepts because they can cause weird timing issues. Any way we can solve this another way
There was a problem hiding this comment.
Removed the intercept. Player now calls a new DataController.rebuildPipeline() once, right after the dataController hook, so every stage tapped during that hook is included whatever the plugin order, and tapping alone never touches a built pipeline. When nothing read data during setup it does nothing; a new test checks that resolveDataStages runs once in that case. A stage tapped after the hook needs an explicit rebuildPipeline() call.
KetanReddy
left a comment
There was a problem hiding this comment.
If we can work around the intercept thing I think this should be good to go
Replace the resolveDataStages intercept, which rebuilt the pipeline whenever a stage was tapped after the first read, with one rebuild that Player runs right after its dataController hook. That covers a plugin reading data in its own tap before a later plugin taps resolveDataStages. A stage tapped after the hook calls the new DataController.rebuildPipeline().
Stacked on #966 to set the merge order. The two fixes don't depend on each other, and this PR's diff shows only its own change.
DataControllerbuilds its data pipeline lazily, the first time anything reads or writes data, and callsresolveDataStagesonly at that moment. A stage tapped after that never runs, and nothing reports it.Ordinary plugins hit this. Plugins tap
player.hooks.dataControllerin registration order, and if a plugin registered earlier reads data in its tap (to seed or check a value, say), the pipeline is built right then. A plugin registered later that tapsresolveDataStagesfrom its owndataControllertap is silently left out. Whether a data middleware runs then depends on plugin order, which the plugin adding it doesn't control.Why it's needed now
#968 adds a streaming data plugin whose middleware serves large collections from outside the data model. Without this fix, that plugin has to detect being left out and add itself another way:
Every plugin that adds a data stage would need the same workaround. With this fix, tapping
resolveDataStagesis enough, and #968 does only that. Its test "serves the collection when a plugin registered before it already read data" fails without this change.Change
Right after
player.hooks.dataControllerreturns, Player calls a newDataController.rebuildPipeline(). If something already built the pipeline, that callsresolveDataStagesagain and passes the result toPipelinedDataModel.setMiddleware. If nothing did, it does nothing, and the pipeline is built on first use as before. The data lives in the baseLocalModel, and thePipelinedDataModelinstance and its hooks are kept, so nothing written earlier is lost and listeners on the model stay attached.There's no intercept, so tapping
resolveDataStagesnever changes a built pipeline by itself. Every stage tapped during thedataControllerhook is included, whatever the plugin order. A stage tapped after the hook needs arebuildPipeline()call; onmain, such a stage never runs.Rebuilding calls every
resolveDataStagestap again. A tap that creates a new middleware on each call gets a fresh instance at that point; the taps incomputed-propertiesandstage-revert-datareuse theirs, so they're unaffected.The data controller architecture page now says that Player rebuilds the pipeline after its
dataControllerhook and that a later tap needsrebuildPipeline(), instead of describing the stages as frozen.Tests
data.test.ts: a stage tapped after the first read doesn't run untilrebuildPipeline()and then does, data written before the rebuild is kept, anonSetlistener on the model still fires after it, and calling it before the pipeline is built leaves the pipeline to be built on first use.player.test.ts: when one plugin reads data in itsdataControllertap and a later plugin tapsresolveDataStages, the later stage runs. When no plugin reads data during setup,resolveDataStagesis called once.The first
player.test.tstest fails onmain, and also fails here if Player doesn't callrebuildPipeline(). Thecore/playervitest, eslint, and typecheck targets pass, as do thecomputed-propertiesandstage-revert-datasuites.Change Type (required)
Indicate the type of change your pull request is:
patchminormajorN/ADoes your PR have any documentation updates?