Skip to content
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

Proper Locking During Block Persistence and Increase Performance while Syncing the Chain #237

Merged

Conversation

jsolman
Copy link
Contributor

@jsolman jsolman commented May 16, 2018

This change insures consistency of the mem_pool upon accepting and persisting a new block and it improves performance of block persistence. Performance is especially improved when syncing the chain in the case that there are a high number number of future transactions hanging around in the mem_pool.

Syncing from a recent chain.acc.zip file has been almost required in the past since syncing could get very slow without this fix if the chain file is rather old. This is because contention on the mem_pool lock from the AddTransactionLoop would block the block persistence thread when LocalNode.Blockchain_PersistCompleted is invoked.

This change will cancel transaction verification each time a new block is received and persisted. I tested syncing the chain, and observed significant performance improvement using these changes. Testing was performed on 2 cores of an Intel(R) Xeon(R) CPU E5-2676 v3 @ 2.40GHz using a disk provisioned at 300 minimum IOPS.

This pull request was originally here (#218), but I'm submitting again freshly from a new branch:


// Need to ensure any outstanding calls to Blockchain_PersistCompleted are not in progress.
// TODO: could add locking instead of using an arbitrarily long sleep here.
Thread.Sleep(3000);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have any plans to improve this place before this PR is merged?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I should be able to adjust this to obtain the new PersistLock now. I’ll adjust and test it and update the pull request.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be good now.

@jsolman jsolman mentioned this pull request May 17, 2018
@erikzhang erikzhang merged commit bdd11cd into neo-project:master May 18, 2018
lock9 pushed a commit to simplitech/neo that referenced this pull request Aug 3, 2018
Thacryba pushed a commit to simplitech/neo that referenced this pull request Feb 17, 2020
gui 2.3.5 need .net Framework 4.7.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants