libtorrent icon indicating copy to clipboard operation
libtorrent copied to clipboard

update auto piece size calculation

Open Audionut opened this issue 4 months ago • 5 comments

The existing code has a hard defined limit of 8 MiB,.

This PR iterates through the piece sizes, up to 128 MiB piece size, to keep the piece count between 1000 and 2000.

Audionut avatar Aug 23 '25 10:08 Audionut

I would significantly reduce the initial value, from 300.

stalkerok avatar Aug 26 '25 13:08 stalkerok

what's the motivation for this change? I imagine you want the .torrent file to be smaller, but it has to be weight against the performance of swarm as well, right?

arvidn avatar Sep 07 '25 14:09 arvidn

also, some torrent clients don't support piece sizes of 16 MB or greater

arvidn avatar Sep 07 '25 14:09 arvidn

To maintain performant piece counts without arbitrary limits.

If piece count was irrelevant, then a fixed size should be defined, reducing code clutter and uncertainty.

I am not aware of any relatively modern client having a 16 MiB piece size limit, nor am I sure why overall swarm performance should be limited because of 1 or 2 clients, that would seemingly wish to maintain updated libtorrent, but not also update their end, to support codebase changes.

Audionut avatar Sep 07 '25 14:09 Audionut

To maintain performant piece counts without arbitrary limits.

Please elaborate

I would expect performance to suffer from larger pieces, since you need to download more before you can start uploading.

arvidn avatar Sep 07 '25 18:09 arvidn