Skip to content

Commit

Permalink
core: preallocate batch size in bloomIndexer (#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 kyrie-yl committed Dec 14, 2022
1 parent b8cd3c9 commit 223b185
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 223b185

Please sign in to comment.