Skip to content

Conversation

@aaronbuchwald
Copy link
Collaborator

Why this should be merged

This PR adds a benchmark for GetCanonicalValidatorSet used in warp signature verification.

How this works

See the code

How this was tested

Running locally to confirm the benchmark passes and see the initial values:

# github.com/ava-labs/avalanchego/vms/platformvm/warp.test
ld: warning: could not create compact unwind for _blst_sha256_block_data_order: does not use RBP or RSP based frame
goos: darwin
goarch: amd64
pkg: github.com/ava-labs/avalanchego/vms/platformvm/warp
cpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
BenchmarkGetCanonicalValidatorSet/0-12  	37213069	        29.15 ns/op	       0 B/op	       0 allocs/op
BenchmarkGetCanonicalValidatorSet/1-12  	 2807650	       441.2 ns/op	     192 B/op	       5 allocs/op
BenchmarkGetCanonicalValidatorSet/10-12 	  275293	      5106 ns/op	    2340 B/op	      42 allocs/op
BenchmarkGetCanonicalValidatorSet/100-12         	   24452	     54903 ns/op	   23477 B/op	     403 allocs/op
BenchmarkGetCanonicalValidatorSet/1000-12        	    2030	    510480 ns/op	  249560 B/op	    4003 allocs/op
BenchmarkGetCanonicalValidatorSet/10000-12       	     184	   6788629 ns/op	 2380698 B/op	   40003 allocs/op
PASS
ok  	github.com/ava-labs/avalanchego/vms/platformvm/warp	12.603s

@StephenButtolph StephenButtolph added the sdk This involves SDK tooling or frameworks label Apr 25, 2023
@StephenButtolph StephenButtolph merged commit 2f6d922 into dev Apr 25, 2023
@StephenButtolph StephenButtolph deleted the benchmark-get-canonical-validator-set branch April 25, 2023 23:50
@aaronbuchwald
Copy link
Collaborator Author

@joshua-kim this is the PR adding the benchmark for GetCanonicalValidatorSet. I separated the function out locally and saw that the lion's share of the time was spent handling the sort operation at the end.

Your idea of adding the items to a sorted map sounds like a good idea to optimize this.

maru-ava pushed a commit that referenced this pull request Nov 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sdk This involves SDK tooling or frameworks

Projects

No open projects
Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants