mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-27 12:56:01 +01:00
c7fad8f400
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]:
|
||
---|---|---|
.. | ||
pending-tx-tracker-test.js | ||
tx-controller-test.js | ||
tx-gas-util-test.js | ||
tx-helper-test.js | ||
tx-state-history-helpers-test.js | ||
tx-state-manager-test.js | ||
tx-utils-test.js |