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 HanWang233 committed Sep 11, 2022
1 parent 3d63ba3 commit 58308be
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 58308be

Please sign in to comment.