ChainSafe / js-libp2p-gossipsub

TypeScript implementation of Gossipsub
Apache License 2.0
151 stars 43 forks source link

Use PushableAbortable #434

Closed dapplion closed 9 months ago

dapplion commented 1 year ago

Motivation

In high traffic apps like a beacon node, abortableSource takes +1% of total CPU time.

Description

This PR removes the need for one loop of abortableSource in each outbound packet. Uses a simplified implementation of pushable with abort capacity using Lodestar's LinkedList https://github.com/ChainSafe/lodestar/blob/09ecf9957c33c3bdf79645dbd27979bdb0514c56/packages/beacon-node/src/util/array.ts#L32 and AsyncIterator from https://github.com/ChainSafe/lodestar/blob/09ecf9957c33c3bdf79645dbd27979bdb0514c56/packages/beacon-node/src/util/asyncIterableToEvents.ts#L53

wemeetagain commented 1 year ago

We might wait for https://github.com/libp2p/js-libp2p/issues/1793#issue-1741818809 (check last few paragraphs of the comment) to be implemented which will give us abortable sources at a lower level.

wemeetagain commented 9 months ago

closing in favor of #488