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

(Fix) Improve performance when big list of sent transactions from account #67

Merged
merged 2 commits into from
Aug 8, 2018

Conversation

patitonar
Copy link

Relates to #51

When there is an update on the state of the extension, background script sends the full updated state to the UI using RPC. That process involves iterating over every attribute for parsing the object, and when there are a lot of transactions (the 40 last transactions are stored as max) it blocks the thread causing slow render and responses on UI interaction. I was able to find that by profiling the extension using chrome developer tools.

Here is an example of a profile of an Account with 40 transactions on the list: profileNiftyWallet.zip
privatesendupdatebefore

In this example the privateSendUpdate function took more than a second to emit the state.
https://github.com/poanetwork/metamask-extension/blob/e03ecbfff2415be5d5d6a5b928114f04a1b7b4d4/app/scripts/metamask-controller.js#L1283-L1289
Here is the generated state of this example which stored in a json file size is 337,8 kb exampleState.zip

I identified that there were some parts of the state that weren't being used by the UI so I filtered them from being send to UI to improve the performance.

Information that is no longer being send to UI:

  • Last 40 blocks related information.
  • For every transaction: UI history and nonce related information.

After that changes, a json file with the state has a size of 44,2 kb newExampleState.zip

Here is an example of a new profile after the changes where privateSendUpdate function time was reduced. profileImproved.zip

privatesendupdateafter

Please test this solution to know if it is good enough, if not, maybe there is still place to reduce the state sent to UI or discuss any other alternatives.

Copy link
Collaborator

@vbaranov vbaranov left a comment

Choose a reason for hiding this comment

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

@patitonar tested with the creation of multi-tiered crowdsale in Token Wizard. NW popup visually appears faster, than in MM, with full stack of transactions (40) in the list. In Chrome dev console privateSendUpdate emits state roughly 10x faster on average, than in current release of NW, MM or MM Beta. I didn't find any regression tests issues. Great catch!

@vbaranov vbaranov merged commit 44456df into develop Aug 8, 2018
@ghost ghost removed the awaiting for review label Aug 8, 2018
@vbaranov vbaranov deleted the performance-big-list-transactions-#51 branch August 8, 2018 14:46
@vbaranov vbaranov mentioned this pull request Aug 9, 2018
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.

3 participants