-
Notifications
You must be signed in to change notification settings - Fork 809
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fatxpool
: do not use individual transaction listeners (#7316)
#### Description During 2s block investigation it turned out that [ForkAwareTxPool::register_listeners](https://github.com/paritytech/polkadot-sdk/blob/master/substrate/client/transaction-pool/src/fork_aware_txpool/fork_aware_txpool.rs#L1036) call takes significant amount of time. ``` register_listeners: at HashAndNumber { number: 12, hash: 0xe9a1...0b1d2 } took 200.041933ms register_listeners: at HashAndNumber { number: 13, hash: 0x5eb8...a87c6 } took 264.487414ms register_listeners: at HashAndNumber { number: 14, hash: 0x30cb...2e6ec } took 340.525566ms register_listeners: at HashAndNumber { number: 15, hash: 0x0450...4f05c } took 405.686659ms register_listeners: at HashAndNumber { number: 16, hash: 0xfa6f...16c20 } took 477.977836ms register_listeners: at HashAndNumber { number: 17, hash: 0x5474...5d0c1 } took 483.046029ms register_listeners: at HashAndNumber { number: 18, hash: 0x3ca5...37b78 } took 482.715468ms register_listeners: at HashAndNumber { number: 19, hash: 0xbfcc...df254 } took 484.206999ms register_listeners: at HashAndNumber { number: 20, hash: 0xd748...7f027 } took 414.635236ms register_listeners: at HashAndNumber { number: 21, hash: 0x2baa...f66b5 } took 418.015897ms register_listeners: at HashAndNumber { number: 22, hash: 0x5f1d...282b5 } took 423.342397ms register_listeners: at HashAndNumber { number: 23, hash: 0x7a18...f2d03 } took 472.742939ms register_listeners: at HashAndNumber { number: 24, hash: 0xc381...3fd07 } took 489.625557ms ``` This PR implements the idea outlined in #7071. Instead of having a separate listener for every transaction in each view, we now use a single stream of aggregated events per view, with each stream providing events for all transactions in that view. Each event is represented as a tuple: (transaction-hash, transaction-status). This significantly reduce the time required for `maintain`. #### Review Notes - single aggregated stream, provided by the individual view delivers events in form of `(transaction-hash, transaction-status)`, - `MultiViewListener` now has a task. This task is responsible for: - polling the stream map (which consists of individual view's aggregated streams) and the `controller_receiver` which provides side-channel [commands](https://github.com/paritytech/polkadot-sdk/blob/2b18e080cfcd6b56ee638c729f891154e566e52e/substrate/client/transaction-pool/src/fork_aware_txpool/multi_view_listener.rs#L68-L95) (like `AddView` or `FinalizeTransaction`) sent from the _transaction pool_. - dispatching individual transaction statuses and control commands into the external (created via API, e.g. over RPC) listeners of individual transactions, - external listener is responsible for status handling _logic_ (e.g. deduplication of events, or ignoring some of them) and triggering statuses to external world (_this was not changed_). - level of debug messages was adjusted (per-tx messages shall be _trace_), Closes #7071 --------- Co-authored-by: Sebastian Kunert <skunert49@gmail.com>
- Loading branch information
1 parent
37446fc
commit aa42deb
Showing
14 changed files
with
740 additions
and
606 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.