1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00
metamask-extension/test/unit/app
Whymarrh Whitby c7fad8f400
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
2020-07-16 17:52:41 -02:30
..
controllers Limit number of transactions passed outside of TransactionController (#9010) 2020-07-16 17:52:41 -02:30
account-import-strategies.spec.js Update ESLint rules for test suite (#8023) 2020-02-11 13:21:13 -03:30
buy-eth-url.spec.js Update Wyre ETH purchase url (#8051) 2020-02-14 14:07:24 -08:00
cleanErrorStack.spec.js Update ESLint rules for test suite (#8023) 2020-02-11 13:21:13 -03:30
ComposableObservableStore.js Update ESLint rules for test suite (#8023) 2020-02-11 13:21:13 -03:30
fetch-with-timeout.test.js Enable arrow-parens ESLint rule 2020-02-15 17:04:21 -03:30
message-manager-test.js Migrate codebase to use ESM (#7730) 2020-01-09 00:04:58 -03:30
nodeify-test.js Update mocha version (#8028) 2020-02-12 14:47:36 -03:30
personal-message-manager-test.js Migrate codebase to use ESM (#7730) 2020-01-09 00:04:58 -03:30
seed-phrase-verifier-test.js Replace clone dependency with cloneDeep from lodash (#7926) 2020-01-29 13:14:33 -04:00
typed-message-manager.spec.js Update ESLint rules for test suite (#8023) 2020-02-11 13:21:13 -03:30
util-test.js Update ESLint rules for test suite (#8023) 2020-02-11 13:21:13 -03:30