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

Optimization summary #1324

Closed
5 of 7 tasks
Tommo-L opened this issue Dec 4, 2019 · 0 comments
Closed
5 of 7 tasks

Optimization summary #1324

Tommo-L opened this issue Dec 4, 2019 · 0 comments
Labels
discussion Initial issue state - proposed but not yet accepted

Comments

@Tommo-L
Copy link
Contributor

Tommo-L commented Dec 4, 2019

This is an open discussion issue, which summarizes the optimization work in the past and some ideas for the next step. More suggestions and new ideas are needed for further optimization. We are willing to provide more details of the data for your reference. And we will keep updating this post to include further ideas.

Goal

  • increase TPS
  • Increase network transmission stability and security
  • Improve smart contract execution efficiency

Introduction

Over the past few months, @neo-project/core, @neo-project/ngd-shanghai have done a lot of work regarding optimization. At present, in our experimental environment, the peak value of TPS has reached 2100/s. It is hoped that there can be greater breakthroughs and improvements in the future to lay a solid foundation to support large-scale commercial applications.

At present, we adhere to the following methodologies: Benchmark-> Locate Bottlenecks-> Optimization / New Design .

There are four modules having a relatively large impact on performance, including memory pool, P2P, consensus and VM. For each module, we have summarized the possible performance issues and list the optimizations that have been completed or in progress. Besides, we also list some potential optimization ideas and would like to further discuss or design about them.

The following figure is a summary of the time consumption of all current methods:

neo-optimization-issue

Tips:

  1. Those marked yellow are optimizations which has been implemented.
  2. Those marked orange are sessions take long time which need to be optimized.

Memory Pool

It takes a lot of time to enter the memory pool in the process of transactions , which mainly includes two processes:

  1. Verification before the transaction entering the memory pool, such as whether the balance is sufficient, set operations, and verify the signature.
  2. When the new block comes in, there will be a reverification of the memory pool transactions, which is caused by the following reasons and takes about 2 seconds.
  • Change in balance
  • Frozen account changes
  • Contract changes

In Progress

  • Parallel verification transaction
  • Keeping track of sender fee in memory pool

P2P

Currently we have more discussion on github regarding network optimization, including great suggestions from @decentralisedkev @ixje @jsolman @yongjiema @shagron @vncoelho @igormcoelho , etc., in fast synchronization, stability, and security.

In Progress

Open discussion

Consensus

Although the current bottleneck is not consensus mechanism, however, when there are a large number of transactions, frequent ChangeView phenomenon is prone to occur, resulting in slower block generation.

The other issue is the adjustment of the block generation time. When the TPS is improved, it is necessary to find a more suitable block generation time.

Open discussion

  • How to improve the efficiency of consensus execution and reduce the frequency of ChangeView

    • Possible solution 1: Change the serial block generation to the pipeline block generation mechanism (both neo-go and @vncoelho have tried)
  • Setting a reasonable block generation time and and the maximum number of transactions in a block

  • Faster new consensus mechanism with more nodes, such as sharding, new consensus algorithms, etc.

VM

The execution process of the VM is another time-consuming session, especially in VM instruction execution, interoperable services, and serial execution of transactions.

At present, each transfer usually takes 0.2 milliseconds, which is relatively time-consuming.

In Progress

  • Optimizing the ContractManifest.Clone method in System.Contract.Call to avoid deep copying

Open discussion


In the process of optimization, we found that some code is not efficient, resulting in performance degradation. We think the following measures can help optimization.

  • Using the space-for-time algorithm. The memory can be expanded by hardware, such as using HashSet instead of array traversal
  • Caching calculated data, such as the Size field in transactions, calculated from serialized data, which is very time-consuming
  • Using efficient processing syntax, like @shargon mentioned, avoid Linq, replace List with Array, etc.
  • Parallel processing where possible, such as transaction signature verification
@Tommo-L Tommo-L added the discussion Initial issue state - proposed but not yet accepted label Dec 4, 2019
@Tommo-L Tommo-L changed the title [Opimitzation] Design, Discussion and Implementation Optimization summary Dec 4, 2019
@Tommo-L Tommo-L closed this as completed Feb 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Initial issue state - proposed but not yet accepted
Projects
None yet
Development

No branches or pull requests

1 participant