-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Background
Processing most alerts is a trivial resource burden, with the read_piece_alert being a significant exception. It requires copying a buffer owned by the libtorrent thread into the V8 memory space, often in the range of 0.1-0.5MB.
Problem
With a large number of torrents, all with thousands of pieces, this can get very expensive. In particular in combination with the extension in https://github.com/JoyStream/joystream-node it gets worse, as the alert will arrive for each time we want to read a piece for seeding, which may be happening to many peers on a single torrent.
The only reason libtorrent itself does not need to offer such control is because it does not automatically copy the content from the libtorrent thread to the user thread, however these bindings do.
The only scenario it really makes sense to process this alert in these bindings is when consuming the actual content in nodejs is relevant, which is pretty much only of some sort of streaming playback is being done at the nodejs application level.
Solution
Some way of controlling whether this alert should be processed on a given torrent at any given time.