mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 19:50:36 +00:00
d370ea7ac2
Here is my case: writeIndex function takes about 39% in pprof flame graph. I dive into it and find out that we use POA consensus, therefore mining addresses have a big bitmap. ``` func writeIndex(blocknum uint64, changes *historyv2.ChangeSet, bucket string, changeDb kv.RwTx) error { buf := bytes.NewBuffer(nil) for _, change := range changes.Changes { k := dbutils.CompositeKeyWithoutIncarnation(change.Key) index, err := bitmapdb.Get64(changeDb, bucket, k, math.MaxUint32, math.MaxUint32) if err != nil { return fmt.Errorf("find chunk failed: %w", err) } index.Add(blocknum) if err = bitmapdb.WalkChunkWithKeys64(k, index, bitmapdb.ChunkLimit, func(chunkKey []byte, chunk *roaring64.Bitmap) error { buf.Reset() if _, err = chunk.WriteTo(buf); err != nil { return err } return changeDb.Put(bucket, chunkKey, common.CopyBytes(buf.Bytes())) }); err != nil { return err } } return nil } ``` assume that a mining address has a big bitmap (Cardinality 400000), then "writeIndex" will split it into 300 small bitmaps according to ”ChunkLimit“ and next time "writeIndex" will union all small bitmaps into a big bitmap, then use binary search to split it into 300 small bitmaps. over and over again. I think blockNum > index.Maximum(), so that we only need get the last one of 300 small bitmaps . Co-authored-by: mengweifu <75886642@qq.com> |
||
---|---|---|
.. | ||
contracts | ||
historyv2read | ||
temporal | ||
access_list_test.go | ||
access_list.go | ||
cached_reader2.go | ||
cached_reader.go | ||
cached_writer.go | ||
change_set_writer.go | ||
database_test.go | ||
database.go | ||
db_state_reader.go | ||
db_state_writer.go | ||
dump.go | ||
helper.go | ||
history_reader_inc.go | ||
history_reader_v3.go | ||
history_test.go | ||
history_walk.go | ||
intra_block_state_test.go | ||
intra_block_state.go | ||
journal.go | ||
plain_readonly.go | ||
plain_state_reader.go | ||
plain_state_writer.go | ||
recon_state.go | ||
recon_writer_inc.go | ||
rw_v3.go | ||
state_object_test.go | ||
state_object.go | ||
state_test.go | ||
transient_storage.go |