From 5fb463dddc928eec38de80f63ebdd9d7820d1a72 Mon Sep 17 00:00:00 2001 From: Seungbae Yu Date: Thu, 4 Aug 2022 00:02:09 +0900 Subject: [PATCH] core: preallocate batch size in bloomIndexer (#25289) This change reduces allocations when committing bloombits indexes by creating the database batch with a larger initial size. --- core/bloom_indexer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/bloom_indexer.go b/core/bloom_indexer.go index 856746a1c..68a35d811 100644 --- a/core/bloom_indexer.go +++ b/core/bloom_indexer.go @@ -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 {