Skip to content

Fix Parallel verification issues (v2)#1423

Closed
shargon wants to merge 9 commits intoneo-project:masterfrom
shargon:fix-parallel-II
Closed

Fix Parallel verification issues (v2)#1423
shargon wants to merge 9 commits intoneo-project:masterfrom
shargon:fix-parallel-II

Conversation

@shargon
Copy link
Copy Markdown
Member

@shargon shargon commented Jan 17, 2020

Close #1420

Alternative of #1417

cloud8little
cloud8little previously approved these changes Jan 20, 2020
Copy link
Copy Markdown
Contributor

@cloud8little cloud8little left a comment

Choose a reason for hiding this comment

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

Test Passed. Wallet with 10000 neo, 500 gas, send rpc (sendtoaddress)requests for 2 times, one with 400 parrallel threads. finally, 493 tx are dealt with, and the balance is consistent with the result without this PR.
Kindly let me know if you want other user scenarios involved.

eryeer
eryeer previously approved these changes Jan 21, 2020
@shargon shargon dismissed stale reviews from eryeer and cloud8little via eddaa04 January 21, 2020 09:25
@shargon
Copy link
Copy Markdown
Member Author

shargon commented Jan 21, 2020

with the result without this PR.

Are you be able to reproduce the issue?

reason = RelayResultReason.OutOfMemory;
else if (parallelVerified.ShouldRelay)
system.LocalNode.Tell(new LocalNode.RelayDirectly { Inventory = parallelVerified.Transaction });
reason = parallelVerified.Transaction.VerifyForEachBlock(currentSnapshot, MemPool.SendersFeeMonitor.GetSenderFee(parallelVerified.Transaction.Sender));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

            if (hashes.Length != Witnesses.Length) return RelayResultReason.Invalid;
            for (int i = 0; i < hashes.Length; i++)
            {
                if (Witnesses[i].VerificationScript.Length > 0) continue;
                if (snapshot.Contracts.TryGet(hashes[i]) is null) return RelayResultReason.Invalid;
            }

Maybe some of these could be avoided, at least the first line.
But it is a just a minor thing.

I am not sure if the snapshot could contain a previous contract that is now deleted.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

If we remove the first line, we can have an exception

@cloud8little
Copy link
Copy Markdown
Contributor

@shargon @eryeer Here is the TPS result for comparing #1423 (parallel thread verification) and #1429 (single thread verification), it shows tps with parallel thread verification is nearly double of single thread verification:

Test Env:
OS: Windows 10 X64
CPU: Intel(R) Core(TM) i3-6006U 2Core
RAM: 12GB

Test Condition:
Transaction send speed: 2000 tx/s
Consensus node number: 1
Transaction sender node number: 1
Block time: 15s

Total Tx: 1000,000txs

Test Result:

Parallel thread verification TPS: 532
Single thread verification TPS:  287

Test Env:
OS: Linux Red Hat 4.8.5-36
CPU: Intel Core Processor (Skylake) 16 Core
RAM: 16G

Test Condition:
Transaction send speed: 2000 tx/s
Consensus node number: 1
Transaction sender node number: 1
Block time: 15s

Total Tx: 500,000txs

Test Result:

Parallel thread verification TPS: 1529
Single thread verification TPS:  728

@shargon
Copy link
Copy Markdown
Member Author

shargon commented Feb 6, 2020

Good to know! @cloud8little thanks!

@shargon shargon requested a review from eryeer February 11, 2020 13:17
@superboyiii
Copy link
Copy Markdown
Member

@erikzhang Could you approve it? Test is OK.

reason = RelayResultReason.OutOfMemory;
else if (parallelVerified.ShouldRelay)
system.LocalNode.Tell(new LocalNode.RelayDirectly { Inventory = parallelVerified.Transaction });
reason = parallelVerified.Transaction.VerifyForEachBlock(currentSnapshot, MemPool.SendersFeeMonitor.GetSenderFee(parallelVerified.Transaction.Sender));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we remove L410?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think no. We need to check the L410 line in advance to avoid wasting resources on parallel VerifyWitness for unqualified transactions.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I am not sure, we save resource in certain cases and waste in other, we should check what it will be more usual.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Perhaps reverting to single-threaded mode is currently the best option.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This was this alternative #1429 but the speed it's lower

@erikzhang erikzhang closed this Mar 3, 2020
@shargon shargon deleted the fix-parallel-II branch March 3, 2020 07:14
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.

Parallel verification issues

6 participants