Description
The current ProofBuilder is not thread-safe. There is a demand from personality applications to build the proof after the entries have merged into the tree. If there are 500 entries being merged in a batch, the application will then create 500 ProofBuilders fetching the same tiles from the storage and doing the hashing works again and again. This becomes the performance bottleneck which slows down the write QPS.
|
// NewProofBuilder creates a new ProofBuilder object for a given tree size. |
|
// The returned ProofBuilder can be re-used for proofs related to a given tree size, but |
|
// it is not thread-safe and should not be accessed concurrently. |
|
func NewProofBuilder(ctx context.Context, treeSize uint64, f TileFetcherFunc) (*ProofBuilder, error) { |
|
pb := &ProofBuilder{ |
|
treeSize: treeSize, |
|
nodeCache: newNodeCache(f, treeSize), |
|
} |
|
return pb, nil |
|
} |
A thread-safe ProofBuilder is needed to generate the proofs concurrently and effectively.
Description
The current
ProofBuilderis not thread-safe. There is a demand from personality applications to build the proof after the entries have merged into the tree. If there are 500 entries being merged in a batch, the application will then create 500ProofBuilders fetching the same tiles from the storage and doing the hashing works again and again. This becomes the performance bottleneck which slows down the write QPS.tessera/client/client.go
Lines 186 to 195 in 05ff747
A thread-safe
ProofBuilderis needed to generate the proofs concurrently and effectively.