Skip to content

bug: Genesis imports degradation #2350

@jhernandezb

Description

@jhernandezb

During testing and improving of genesis imports/exports I have identified a bottleneck in how genesis imports of contract state is happening specially when there is half million contract instances being imported

Specifically the import of historicalEntries creating unnecessary amount of iterators creating a lot of cpu usage and contention

// find last element position
var pos uint64
prefixStore := prefix.NewStore(runtime.KVStoreAdapter(store), types.GetContractCodeHistoryElementPrefix(contractAddr))
iter := prefixStore.ReverseIterator(nil, nil)
defer iter.Close()

the appendToContractHistory can avoid entirely the creation of unnecessary iterators if we assume the entire history has been passed for insertion (there is no pre-existing position as it is the case for a genesis import)

I've ran a patched version jhernandezb@0c31fbc

Let me know if it is ok to submit similar patch

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions