Skip to content

Use defensive copies for readonly nested value fields - #626

Open
jogibear9988 wants to merge 1 commit into
dadhi:masterfrom
jogibear9988:fix/readonly-nested-bindings-independent
Open

jogibear9988 wants to merge 1 commit into
dadhi:masterfrom
jogibear9988:fix/readonly-nested-bindings-independent

Conversation

@jogibear9988

Copy link
Copy Markdown
Contributor

Nested initialization currently mutates readonly struct fields. Load a readonly value field into a local copy before applying its nested bindings, preserving the stored field as System compilation does.

Readonly instance struct fields, with writable-field controls and System compilation as the behavior oracle. Regressions require strict FEC compilation. Native suites cover Standard and LightExpression.

Validation

Local validation uses master baseline 094d067 plus this change. Release solution build: zero warnings/errors.

Runtime TestX groups Legacy tests
.NET 10 489 passed 1,756 passed
.NET 8 489 passed 1,755 passed
.NET Framework 4.7.2 468 passed 1,639 passed

Measurements

Master baseline 094d0678 → this change, Release, Windows ARM64, .NET 8.0.28 / 10.0.9. Compilation uses prebuilt trees; runtime measures invocation through the same wrapper. Two fresh process rounds with reversed load order, seven samples per round, about 30 ms calibration, one logical CPU and tiered compilation disabled. Tables use the median of the two per-round medians.

The controls below produce correct results on master for their measured inputs. Newly supported trees have no valid before/after execution comparison because master rejects them, produces incorrect results or emits invalid IL. Timings include machine and JIT/code-placement variation; the unchanged add control helps show that variation. These observations do not prove universal performance neutrality.

net8.0 results (master → change)
API / workload Compile ns Invoke ns Compile B/op Invoke B/op
Standard / add_control 1556.8 → 1603.4 2.5 → 2.6 872.0 → 872.0 0.0 → 0.0
Standard / member_init 2161.7 → 2648.0 4.7 → 5.3 1064.1 → 1064.1 24.0 → 24.0
Standard / nested_writable_field 1632.9 → 1855.3 6.8 → 4.6 1064.1 → 1064.1 24.0 → 24.0
Light / add_control 1749.8 → 1424.4 2.4 → 2.4 872.0 → 872.0 0.0 → 0.0
Light / member_init 2434.2 → 2350.6 15.3 → 7.3 1064.0 → 1064.0 24.0 → 24.0
Light / nested_writable_field 2410.9 → 2592.6 15.4 → 15.0 1064.0 → 1064.0 24.0 → 24.0
net10.0 results (master → change)
API / workload Compile ns Invoke ns Compile B/op Invoke B/op
Standard / add_control 3608.4 → 3595.1 2.2 → 2.2 872.0 → 872.0 0.0 → 0.0
Standard / member_init 4327.8 → 4505.9 4.2 → 4.1 1064.2 → 1064.2 24.0 → 24.0
Standard / nested_writable_field 3596.7 → 3538.5 4.1 → 4.1 1064.2 → 1064.2 24.0 → 24.0
Light / add_control 2699.3 → 2773.6 2.2 → 2.1 872.0 → 872.0 0.0 → 0.0
Light / member_init 3106.0 → 3286.2 3.9 → 3.9 1064.0 → 1064.0 24.0 → 24.0
Light / nested_writable_field 2756.8 → 2778.0 4.0 → 4.0 1064.0 → 1064.0 24.0 → 24.0

Emitted IL differs in these measured workloads: none.
No measured allocation increase above 0.1 B/op in these controls.

Nested initialization currently mutates readonly struct fields. Load a readonly value field into a local copy before applying its nested bindings, preserving the stored field as System compilation does.

Validation: Release solution build; full Standard and LightExpression .NET 8, .NET 10 and Framework runners pass.

Measurements: master 094d067 versus this change, compilation and invocation, both APIs, .NET 8/10, two opposite-order process rounds with seven samples each. No measured allocation increase above 0.1 B/op in the selected working controls. Timings and emitted IL are recorded in the PR description; these controls do not establish universal performance neutrality.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant