Skip to content

Batch convert commitments/proofs to bytes#626

Open
jtraglia wants to merge 4 commits intoethereum:mainfrom
jtraglia:batch-convert-proofs-to-bytes
Open

Batch convert commitments/proofs to bytes#626
jtraglia wants to merge 4 commits intoethereum:mainfrom
jtraglia:batch-convert-proofs-to-bytes

Conversation

@jtraglia
Copy link
Member

In compute_cells_and_kzg_proofs, converting proofs to bytes in batch is 3.44% faster with precompute=8.

Before:

$ go clean -cache && GOMAXPROCS=1 go test -test.bench=Benchmark/ComputeCellsAndKZGProofs -test.run=^$ ./bindings/go 
goos: darwin
goarch: arm64
pkg: github.com/ethereum/c-kzg-4844/v2/bindings/go
cpu: Apple M1
Benchmark/ComputeCellsAndKZGProofs(precompute=0)                       4         263398458 ns/op
Benchmark/ComputeCellsAndKZGProofs(precompute=1)                       2         908959958 ns/op
Benchmark/ComputeCellsAndKZGProofs(precompute=2)                       3         488505694 ns/op
Benchmark/ComputeCellsAndKZGProofs(precompute=3)                       3         350817750 ns/op
Benchmark/ComputeCellsAndKZGProofs(precompute=4)                       4         277039625 ns/op
Benchmark/ComputeCellsAndKZGProofs(precompute=5)                       5         240792967 ns/op
Benchmark/ComputeCellsAndKZGProofs(precompute=6)                       5         213914367 ns/op
Benchmark/ComputeCellsAndKZGProofs(precompute=7)                       6         198406333 ns/op
Benchmark/ComputeCellsAndKZGProofs(precompute=8)                       6         184162486 ns/op
Benchmark/ComputeCellsAndKZGProofsParallel(count=8)                    4         289445594 ns/op
PASS
ok      github.com/ethereum/c-kzg-4844/v2/bindings/go   96.002s

After:

$ go clean -cache && GOMAXPROCS=1 go test -test.bench=Benchmark/ComputeCellsAndKZGProofs -test.run=^$ ./bindings/go
goos: darwin
goarch: arm64
pkg: github.com/ethereum/c-kzg-4844/v2/bindings/go
cpu: Apple M1
Benchmark/ComputeCellsAndKZGProofs(precompute=0)                       4         260788177 ns/op
Benchmark/ComputeCellsAndKZGProofs(precompute=1)                       2         901798042 ns/op
Benchmark/ComputeCellsAndKZGProofs(precompute=2)                       3         479930694 ns/op
Benchmark/ComputeCellsAndKZGProofs(precompute=3)                       3         344812153 ns/op
Benchmark/ComputeCellsAndKZGProofs(precompute=4)                       4         274845333 ns/op
Benchmark/ComputeCellsAndKZGProofs(precompute=5)                       5         237340850 ns/op
Benchmark/ComputeCellsAndKZGProofs(precompute=6)                       5         210313592 ns/op
Benchmark/ComputeCellsAndKZGProofs(precompute=7)                       6         193029160 ns/op
Benchmark/ComputeCellsAndKZGProofs(precompute=8)                       6         177826458 ns/op
Benchmark/ComputeCellsAndKZGProofsParallel(count=8)                    4         268851688 ns/op
PASS
ok      github.com/ethereum/c-kzg-4844/v2/bindings/go   93.767s

Copy link
Contributor

@b-wagn b-wagn left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@kevaundray kevaundray left a comment

Choose a reason for hiding this comment

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

LGTM.

I wonder if we can do the same in recover_cells_and_kzg_proofs

@jtraglia
Copy link
Member Author

I wonder if we can do the same in recover_cells_and_kzg_proofs

@kevaundray Ah I was too focused on speeding up compute_cells_and_kzg_proofs. Yes, we can do this (batch conversions) in two other places. I've just pushed two commits for this, please re-review.

Copy link
Contributor

@kevaundray kevaundray left a comment

Choose a reason for hiding this comment

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

LGTM ser

@jtraglia jtraglia changed the title Batch convert cell proofs to bytes Batch convert commitments/proofs to bytes Feb 25, 2026
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.

3 participants