-
Notifications
You must be signed in to change notification settings - Fork 146
Support column families in kvt txFrame API and use for contract code #3765
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…n family for reading and storing code.
I ran a block import benchmark on the first 10 million mainnet blocks. Here are the results:
Unfortunately, there doesn't appear to be any performance improvement from this change. Perhaps the overhead of the additional kvts is more significant then any potential speed up from using the additional column families. |
Additional column families are expensive to manage and cause the WAL to expand - in general, "common prefixes" in keys are almost free (the prefix is stored separately) so the prefix strategy is to be preferred unless different column family options are needed and a few other special cases (like txframe lifetime). |
Contract code is interesting in that it has slightly different lifetime properties than other transaction data: it is shared between accounts - this makes its lifetime management slightly different from that of block data for example. |
This PR updates the KVT txFrame API to support multiple column families and also introduces and uses separate column families for contract code and witnesses.
For performance reasons the kvts are stored in an array indexed by the column family enum type. The
KvtCfs
enum type is renamed toKvtType
and moved so that it can be exposed as part of the CoreDb API in the base module. When aKvtType
is not specified then the defaultKvtType.Generic
is used.When using column families the data is partitioned into a separate space so the
DBKeyKind
key mapping functions in thestorage_types
module are no longer required for the contract code and witness reads and writes.This changes the structure of the database on disk and is therefore not backwards compatible meaning that after this change is merged then all nodes will require a full re-sync.