(Fix) Improve performance when big list of sent transactions from account #67
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.
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
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:
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.zipPlease 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.