Skip to content

interop: add benchmarks for interop prices - #4388

Open
Turalchik wants to merge 1 commit into
masterfrom
interop-prices
Open

Turalchik wants to merge 1 commit into
masterfrom
interop-prices

Conversation

@Turalchik

@Turalchik Turalchik commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

A part of #4281.

@codecov

codecov Bot commented Aug 14, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 29 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.16%. Comparing base (ac51380) to head (f7e8c6a).

Files with missing lines Patch % Lines
pkg/core/interop/crypto/ecdsa.go 0.00% 29 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4388      +/-   ##
==========================================
+ Coverage   87.13%   87.16%   +0.02%     
==========================================
  Files         359      359              
  Lines       39069    39098      +29     
==========================================
+ Hits        34044    34078      +34     
+ Misses       5018     5013       -5     
  Partials        7        7              

☔ 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.

@Turalchik
Turalchik force-pushed the interop-prices branch 2 times, most recently from 35dcdd7 to 1a1323a Compare August 20, 2026 12:36
@Turalchik
Turalchik force-pushed the interop-prices branch 9 times, most recently from 7c34b24 to f1d210f Compare September 3, 2026 06:14
@Turalchik
Turalchik force-pushed the interop-prices branch 2 times, most recently from 176c09d to 765aba9 Compare September 15, 2026 12:28
@Turalchik
Turalchik force-pushed the interop-prices branch 6 times, most recently from 6cecd8c to ccb9268 Compare September 21, 2026 13:04
@Turalchik
Turalchik force-pushed the interop-prices branch 8 times, most recently from f36926b to 8b2b971 Compare September 29, 2026 15:06
@Turalchik
Turalchik marked this pull request as ready for review September 29, 2026 15:10

@AnnaShaleva AnnaShaleva 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.

Not finished.

return nil
}

func ECDSASecp256r1CheckMultisigDummy(ic *interop.Context) error {

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.

As discussed earlier, we won't use this approximation and we're OK with n*checkSigPrice for System.Crypto.CheckMultisig. So let's remove this method.

@@ -0,0 +1,20 @@
package interop_test

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.

Let's specify the build constraint via comment, like in

//go:build !windows

}
err = f.Sync()
if err == nil {
err = unix.Fadvise(int(f.Fd()), 0, 0, unix.FADV_DONTNEED)

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.

Adjust filename. AFAIK, the same test will properly work on all unix systems.

}
err = f.Sync()
if err == nil {
err = unix.Fadvise(int(f.Fd()), 0, 0, unix.FADV_DONTNEED)

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.

Why not via clearing page cache at OS level?

b.Fatal(err)
}
}
b.StartTimer()

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.

Useless call to b.StartTimer().

type benchCase struct {
f func(*interop.Context) error
itemsToAdd []any
amountToPop int

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.

numToPop.


type benchCase struct {
f func(*interop.Context) error
itemsToAdd []any

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.

itemsToPush, for unification.

}
pubBytes := priv.PublicKey().Bytes()

measure := func(n int) []string {

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.

We're not in Python, use proper type/struct instead of []string.

return ns / nopNs
}

func genCreateMultisigAccount(nopNs float64) [][]string {

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.

Ditto, use type instead of [][]string.

Comment on lines +1548 to +1551
func TestGenerateNOPCSV(t *testing.T) {
if *genOutDir == "" {
t.Skip("-genoutdir is not set")
}

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.

It's a benchmark, not test. Create a unit-test that will use static filenames and generate all the output files on some constant boolean condition. Take the approach from TestCreateBasicChain.

nopIC.SpawnVM()
nopIC.VM.SetGasLimit(-1)
nopNs := measureNsPerOp(func(b *testing.B) { benchmarkNOP(b, nopIC) })
t.Logf("nop ns/op = %v", nopNs)

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.

NOP here and everywhere where the string representation of an opcode is used.

}
}

func readNOPNs(dir string) (float64, error) {

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.

Why do you need a separate read for NOPs? Why not to start TestGenerateInteropPriceCSV with NOPs evaluation in-place? It will give more robust data that are relatively independent from the benchmark environment.

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.

How long does it take to run benchmark for NOP?

return nopNs, nil
}

func TestGenerateInteropPriceCSV(t *testing.T) {

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.

Place all gen* functions to a separate file, decouple them from the real benchmark setup.

Comment thread go.mod
go.uber.org/zap v1.28.0
go.yaml.in/yaml/v3 v3.0.5
golang.org/x/crypto v0.55.0
golang.org/x/sys v0.47.0

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.

Unrelated.

Signed-off-by: Tural Devrishev <tural@nspcc.ru>
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