Limit number of transactions passed outside of TransactionController (#9010)
Refs #8572
Refs #8991
This change limits the number of transactions (`txMeta`s) that are passed
outside of the `TransactionController`, resulting in shorter serialization and
deserialization times when state is moved between the background and UI
contexts.
`TransactionController#_updateMemstore`
---------------------------------------
The `currentNetworkTxList` state of the `TransactionController` is used
externally (i.e. outside of the controller) as the canonical source for
the full transaction history. Prior to this change, the method would iterate
the full transaction history and possibly return all of it.
This change limits it to `MAX_MEMSTORE_TX_LIST_SIZE` to make sure that:
1. Calls to `_updateMemstore` are fast(er)
2. Passing `currentNetworkTxList` around is fast(er)
(Shown in #8377, `_updateMemstore`, is called _frequently_ when a transaction
is pending.)
The list is iterated backwards because it is possible that new transactions are
at the end of the list. [1]
Results
-------
In profiles before this change, with ~3k transactions locally,
`PortDuplexStream._onMessage` took up to ~4.5s to complete when the set of
transactions is included. [2]
In profiles after this change, `PortDuplexStream._onMessage` took ~90ms to
complete. [3]
Before vs. after profile screenshots:
![Profile 1][2]
![Profile 2][3]
[1]:5a3ae85b72/app/scripts/controllers/transactions/tx-state-manager.js (L172-L174)
[2]:https://user-images.githubusercontent.com/1623628/87613203-36f51d80-c6e7-11ea-89bc-11a1cc2f3b1e.png
[3]:https://user-images.githubusercontent.com/1623628/87613215-3bb9d180-c6e7-11ea-8d85-aff3acbd0374.png
[8337]:https://github.com/MetaMask/metamask-extension/issues/8377
[8572]:https://github.com/MetaMask/metamask-extension/issues/8572
[8991]:https://github.com/MetaMask/metamask-extension/issues/8991
feature/default_network_editable
parent
c8e50c6b15
commit
c7fad8f400
Loading…
Reference in new issue