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 committed Aug 3, 2022
1 parent 6b6261b commit 5fb463d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion core/bloom_indexer.go
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 5fb463d

Please sign in to comment.