Skip to content

update test to match fvm benchmark#4353

Draft
j1010001 wants to merge 1 commit intomasterfrom
jan/benchmark-experimentation
Draft

update test to match fvm benchmark#4353
j1010001 wants to merge 1 commit intomasterfrom
jan/benchmark-experimentation

Conversation

@j1010001
Copy link
Copy Markdown
Member

DO NOT MERGE - experiment

I was just curious how fvm vs cadence benchmark compares for same (at least close to same) token transfer tx.

I took FVM benchmark @janezpodhostnik added here: https://github.com/onflow/flow-execution-effort-estimation/pull/80
The Tx this runs is:

transaction(){


    prepare(signer: auth(Storage, Contracts, Keys, Inbox, Capabilities) &Account) {
        var f: fun(): Void = fun(){}
        f = fun() {
                var i = 0
                while i < 26 {
                    i = i + 1

            let vaultRef = signer.storage.borrow<auth(FungibleToken.Withdraw) &FlowToken.Vault>(from: /storage/flowTokenVault)!
            let receiverRef = getAccount(signer.address)
                .capabilities.borrow<&{FungibleToken.Receiver}>(/public/flowTokenReceiver)!
            receiverRef.deposit(from: <-vaultRef.withdraw(amount: 0.00001))

                }
        }
        f()
    }

    execute {
        var f: fun(): Void = fun(){}
    }
}

Then I updated Cadence testRuntimeFungibleTokenTransfer test to match the transaction above (see the change in this PR).

FVM
Benchmark_GlobalRegistry/[TTS_26]-14 230 5,147,458 ns/op

Cadence interpreter
BenchmarkRuntimeFungibleTokenTransferInterpreter-14 690 1,618,031 ns/op 1672294 B/op 36598 allocs/op

Cadence VM
BenchmarkRuntimeFungibleTokenTransferVM-14 972 1,124,029 ns/op 1160718 B/op 26218 allocs/op

@github-actions
Copy link
Copy Markdown

Benchstat comparison

  • Base branch: onflow:master
  • Base commit: 5ec4685
Results

old.txtnew.txt
time/opdelta
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
ContractFunctionInvocation-4402µs ± 0%405µs ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
Emit-44.11ms ± 0%4.00ms ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
ExportType/composite_type-4272ns ± 0%266ns ± 0%~(p=1.000 n=1+1)
ExportType/simple_type-477.6ns ± 0%78.0ns ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ImperativeFib-420.4µs ± 0%20.5µs ± 0%~(p=1.000 n=1+1)
InterpretRecursionFib-42.23ms ± 0%2.14ms ± 0%~(p=1.000 n=1+1)
NewInterpreter/new_interpreter-41.05µs ± 0%1.03µs ± 0%~(p=1.000 n=1+1)
NewInterpreter/new_sub-interpreter-4315ns ± 0%314ns ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
RuntimeFungibleTokenTransferInterpreter-4598µs ± 0%5598µs ± 0%~(p=1.000 n=1+1)
RuntimeFungibleTokenTransferVM-4638µs ± 0%4114µs ± 0%~(p=1.000 n=1+1)
RuntimeResourceDictionaryValues-42.59ms ± 0%2.58ms ± 0%~(p=1.000 n=1+1)
RuntimeResourceTracking-412.0ms ± 0%12.1ms ± 0%~(p=1.000 n=1+1)
RuntimeScriptNoop-414.8µs ± 0%14.1µs ± 0%~(p=1.000 n=1+1)
RuntimeVMInvokeContractImperativeFib-427.7µs ± 0%27.5µs ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ValueIsSubtypeOfSemaType-468.8ns ± 0%67.3ns ± 0%~(p=1.000 n=1+1)
 
alloc/opdelta
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
ContractFunctionInvocation-4152kB ± 0%152kB ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
Emit-41.48MB ± 0%1.48MB ± 0%~(p=1.000 n=1+1)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
ExportType/composite_type-4120B ± 0%120B ± 0%~(all equal)
ExportType/simple_type-40.00B 0.00B ~(all equal)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ImperativeFib-48.30kB ± 0%8.30kB ± 0%~(all equal)
InterpretRecursionFib-41.19MB ± 0%1.19MB ± 0%~(p=1.000 n=1+1)
NewInterpreter/new_interpreter-4976B ± 0%976B ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-4232B ± 0%232B ± 0%~(all equal)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
RuntimeFungibleTokenTransferInterpreter-4159kB ± 0%1665kB ± 0%~(p=1.000 n=1+1)
RuntimeFungibleTokenTransferVM-4173kB ± 0%1163kB ± 0%~(p=1.000 n=1+1)
RuntimeResourceDictionaryValues-41.76MB ± 0%1.76MB ± 0%~(p=1.000 n=1+1)
RuntimeResourceTracking-49.27MB ± 0%9.26MB ± 0%~(p=1.000 n=1+1)
RuntimeScriptNoop-48.03kB ± 0%8.04kB ± 0%~(p=1.000 n=1+1)
RuntimeVMInvokeContractImperativeFib-49.80kB ± 0%9.80kB ± 0%~(all equal)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ValueIsSubtypeOfSemaType-448.0B ± 0%48.0B ± 0%~(all equal)
 
allocs/opdelta
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
ContractFunctionInvocation-42.46k ± 0%2.46k ± 0%~(all equal)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
Emit-439.0k ± 0%39.0k ± 0%~(all equal)
pkg:github.com/onflow/cadence/runtime goos:linux goarch:amd64
ExportType/composite_type-43.00 ± 0%3.00 ± 0%~(all equal)
ExportType/simple_type-40.00 0.00 ~(all equal)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ImperativeFib-4176 ± 0%176 ± 0%~(all equal)
InterpretRecursionFib-417.7k ± 0%17.7k ± 0%~(all equal)
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/runtime goos:linux goarch:amd64
RuntimeFungibleTokenTransferInterpreter-42.98k ± 0%36.89k ± 0%~(p=1.000 n=1+1)
RuntimeFungibleTokenTransferVM-43.00k ± 0%26.62k ± 0%~(p=1.000 n=1+1)
RuntimeResourceDictionaryValues-436.7k ± 0%36.7k ± 0%~(all equal)
RuntimeResourceTracking-4159k ± 0%159k ± 0%~(all equal)
RuntimeScriptNoop-4113 ± 0%113 ± 0%~(all equal)
RuntimeVMInvokeContractImperativeFib-4197 ± 0%197 ± 0%~(all equal)
pkg:github.com/onflow/cadence/interpreter goos:linux goarch:amd64
ValueIsSubtypeOfSemaType-41.00 ± 0%1.00 ± 0%~(all equal)
 

@SupunS
Copy link
Copy Markdown
Member

SupunS commented Nov 24, 2025

oh wow, I piggy-back on this updated test to compare the interpreter (master), vm (master), and optimized-vm (#4322), and the results are:

goos: darwin
goarch: arm64
pkg: github.com/onflow/cadence/runtime
cpu: Apple M1 Pro
                               │ interpreter_master.txt │            vm_master.txt            │          vm_optimized.txt           │
                               │         sec/op         │   sec/op     vs base                │   sec/op     vs base                │
RuntimeFungibleTokenTransfer-8              2.752m ± 3%   1.906m ± 4%  -30.75% (p=0.000 n=10)   1.490m ± 2%  -45.86% (p=0.000 n=10)

                               │ interpreter_master.txt │             vm_master.txt             │           vm_optimized.txt           │
                               │          B/op          │     B/op       vs base                │     B/op      vs base                │
RuntimeFungibleTokenTransfer-8            1639.7Ki ± 0%   1144.0Ki ± 0%  -30.23% (p=0.000 n=10)   844.9Ki ± 0%  -48.47% (p=0.000 n=10)

                               │ interpreter_master.txt │            vm_master.txt            │          vm_optimized.txt           │
                               │       allocs/op        │  allocs/op   vs base                │  allocs/op   vs base                │
RuntimeFungibleTokenTransfer-8              36.90k ± 0%   26.63k ± 0%  -27.83% (p=0.000 n=10)   20.64k ± 0%  -44.07% (p=0.000 n=10)

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.

2 participants