Skip to content

fix(core): release replaced nodes in the validation binding tracker - #966

Merged
KetanReddy merged 1 commit into
mainfrom
fix/binding-tracker-resolved-node-map
Nov 17, 2026
Merged

KetanReddy merged 1 commit into
mainfrom
fix/binding-tracker-resolved-node-map

Conversation

@shahabdsh

@shahabdsh shahabdsh commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Bottom of a stack: #967 is stacked on this PR, and #968 on that one. This fix doesn't depend on either; the stack only sets the merge order.

ValidationBindingTrackerViewPlugin keeps every node that any update of a view resolves, for as long as the view stays current. A view whose data changes often grows memory with each update, and gets it back only when Player moves to another view.

Why it's needed

The tracker maps each resolved node to its source node in resolvedNodeMap, so it can carry validation bindings from one update to the next. When the root node finishes an update, it clears its other per-update maps, but not resolvedNodeMap. Each entry holds a resolved node and, through its children, that node's whole resolved subtree. So every update adds the nodes it resolved again, and the ones they replaced are never released.

Any view that updates repeatedly while it stays on screen is affected: typing into inputs, polling, or data a plugin loads in the background. In a measurement with a view of 200 text assets updated 200 times, the heap grew by 14.24 MB on main and by 0.30 MB with this change.

Change

Clear resolvedNodeMap with the other maps when the root finishes an update. The map is read only at that moment, and every node resolved in an update sets its entry before the root finishes, so nothing reads an entry this clears.

Tests

binding-tracker.test.ts updates a view 20 times, holds the nodes each update resolved in WeakRefs, forces garbage collection, and checks that the nodes later updates replaced were released. On main, 19 replaced nodes are still held after garbage collection; with the change, none are. The test turns on gc with v8.setFlagsFromString("--expose-gc"), because vitest doesn't pass Node flags through to tests.

Change Type (required)

Indicate the type of change your pull request is:

  • patch
  • minor
  • major
  • N/A

Does your PR have any documentation updates?

  • Updated docs
  • No Update needed
  • Unable to update docs

ValidationBindingTrackerViewPlugin maps each resolved node to its source
node so it can carry binding trees from one update to the next. It
cleared every other per-update map at the end of each root update, but
never resolvedNodeMap, so the map kept every node any update had
resolved, with its resolved subtree, for as long as the view was
current.

Clear the map with the others. It's only read while the root finishes
an update, and every node in that update sets its entry first.
@intuit-svc

Copy link
Copy Markdown
Contributor

Benchmark Results

Comparison against baseline from main. ⚠️ = regression (>10% slower), ✅ = improvement (>5% faster)

core/player ⚠️

Benchmark Current Baseline Change
core/player/src/binding/__tests__/parser.bench.ts > parser benchmarks > Resolving binding: foo.bar 823.03K ops/s 925.06K ops/s -11.0% ⚠️
core/player/src/binding/__tests__/parser.bench.ts > parser benchmarks > Resolving binding: foo.pets.1.name 538.69K ops/s 521.10K ops/s +3.4%
core/player/src/binding/__tests__/parser.bench.ts > parser benchmarks > Resolving binding: foo.pets.01.name 473.06K ops/s 503.37K ops/s -6.0%
core/player/src/binding/__tests__/parser.bench.ts > parser benchmarks > Resolving binding: foo.pets['01'].name 446.66K ops/s 501.47K ops/s -10.9% ⚠️
core/player/src/binding/__tests__/parser.bench.ts > parser benchmarks > Resolving binding: foo.pets[01].name 501.04K ops/s 492.83K ops/s +1.7%
core/player/src/binding/__tests__/parser.bench.ts > parser benchmarks > Resolving binding: foo.pets[name = "frodo"].type 267.56K ops/s 279.80K ops/s -4.4%
core/player/src/binding/__tests__/parser.bench.ts > parser benchmarks > Resolving binding: foo.pets["name" = "sprinkles"].type 224.75K ops/s 235.69K ops/s -4.6%
core/player/src/binding/__tests__/parser.bench.ts > parser benchmarks > Resolving binding: foo.pets["isDog" = false].type 264.37K ops/s 308.07K ops/s -14.2% ⚠️
core/player/src/binding/__tests__/parser.bench.ts > parser benchmarks > Resolving binding: foo.pets["isDog" = true].type 244.83K ops/s 318.65K ops/s -23.2% ⚠️
core/player/src/binding/__tests__/parser.bench.ts > binding creation benchmarks > Resolving binding: foo.bar 516.46K ops/s 605.13K ops/s -14.7% ⚠️
core/player/src/binding/__tests__/parser.bench.ts > binding creation benchmarks > Resolving binding: foo.pets.1.name 294.65K ops/s 389.77K ops/s -24.4% ⚠️
core/player/src/binding/__tests__/parser.bench.ts > binding creation benchmarks > Resolving binding: foo.pets.01.name 299.75K ops/s 392.62K ops/s -23.7% ⚠️
core/player/src/binding/__tests__/parser.bench.ts > binding creation benchmarks > Resolving binding: foo.pets['01'].name 247.78K ops/s 358.56K ops/s -30.9% ⚠️
core/player/src/binding/__tests__/parser.bench.ts > binding creation benchmarks > Resolving binding: foo.pets[01].name 348.99K ops/s 393.40K ops/s -11.3% ⚠️
core/player/src/binding/__tests__/parser.bench.ts > binding creation benchmarks > Resolving binding: foo.pets[name = "frodo"].type 226.48K ops/s 250.49K ops/s -9.6%
core/player/src/binding/__tests__/parser.bench.ts > binding creation benchmarks > Resolving binding: foo.pets["name" = "sprinkles"].type 169.94K ops/s 200.40K ops/s -15.2% ⚠️
core/player/src/binding/__tests__/parser.bench.ts > binding creation benchmarks > Resolving binding: foo.pets["isDog" = false].type 205.89K ops/s 243.54K ops/s -15.5% ⚠️
core/player/src/binding/__tests__/parser.bench.ts > binding creation benchmarks > Resolving binding: foo.pets["isDog" = true].type 231.05K ops/s 256.20K ops/s -9.8%
core/player/src/expressions/__tests__/performance.bench.ts > Expression Parsing/Execution Benchmark > Parsing: {{foo}} = 1 + 3 (sync) 441.04K ops/s 490.09K ops/s -10.0% ⚠️
core/player/src/expressions/__tests__/performance.bench.ts > Expression Parsing/Execution Benchmark > Parsing: {{foo}} = 1 + 3 (async) 313.50K ops/s 398.74K ops/s -21.4% ⚠️
core/player/src/expressions/__tests__/performance.bench.ts > Expression Parsing/Execution Benchmark > Parsing: conditional(true, true, false) (sync) 467.94K ops/s 501.45K ops/s -6.7%
core/player/src/expressions/__tests__/performance.bench.ts > Expression Parsing/Execution Benchmark > Parsing: conditional(true, true, false) (async) 385.91K ops/s 441.52K ops/s -12.6% ⚠️
core/player/src/expressions/__tests__/performance.bench.ts > Expression Parsing/Execution Benchmark > Parsing: {{foo}} = conditional({{bar}} > 0, true, false) (sync) 161.66K ops/s 221.46K ops/s -27.0% ⚠️
core/player/src/expressions/__tests__/performance.bench.ts > Expression Parsing/Execution Benchmark > Parsing: {{foo}} = conditional({{bar}} > 0, true, false) (async) 159.73K ops/s 206.12K ops/s -22.5% ⚠️
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) 159.90K ops/s 153.99K ops/s +3.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)) (async) 149.69K ops/s 158.90K ops/s -5.8%
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) 247.18K ops/s 298.85K ops/s -17.3% ⚠️
core/player/src/expressions/__tests__/performance.bench.ts > Expression Parsing/Execution Benchmark > Parsing: {{foo}} = asyncTestFunction(1) (sync) 306.34K ops/s 344.27K ops/s -11.0% ⚠️
core/player/src/expressions/__tests__/performance.bench.ts > Expression Parsing/Execution Benchmark > Parsing: {{foo}} = asyncTestFunction(1) (async) 260.72K ops/s 314.43K ops/s -17.1% ⚠️
core/player/src/expressions/__tests__/performance.bench.ts > Expression Parsing/Execution Benchmark > Parsing: asyncTestFunction(1) (sync) 825.98K ops/s 942.19K ops/s -12.3% ⚠️
core/player/src/expressions/__tests__/performance.bench.ts > Expression Parsing/Execution Benchmark > Parsing: asyncTestFunction(1) (async) 435.90K ops/s 742.09K ops/s -41.3% ⚠️
core/player/src/expressions/__tests__/performance.bench.ts > Expression Parsing/Execution Benchmark > Parsing: {{foo}} = conditional(!{{bar}} == false, await(asyncTestFunction(1)), false) (sync) 163.96K ops/s 193.03K ops/s -15.1% ⚠️
core/player/src/expressions/__tests__/performance.bench.ts > Expression Parsing/Execution Benchmark > Parsing: {{foo}} = conditional(!{{bar}} == false, await(asyncTestFunction(1)), false) (async) 171.97K ops/s 177.43K ops/s -3.1%
core/player/src/view/resolver/__tests__/index.bench.ts > resolver benchmarks > initial resolve 625.51 ops/s 695.31 ops/s -10.0% ⚠️
core/player/src/view/resolver/__tests__/index.bench.ts > resolver benchmarks > Resolving from cache 15.58K ops/s 21.96K ops/s -29.0% ⚠️
core/player/src/view/resolver/__tests__/index.bench.ts > resolver benchmarks > data changes 2.83K ops/s 3.14K ops/s -10.0% ⚠️
core/player/src/view/resolver/__tests__/index.bench.ts > resolver benchmarks > data changes slow 570.62 ops/s 660.60 ops/s -13.6% ⚠️

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.02K ops/s 13.80K ops/s -5.6%
plugins/async-node/core/src/__tests__/index.bench.ts > async node benchmarks > Resolve Async Node 5 times 12.28K ops/s 11.81K ops/s +4.0%
plugins/async-node/core/src/__tests__/index.bench.ts > async node benchmarks > Resolve Async Node 10 times 7.89K ops/s 10.29K ops/s -23.4% ⚠️
plugins/async-node/core/src/__tests__/index.bench.ts > async node benchmarks > Resolve Async Node 50 times 2.93K ops/s 3.26K ops/s -10.3% ⚠️
plugins/async-node/core/src/__tests__/index.bench.ts > async node benchmarks > Resolve Async Node 100 times 1.47K ops/s 1.29K ops/s +13.4% ✅
plugins/async-node/core/src/__tests__/transform.bench.ts > async transform benchmarks > Resolve Async Node 1 times 6.49K ops/s 7.74K ops/s -16.1% ⚠️
plugins/async-node/core/src/__tests__/transform.bench.ts > async transform benchmarks > Resolve Async Node 5 times 7.08K ops/s 8.61K ops/s -17.8% ⚠️
plugins/async-node/core/src/__tests__/transform.bench.ts > async transform benchmarks > Resolve Async Node 10 times 6.21K ops/s 7.56K ops/s -17.9% ⚠️
plugins/async-node/core/src/__tests__/transform.bench.ts > async transform benchmarks > Resolve Async Node 50 times 2.41K ops/s 2.84K ops/s -15.2% ⚠️
plugins/async-node/core/src/__tests__/transform.bench.ts > async transform benchmarks > Resolve Async Node 100 times 1.39K ops/s 1.48K ops/s -6.1%

react/player ⚠️

Benchmark Current Baseline Change
react/player/src/asset/__tests__/index.bench.tsx > ReactAsset benchmarks > Render asset nested in 1 ReactAssets 530.02 ops/s 581.40 ops/s -8.8%
react/player/src/asset/__tests__/index.bench.tsx > ReactAsset benchmarks > Bubble errors nested in 1 ReactAssets 905.05 ops/s 887.17 ops/s +2.0%
react/player/src/asset/__tests__/index.bench.tsx > ReactAsset benchmarks > Render asset nested in 5 ReactAssets 571.96 ops/s 601.54 ops/s -4.9%
react/player/src/asset/__tests__/index.bench.tsx > ReactAsset benchmarks > Bubble errors nested in 5 ReactAssets 887.84 ops/s 996.91 ops/s -10.9% ⚠️
react/player/src/asset/__tests__/index.bench.tsx > ReactAsset benchmarks > Render asset nested in 10 ReactAssets 505.63 ops/s 600.54 ops/s -15.8% ⚠️
react/player/src/asset/__tests__/index.bench.tsx > ReactAsset benchmarks > Bubble errors nested in 10 ReactAssets 828.75 ops/s 550.59 ops/s +50.5% ✅
react/player/src/asset/__tests__/index.bench.tsx > ReactAsset benchmarks > Render asset nested in 50 ReactAssets 419.15 ops/s 425.02 ops/s -1.4%
react/player/src/asset/__tests__/index.bench.tsx > ReactAsset benchmarks > Bubble errors nested in 50 ReactAssets 219.42 ops/s 192.67 ops/s +13.9% ✅
react/player/src/asset/__tests__/index.bench.tsx > ReactAsset benchmarks > Render asset nested in 100 ReactAssets 354.24 ops/s 346.42 ops/s +2.3%
react/player/src/asset/__tests__/index.bench.tsx > ReactAsset benchmarks > Bubble errors nested in 100 ReactAssets 100.36 ops/s 95.61 ops/s +5.0%

@shahabdsh
shahabdsh added this pull request to stack #969 November 10, 2026 20:28
@codecov

codecov Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (5cc6702) to head (c911b30).
⚠️ Report is 31 commits behind head on main.

Additional details and impacted files
@@     Coverage Diff     @@
##   main   #966   +/-   ##
===========================
===========================

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codecov

codecov Bot commented Nov 10, 2026

Copy link
Copy Markdown

Bundle Report

Changes will increase total bundle size by 20.91kB (0.35%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
plugins/check-path/core 444.06kB 53 bytes (0.01%) ⬆️
plugins/async-node/core 506.66kB 20.39kB (4.19%) ⬆️
plugins/markdown/core 684.96kB 53 bytes (0.01%) ⬆️
plugins/reference-assets/core 556.66kB 53 bytes (0.01%) ⬆️
plugins/beacon/core 425.66kB 53 bytes (0.01%) ⬆️
plugins/metrics/core 462.22kB 53 bytes (0.01%) ⬆️
core/player 1.02MB 158 bytes (0.02%) ⬆️
plugins/external-state/core 428.32kB 53 bytes (0.01%) ⬆️
plugins/a2ui/core 587.42kB 53 bytes (0.01%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: plugins/markdown/core

Assets Changed:

Asset Name Size Change Total Size Change (%)
MarkdownPlugin.native.js 53 bytes 659.57kB 0.01%
view changes for bundle: plugins/a2ui/core

Assets Changed:

Asset Name Size Change Total Size Change (%)
A2UIPlugin.native.js 53 bytes 493.57kB 0.01%
view changes for bundle: plugins/external-state/core

Assets Changed:

Asset Name Size Change Total Size Change (%)
ExternalStatePlugin.native.js 53 bytes 409.36kB 0.01%
view changes for bundle: core/player

Assets Changed:

Asset Name Size Change Total Size Change (%)
Player.native.js 53 bytes 427.8kB 0.01%
cjs/index.cjs 35 bytes 203.01kB 0.02%
index.legacy-esm.js 35 bytes 196.29kB 0.02%
index.mjs 35 bytes 196.29kB 0.02%
view changes for bundle: plugins/async-node/core

Assets Changed:

Asset Name Size Change Total Size Change (%)
AsyncNodePlugin.native.js 53 bytes 443.38kB 0.01%
index.legacy-esm.js 20.33kB 20.33kB 100.0% ⚠️
view changes for bundle: plugins/reference-assets/core

Assets Changed:

Asset Name Size Change Total Size Change (%)
ReferenceAssetsPlugin.native.js 53 bytes 518.67kB 0.01%
view changes for bundle: plugins/check-path/core

Assets Changed:

Asset Name Size Change Total Size Change (%)
CheckPathPlugin.native.js 53 bytes 414.57kB 0.01%
view changes for bundle: plugins/metrics/core

Assets Changed:

Asset Name Size Change Total Size Change (%)
MetricsPlugin.native.js 53 bytes 429.87kB 0.01%
view changes for bundle: plugins/beacon/core

Assets Changed:

Asset Name Size Change Total Size Change (%)
BeaconPlugin.native.js 53 bytes 411.19kB 0.01%

@KetanReddy KetanReddy added the patch Increment the patch version when merged label Nov 17, 2026
@KetanReddy
KetanReddy merged commit 42e48c3 into main Nov 17, 2026
23 of 26 checks passed
@KetanReddy
KetanReddy deleted the fix/binding-tracker-resolved-node-map branch November 17, 2026 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch Increment the patch version when merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants