Skip to content

Compile BuiltinData transparently in the plugin - #7862

Closed
Unisay wants to merge 2 commits into
yura/fix-builtin-casing-addr-joinpointfrom
yura/builtin-data-transparent
Closed

Compile BuiltinData transparently in the plugin#7862
Unisay wants to merge 2 commits into
yura/fix-builtin-casing-addr-joinpointfrom
yura/builtin-data-transparent

Conversation

@Unisay

@Unisay Unisay commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Alternative to the unreachable-constructor workaround in #7719 (stacked on that branch, so the diff shows only the delta; retarget to master once #7719 merges or if it's superseded).

The plugin treats BuiltinData as representationally transparent: PlutusCore.Data.Data compiles to the builtin data type (same as BuiltinData), the BuiltinData constructor compiles to the identity, and a single-alternative case on it binds both the case binder and the field to the scrutinee. GHC unwrapping the wrapper (the #7716 join-point crash) then becomes harmless instead of fatal, so BuiltinDataUnreachable and its COMPLETE pragma are removed. Details in Note [Transparent BuiltinData] in PlutusTx.Compiler.Expr.

The GHC 9.12 budget goldens return exactly to master's numbers — the ~1% CPU / ~2.5% memory cost of blocking GHC's unboxing is gone. Both plugin test suites pass under GHC 9.6 and 9.12 (847 + 81).

One diagnostic change: StageViolation/builtinData now reports the unwrapped binding (ipv … No unfolding, Type: PlutusCore.Data.Data) instead of validator :: BuiltinData, because GHC unwraps the where-binding again; the stage-violation hint and remediation notes are unchanged.

@github-actions

Copy link
Copy Markdown
Contributor

Execution Budget Golden Diff

22c47f6 (master) vs 054cace

output

plutus-tx-plugin/test-ledger-api/Spec/Data/Budget/9.12/geq1.golden.eval

Metric Old New Δ%
CPU 334_850_215 331_010_215 -1.15%
Memory 976_905 952_905 -2.46%
Flat Size 928 938 +1.08%

plutus-tx-plugin/test-ledger-api/Spec/Data/Budget/9.12/geq2.golden.eval

Metric Old New Δ%
CPU 344_667_162 340_731_162 -1.14%
Memory 1_003_331 978_731 -2.45%
Flat Size 979 989 +1.02%

plutus-tx-plugin/test-ledger-api/Spec/Data/Budget/9.12/geq3.golden.eval

Metric Old New Δ%
CPU 355_696_500 351_760_500 -1.11%
Memory 1_035_525 1_010_925 -2.38%
Flat Size 979 989 +1.02%

plutus-tx-plugin/test-ledger-api/Spec/Data/Budget/9.12/geq4.golden.eval

Metric Old New Δ%
CPU 179_453_560 177_245_560 -1.23%
Memory 536_841 523_041 -2.57%
Flat Size 935 945 +1.07%

plutus-tx-plugin/test-ledger-api/Spec/Data/Budget/9.12/geq5.golden.eval

Metric Old New Δ%
CPU 346_913_250 342_977_250 -1.13%
Memory 1_009_660 985_060 -2.44%
Flat Size 935 945 +1.07%

plutus-tx-plugin/test-ledger-api/Spec/Data/Budget/9.12/gt1.golden.eval

Metric Old New Δ%
CPU 385_306_620 381_466_620 -1.00%
Memory 1_153_920 1_129_920 -2.08%
Flat Size 1_281 1_291 +0.78%

plutus-tx-plugin/test-ledger-api/Spec/Data/Budget/9.12/gt2.golden.eval

Metric Old New Δ%
CPU 344_891_162 340_955_162 -1.14%
Memory 1_004_731 980_131 -2.45%
Flat Size 1_332 1_342 +0.75%

plutus-tx-plugin/test-ledger-api/Spec/Data/Budget/9.12/gt3.golden.eval

Metric Old New Δ%
CPU 407_098_605 403_162_605 -0.97%
Memory 1_217_905 1_193_305 -2.02%
Flat Size 1_332 1_342 +0.75%

plutus-tx-plugin/test-ledger-api/Spec/Data/Budget/9.12/gt4.golden.eval

Metric Old New Δ%
CPU 179_677_560 177_469_560 -1.23%
Memory 538_241 524_441 -2.56%
Flat Size 1_288 1_298 +0.78%

plutus-tx-plugin/test-ledger-api/Spec/Data/Budget/9.12/gt5.golden.eval

Metric Old New Δ%
CPU 370_975_878 367_039_878 -1.06%
Memory 1_097_584 1_072_984 -2.24%
Flat Size 1_288 1_298 +0.78%

plutus-tx-plugin/test/Budget/9.12/map2.golden.eval

Metric Old New Δ%
CPU 68_035_382 67_555_382 -0.71%
Memory 199_090 196_090 -1.51%
Flat Size 454 459 +1.10%

plutus-tx-plugin/test/Budget/9.12/map3.golden.eval

Metric Old New Δ%
CPU 111_907_732 111_043_732 -0.77%
Memory 333_684 328_284 -1.62%
Flat Size 699 709 +1.43%

This comment will get updated when changes are made.

@Unisay Unisay self-assigned this Jul 22, 2026
@Unisay
Unisay force-pushed the yura/builtin-data-transparent branch from 054cace to a22ae94 Compare July 22, 2026 13:51
@Unisay

Unisay commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

Superseded — reopening as an independent PR against master rather than stacked on #7719.

@Unisay Unisay closed this Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant