Remove Manifest Clone in ContractState#1326
Closed
eryeer wants to merge 2 commits intoneo-project:masterfrom
eryeer:pr_optimse_CountractState
Closed
Remove Manifest Clone in ContractState#1326eryeer wants to merge 2 commits intoneo-project:masterfrom eryeer:pr_optimse_CountractState
eryeer wants to merge 2 commits intoneo-project:masterfrom
eryeer:pr_optimse_CountractState
Conversation
erikzhang
requested changes
Dec 5, 2019
Member
erikzhang
left a comment
There was a problem hiding this comment.
The SYSCALL Neo.Contract.Update can update the manifest of the contract. So we can't remove the Clone().
Contributor
|
If only replace the reference of Only when the fields of manifest were modified, we need deep copy to protect the original data. |
Member
|
Please test #1328 to check if it has been optimized. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After performance testing, we found that when the NEO / GAS transfer transaction was executed in the block
Persist, the average time was 0.3ms, and about 0.1-0.2ms of it was spent on theClone()of the ContractState Manifest. The Clone() is invoked byengine.Snapshot.Contracts.TryGet()of InteropServiceContract_Callneo/src/neo/SmartContract/InteropService.cs
Line 478 in afec99a
Since Contracts is a CloneCache, when calling TryGetInternal(), the ContractState will clone another copy including the
Manifestas well.Considering that
Manifestwill not be modified if the snapshot is not committed, and the transaction is executed sequentially, so if the Manifest is used in the transaction execution process, it will not interfere with each other. So consider removingClone()to improve speed.