Skip to content

Commit 5fb463d

Browse files
authored
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.
1 parent 6b6261b commit 5fb463d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

core/bloom_indexer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func (b *BloomIndexer) Process(ctx context.Context, header *types.Header) error
7575
// Commit implements core.ChainIndexerBackend, finalizing the bloom section and
7676
// writing it out into the database.
7777
func (b *BloomIndexer) Commit() error {
78-
batch := b.db.NewBatch()
78+
batch := b.db.NewBatchWithSize((int(b.size) / 8) * types.BloomBitLength)
7979
for i := 0; i < types.BloomBitLength; i++ {
8080
bits, err := b.gen.Bitset(uint(i))
8181
if err != nil {

0 commit comments

Comments
 (0)