Skip to content

Conversation

@suranmiao
Copy link

These changes use b.Loop() to simplify the code and improve performance
Supported by Go Team, more info: https://go.dev/blog/testing-b-loop and https://go.dev/issue/73137.

Before:

 go test -run=^$ -bench=. ./blob  
goos: darwin
goarch: arm64
pkg: github.com/celestiaorg/celestia-node/blob
cpu: Apple M4
BenchmarkGetByCommitment-10    	    4675	    336084 ns/op	 1053903 B/op	    3418 allocs/op
PASS
ok  	github.com/celestiaorg/celestia-node/blob	3.784s

---

go test -run=^$ -bench=. ./header/headertest    
goos: darwin
goarch: arm64
pkg: github.com/celestiaorg/celestia-node/header/headertest
cpu: Apple M4
BenchmarkMsgID-10    	   39388	     33899 ns/op	  165967 B/op	     593 allocs/op
PASS
ok  	github.com/celestiaorg/celestia-node/header/headertest	2.866s

---

go test -run=^$ -bench=. ./share/shwap                 
goos: darwin
goarch: arm64
pkg: github.com/celestiaorg/celestia-node/share/shwap
cpu: Apple M4
BenchmarkRowValidate-10       	   37148	     32432 ns/op
BenchmarkSampleValidate-10    	 1000000	      1137 ns/op
PASS
ok  	github.com/celestiaorg/celestia-node/share/shwap	3.656s

After:

go test -run=^$ -bench=. ./blob       
goos: darwin
goarch: arm64
pkg: github.com/celestiaorg/celestia-node/blob
cpu: Apple M4
BenchmarkGetByCommitment-10    	    6092	    195211 ns/op	 1053908 B/op	    3418 allocs/op
PASS
ok  	github.com/celestiaorg/celestia-node/blob	3.558s


---

go test -run=^$ -bench=. ./header/headertest    
goos: darwin
goarch: arm64
pkg: github.com/celestiaorg/celestia-node/header/headertest
cpu: Apple M4
BenchmarkMsgID-10    	   59661	     20424 ns/op	  165957 B/op	     593 allocs/op
PASS
ok  	github.com/celestiaorg/celestia-node/header/headertest	2.491s

---


 go test -run=^$ -bench=. ./share/shwap  
goos: darwin
goarch: arm64
pkg: github.com/celestiaorg/celestia-node/share/shwap
cpu: Apple M4
BenchmarkRowValidate-10       	   35263	     33798 ns/op
BenchmarkSampleValidate-10    	  996700	      1180 ns/op
PASS
ok  	github.com/celestiaorg/celestia-node/share/shwap	3.404s


@github-actions github-actions bot added the external Issues created by non node team members label Oct 17, 2025
@suranmiao
Copy link
Author

@renaynay @Wondertan Hi, Could you please review this PR at your convenience? Thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external Issues created by non node team members

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant