Skip to content

[Compiler] Make inherited functions generation order deterministic#4508

Merged
SupunS merged 1 commit into
masterfrom
supun/fix-compiler-non-determinism
Jun 24, 2026
Merged

[Compiler] Make inherited functions generation order deterministic#4508
SupunS merged 1 commit into
masterfrom
supun/fix-compiler-non-determinism

Conversation

@SupunS

@SupunS SupunS commented Jun 22, 2026

Copy link
Copy Markdown
Member

Work towards #3804

Description

Not a user-facing problem at the moment. But still make it deterministic to make the compilation future proof.


  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work
  • Code follows the standards mentioned here
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

@SupunS SupunS self-assigned this Jun 22, 2026
@github-actions

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@github-actions

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown

Benchstat comparison

  • Base branch: onflow:master
  • Base commit: 38729bf
Results

old.txtnew.txt
time/opdelta
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ByteArrayTransfer-41.20µs ± 0%1.20µs ± 0%~(all equal)
ByteArrayValueToByteSlice-482.4ns ± 0%81.6ns ± 0%~(p=1.000 n=1+1)
ByteSliceToByteArrayValue-4939ns ± 0%965ns ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/bbq/compiler goos:linux goarch:amd64
CompileFungibleTokenTransferTransaction-4136µs ± 0%142µs ± 0%~(p=1.000 n=1+1)
CompileTime-439.6µs ± 0%43.5µs ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
ContractFunctionInvocation-4396µs ± 0%405µs ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/bbq/vm/test goos:linux goarch:amd64
ContractImport-4237µs ± 0%250µs ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
EMVAddressTransfer-43.42µs ± 0%3.47µs ± 0%~(p=1.000 n=1+1)
Emit-44.84ms ± 0%4.67ms ± 0%~(p=1.000 n=1+1)
EnumTransfer-41.32µs ± 0%1.33µs ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
ExportType/composite_type-4232ns ± 0%247ns ± 0%~(p=1.000 n=1+1)
ExportType/simple_type-443.8ns ± 0%44.5ns ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/bbq/vm/test goos:linux goarch:amd64
FTTransfer-4177µs ± 0%175µs ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ImperativeFib-423.3µs ± 0%23.1µs ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/bbq/vm/test goos:linux goarch:amd64
ImperativeFib-429.0µs ± 0%29.0µs ± 0%~(p=1.000 n=1+1)
ImperativeFibNewCompilerNewVM-455.7µs ± 0%57.0µs ± 0%~(p=1.000 n=1+1)
ImperativeFibNewVM-432.3µs ± 0%33.3µs ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
InterpretRecursionFib-42.36ms ± 0%2.36ms ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/bbq/vm/test goos:linux goarch:amd64
InterpreterFTTransfer-4144µs ± 0%145µs ± 0%~(p=1.000 n=1+1)
InterpreterImperativeFib-424.0µs ± 0%25.0µs ± 0%~(p=1.000 n=1+1)
InterpreterNewStruct-468.2µs ± 0%66.8µs ± 0%~(p=1.000 n=1+1)
MethodCall/concrete_type_method_call-445.9µs ± 0%49.9µs ± 0%~(p=1.000 n=1+1)
MethodCall/interface_method_call-467.7µs ± 0%64.7µs ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
NewInterpreter/new_interpreter-4927ns ± 0%898ns ± 0%~(p=1.000 n=1+1)
NewInterpreter/new_sub-interpreter-4347ns ± 0%341ns ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/bbq/vm/test goos:linux goarch:amd64
NewStruct-446.6µs ± 0%47.2µs ± 0%~(p=1.000 n=1+1)
NewStructRaw-43.18µs ± 0%3.07µs ± 0%~(p=1.000 n=1+1)
RecursionFib-41.73ms ± 0%1.77ms ± 0%~(p=1.000 n=1+1)
RuntimeFungibleTokenTransfer-4816µs ± 0%825µs ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
RuntimeFungibleTokenTransferInterpreter-4639µs ± 0%741µs ± 0%~(p=1.000 n=1+1)
RuntimeResourceDictionaryValues-42.85ms ± 0%2.95ms ± 0%~(p=1.000 n=1+1)
RuntimeResourceTracking-410.6ms ± 0%10.5ms ± 0%~(p=1.000 n=1+1)
RuntimeScriptNoop-414.7µs ± 0%15.8µs ± 0%~(p=1.000 n=1+1)
RuntimeVMInvokeContractImperativeFib-445.7µs ± 0%48.7µs ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ValueIsSubtypeOfSemaType-459.6ns ± 0%60.5ns ± 0%~(p=1.000 n=1+1)
 
alloc/opdelta
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ByteArrayTransfer-41.08kB ± 0%1.06kB ± 0%~(p=1.000 n=1+1)
ByteArrayValueToByteSlice-432.0B ± 0%32.0B ± 0%~(all equal)
ByteSliceToByteArrayValue-4845B ± 0%861B ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/bbq/compiler goos:linux goarch:amd64
CompileFungibleTokenTransferTransaction-482.9kB ± 0%82.9kB ± 0%~(p=1.000 n=1+1)
CompileTime-417.0kB ± 0%17.0kB ± 0%~(all equal)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
ContractFunctionInvocation-4145kB ± 0%145kB ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/bbq/vm/test goos:linux goarch:amd64
ContractImport-477.6kB ± 0%78.2kB ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
EMVAddressTransfer-42.44kB ± 0%2.45kB ± 0%~(p=1.000 n=1+1)
Emit-41.53MB ± 0%1.53MB ± 0%~(p=1.000 n=1+1)
EnumTransfer-4897B ± 0%895B ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
ExportType/composite_type-4112B ± 0%112B ± 0%~(all equal)
ExportType/simple_type-40.00B 0.00B ~(all equal)
pkg:github.com/onflow/cadence/bbq/vm/test goos:linux goarch:amd64
FTTransfer-446.7kB ± 0%46.7kB ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ImperativeFib-48.30kB ± 0%8.30kB ± 0%~(all equal)
pkg:github.com/onflow/cadence/bbq/vm/test goos:linux goarch:amd64
ImperativeFib-46.30kB ± 0%6.30kB ± 0%~(all equal)
ImperativeFibNewCompilerNewVM-426.7kB ± 0%26.7kB ± 0%~(all equal)
ImperativeFibNewVM-49.00kB ± 0%9.00kB ± 0%~(all equal)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
InterpretRecursionFib-41.17MB ± 0%1.17MB ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/bbq/vm/test goos:linux goarch:amd64
InterpreterFTTransfer-447.1kB ± 0%47.1kB ± 0%~(p=1.000 n=1+1)
InterpreterImperativeFib-48.29kB ± 0%8.29kB ± 0%~(all equal)
InterpreterNewStruct-424.7kB ± 0%24.6kB ± 0%~(p=1.000 n=1+1)
MethodCall/concrete_type_method_call-411.1kB ± 0%11.1kB ± 0%~(p=1.000 n=1+1)
MethodCall/interface_method_call-418.0kB ± 0%18.0kB ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
NewInterpreter/new_interpreter-4976B ± 0%976B ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-4232B ± 0%232B ± 0%~(all equal)
pkg:github.com/onflow/cadence/bbq/vm/test goos:linux goarch:amd64
NewStruct-414.0kB ± 0%13.6kB ± 0%~(p=1.000 n=1+1)
NewStructRaw-41.83kB ± 0%1.70kB ± 0%~(p=1.000 n=1+1)
RecursionFib-4342kB ± 0%342kB ± 0%~(all equal)
RuntimeFungibleTokenTransfer-4251kB ± 0%250kB ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
RuntimeFungibleTokenTransferInterpreter-4174kB ± 0%174kB ± 0%~(p=1.000 n=1+1)
RuntimeResourceDictionaryValues-41.78MB ± 0%1.78MB ± 0%~(p=1.000 n=1+1)
RuntimeResourceTracking-46.98MB ± 0%6.99MB ± 0%~(p=1.000 n=1+1)
RuntimeScriptNoop-48.07kB ± 0%8.09kB ± 0%~(p=1.000 n=1+1)
RuntimeVMInvokeContractImperativeFib-414.3kB ± 0%14.3kB ± 0%~(all equal)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ValueIsSubtypeOfSemaType-432.0B ± 0%32.0B ± 0%~(all equal)
 
allocs/opdelta
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ByteArrayTransfer-47.00 ± 0%7.00 ± 0%~(all equal)
ByteArrayValueToByteSlice-41.00 ± 0%1.00 ± 0%~(all equal)
ByteSliceToByteArrayValue-45.00 ± 0%5.00 ± 0%~(all equal)
pkg:github.com/onflow/cadence/bbq/compiler goos:linux goarch:amd64
CompileFungibleTokenTransferTransaction-4569 ± 0%569 ± 0%~(all equal)
CompileTime-4207 ± 0%207 ± 0%~(all equal)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
ContractFunctionInvocation-42.23k ± 0%2.23k ± 0%~(all equal)
pkg:github.com/onflow/cadence/bbq/vm/test goos:linux goarch:amd64
ContractImport-41.37k ± 0%1.37k ± 0%~(all equal)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
EMVAddressTransfer-429.0 ± 0%29.0 ± 0%~(all equal)
Emit-441.0k ± 0%41.0k ± 0%~(all equal)
EnumTransfer-413.0 ± 0%13.0 ± 0%~(all equal)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
ExportType/composite_type-42.00 ± 0%2.00 ± 0%~(all equal)
ExportType/simple_type-40.00 0.00 ~(all equal)
pkg:github.com/onflow/cadence/bbq/vm/test goos:linux goarch:amd64
FTTransfer-41.50k ± 0%1.50k ± 0%~(all equal)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ImperativeFib-4176 ± 0%176 ± 0%~(all equal)
pkg:github.com/onflow/cadence/bbq/vm/test goos:linux goarch:amd64
ImperativeFib-4322 ± 0%322 ± 0%~(all equal)
ImperativeFibNewCompilerNewVM-4528 ± 0%528 ± 0%~(all equal)
ImperativeFibNewVM-4364 ± 0%364 ± 0%~(all equal)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
InterpretRecursionFib-416.5k ± 0%16.5k ± 0%~(all equal)
pkg:github.com/onflow/cadence/bbq/vm/test goos:linux goarch:amd64
InterpreterFTTransfer-41.04k ± 0%1.04k ± 0%~(all equal)
InterpreterImperativeFib-4175 ± 0%175 ± 0%~(all equal)
InterpreterNewStruct-4408 ± 0%408 ± 0%~(all equal)
MethodCall/concrete_type_method_call-4402 ± 0%402 ± 0%~(all equal)
MethodCall/interface_method_call-4512 ± 0%512 ± 0%~(all equal)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
NewInterpreter/new_interpreter-415.0 ± 0%15.0 ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-44.00 ± 0%4.00 ± 0%~(all equal)
pkg:github.com/onflow/cadence/bbq/vm/test goos:linux goarch:amd64
NewStruct-4422 ± 0%422 ± 0%~(all equal)
NewStructRaw-430.0 ± 0%30.0 ± 0%~(all equal)
RecursionFib-419.5k ± 0%19.5k ± 0%~(all equal)
RuntimeFungibleTokenTransfer-44.21k ± 0%4.21k ± 0%~(all equal)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
RuntimeFungibleTokenTransferInterpreter-43.21k ± 0%3.21k ± 0%~(all equal)
RuntimeResourceDictionaryValues-436.7k ± 0%36.7k ± 0%~(all equal)
RuntimeResourceTracking-4128k ± 0%128k ± 0%~(p=1.000 n=1+1)
RuntimeScriptNoop-4113 ± 0%113 ± 0%~(all equal)
RuntimeVMInvokeContractImperativeFib-4481 ± 0%481 ± 0%~(all equal)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ValueIsSubtypeOfSemaType-41.00 ± 0%1.00 ± 0%~(all equal)
 

@SupunS SupunS force-pushed the supun/fix-compiler-non-determinism branch from 1aeb40c to 63cad56 Compare June 22, 2026 21:12
@SupunS SupunS marked this pull request as ready for review June 23, 2026 17:03
@SupunS SupunS requested a review from turbolent as a code owner June 23, 2026 17:03

@turbolent turbolent left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, it's best to also make the compilation deterministic.

The nolint:maprange maybe used to be valid, but no longer is. I added a TODO item to #3804 to audit all remaining cases once we are done

@SupunS SupunS merged commit 73b315f into master Jun 24, 2026
15 of 17 checks passed
@SupunS SupunS deleted the supun/fix-compiler-non-determinism branch June 24, 2026 19:23
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.

2 participants