You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Because the current implementation of KVStates is a dedicated VirtualMap, it is straightforward to implement Store.size() methods like this one as here:
@Override
public long sizeOfState() {
return tokenState.size();
}
As all state is consolidated into one VirtualMap (aka MegaMap), the effort of preserving the OnDiskKVState.size() method will no longer be a good cost/benefit ratio. This means Stores need a new implementation of their e.g. sizeOfState() methods.
Solution
Add a new singleton ENTITY_COUNTS state in EntityIdService that has a field (e.g. uint64 num_accounts or uint64 num_bytecodes) for each type of entity.
Add a 0.59-only step in SystemSetup.doPostUpgradeSetup() that initializes all these counts using direct calls to KVState.size() for every K/V state used by every service.
Update the WritableEntityIdStore API to "vend" entity id numbers by type, so that each time a service wants to create a new entity of a certain type, the EntityIdService can increment the correct ENTITY_COUNTS field.
Replace all Store.sizeOfState() implementations by getting a ReadableEntityIdStore and returning its e.g. numAccounts() or numBytecodes() getter as appropriate.
Switch StoreMetrics.updateCount() callbacks to be done by a StateChangeListener with stateTypes() == Set.of(SINGLETON) instead of in OnDiskWritableKVState.
Mark KVState.size() as deprecated and ensure there are no remaining non-test usages of this API.
Testing
Unit tests
Load a state and validate the counts are correctly updating in Entity_Counts map
All existing tests should pass
The text was updated successfully, but these errors were encountered:
Problem
Because the current implementation of
KVState
s is a dedicatedVirtualMap
, it is straightforward to implementStore.size()
methods like this one as here:As all state is consolidated into one
VirtualMap
(aka MegaMap), the effort of preserving theOnDiskKVState.size()
method will no longer be a good cost/benefit ratio. This meansStore
s need a new implementation of their e.g.sizeOfState()
methods.Solution
ENTITY_COUNTS
state inEntityIdService
that has a field (e.g.uint64 num_accounts
oruint64 num_bytecodes
) for each type of entity.SystemSetup.doPostUpgradeSetup()
that initializes all these counts using direct calls toKVState.size()
for every K/V state used by every service.WritableEntityIdStore
API to "vend" entity id numbers by type, so that each time a service wants to create a new entity of a certain type, theEntityIdService
can increment the correctENTITY_COUNTS
field.Store.sizeOfState()
implementations by getting aReadableEntityIdStore
and returning its e.g.numAccounts()
ornumBytecodes()
getter as appropriate.StoreMetrics.updateCount()
callbacks to be done by aStateChangeListener
withstateTypes() == Set.of(SINGLETON)
instead of inOnDiskWritableKVState
.KVState.size()
as deprecated and ensure there are no remaining non-test usages of this API.Testing
Entity_Counts
mapThe text was updated successfully, but these errors were encountered: