Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(swarm): eliminating protocol cloning when nothing is happening
Code keeps the API while eliminating repetitive protocol cloning when protocols did not change, If protocol changes occur, only then the protocols are cloned to a reused buffer from which they are borrowed for iteration. Following are benchmark results: |behaviour count|iterations|protocols|timings|change*| |-|-|-|-|-| |1|1000|10|27.798 µs 28.134 µs 28.493 µs|-15.771% -14.523% -13.269%| |1|1000|100|55.171 µs 55.578 µs 56.009 µs|-51.831% -50.162% -48.437%| |1|1000|1000|289.24 µs 290.99 µs 293.00 µs|-61.748% -60.895% -60.054%| |5|1000|2|34.000 µs 34.216 µs 34.457 µs|-18.538% -16.231% -14.011%| |5|1000|20|70.962 µs 71.428 µs 72.005 µs|-40.501% -38.944% -37.309%| |5|1000|200|426.17 µs 433.27 µs 442.60 µs|-44.824% -42.663% -40.262%| |10|1000|1|42.993 µs 44.382 µs 45.655 µs|-18.839% -16.292% -13.584%| |10|1000|10|94.022 µs 96.787 µs 99.321 µs|-25.469% -23.572% -21.562%| |10|1000|100|543.13 µs 554.91 µs 569.06 µs|-43.781% -42.189% -40.568%| |20|500|1|63.150 µs 64.846 µs 66.860 µs|-9.5693% -6.1722% -2.6400%| |20|500|10|212.21 µs 217.48 µs 222.64 µs|-16.525% -14.234% -11.925%| |20|500|100|1.6651 ms 1.7083 ms 1.7490 ms|-27.704% -25.683% -23.618%| change*: 3da7d91 is the baseline Pull-Request: libp2p#5026.
- Loading branch information