Skip to content

Commit

Permalink
core: preallocate batch size in bloomIndexer (ethereum#25289)
Browse files Browse the repository at this point in the history
This change reduces allocations when committing bloombits indexes
by creating the database batch with a larger initial size.
  • Loading branch information
dbadoy authored and blakehhuynh committed Oct 7, 2022
1 parent 63c30d5 commit 487a622
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion core/bloom_indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (b *BloomIndexer) Process(ctx context.Context, header *types.Header) error
// Commit implements core.ChainIndexerBackend, finalizing the bloom section and
// writing it out into the database.
func (b *BloomIndexer) Commit() error {
batch := b.db.NewBatch()
batch := b.db.NewBatchWithSize((int(b.size) / 8) * types.BloomBitLength)
for i := 0; i < types.BloomBitLength; i++ {
bits, err := b.gen.Bitset(uint(i))
if err != nil {
Expand Down

0 comments on commit 487a622

Please sign in to comment.