-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Optimize OnPersist #3145
Comments
I vote for replace the |
There is no need to change the DB scheme and store duplicating data, just cache it. |
That's solve the node issue, but it won't solve external readers like rpc storage. |
@roman-khimov Or we can support seek backwards in rpc, and cache it in node :) https://github.com/neo-project/neo-devpack-dotnet/pull/904/files#r1491847096 |
It does support it, for iterators in contracts. |
@shargon what is the |
Currently, we store a history of gas changes, which is necessary for calculating the reward of accounts when they call claim, but it is not necessary for the |
@neo-project/core How to test? debug the node, and press F11 (step into) in |
We can also optimize with the same technique |
@neo-project/core @roman-khimov if we will need to resync the chain for 3.7, this is something to think about it, |
This problem is still not worth changing the DB scheme, caching solves it completely and it'd be faster than additional data in the DB anyway. |
And remove the nefFile from contractState? We only need the Script and tokens, and all the nefFile is deserialized in all contract calls, at least we can avoid the checksum check |
This would remove the symmetry of deploy/getcontract. We deploy NEF/manifest, we can expect to get them back the same way. We have a number of external interfaces that return NEFs as well, this change can break them. Deserialization optimization is OK. We actually have a contract cache in NeoGo, so we don't deserialize often. |
Vote up for cache usage instead of storage scheme change.
Could you explain, why? Because in our implementation a similar cache is available for external users via exported method (e.g. external consensus service uses https://github.com/nspcc-dev/neo-go/blob/71fb759c0d009218437d0048f7ba085a2a74c66f/pkg/core/native/native_neo.go#L1120 without any issues). We initialize this cache when needed (on node resume or test historic VM creation basically, ref. https://github.com/nspcc-dev/neo-go/blob/71fb759c0d009218437d0048f7ba085a2a74c66f/pkg/core/native/native_neo.go#L329), and it doesn't cost a lot. The only caveat is that we should keep it up-to-date and relevant, but it's possible. |
Developing the rpc storage in test engine (neo-project/neo-devpack-dotnet#904) I have realized how "expensive" it is to calculate the gas per block.
Currently, we store a history of gas changes, which is necessary for calculating the reward of accounts when they call claim, but it is not necessary for the
OnPersist
of the block. However, we iterate backwards to calculate it in the same way during the block's persist, something completely unnecessary.It can be optimized by avoiding iterating over the storage, we have 2 options.
Prefix_GasPerBlock
, I think it has never been done in any of the networks and can only be done by consensusOpinions?
The text was updated successfully, but these errors were encountered: