{"id":3469,"date":"2016-01-08T12:02:28","date_gmt":"2016-01-08T12:02:28","guid":{"rendered":"http:\/\/www.gubatron.com\/blog\/?p=3469"},"modified":"2016-01-08T12:05:10","modified_gmt":"2016-01-08T12:05:10","slug":"things-to-think-about-when-tuning-libtorrent-for-high-performance","status":"publish","type":"post","link":"https:\/\/www.gubatron.com\/blog\/things-to-think-about-when-tuning-libtorrent-for-high-performance\/","title":{"rendered":"Things to think about when tuning libtorrent for high performance"},"content":{"rendered":"<p>An user on the libtorrent mailing list had the following problem:<\/p>\n<blockquote><p>I&#8217;m doing some testing for a libtorrent application that will use a small number of peers (often just 1 seed and 1 downloaded) and high bandwidth delay product links (in the hundreds of Mb\/s and 100ms+ round trip). I&#8217;m unable to get more than 20Mbps with a single peer on a 140ms RTT link (simulated delay with no packet loss). If I take the network simulator delay down to 0, I can get almost a full 1000Mbps on the same system.  I&#8217;ve tried playing with everything that sounded relevant in session_settings, but nothing seems to make any improvement at all.<\/p>\n<p>Is this the best that can be expected out of uTP on a high latency link? Or is there some combination of parameters that would improve the single peer throughput? Alternatively, is there a way to get libtorrent to make multiple connections between the same 2 peers?<\/p><\/blockquote>\n<p>If you&#8217;re facing a similar situation here are some things you could adjust according to <a href=\"https:\/\/github.com\/arvidn\/\" target=\"_blank\">Arvid Norberg<\/a> lead engineer of the <a href=\"https:\/\/github.com\/arvidn\/libtorrent\" target=\"_blank\">libtorrent project<\/a>.<\/p>\n<p><strong>&#8220;Did you increase the socket buffer sizes on both ends?&#8221;<\/strong><\/p>\n<pre><code>int recv_socket_buffer_size;\nint send_socket_buffer_size;\n<\/code><\/pre>\n<p><strong>&#8220;There&#8217;s also buffer sizes at the bittorrent level:&#8221;<\/strong><\/p>\n<pre><code>int send_buffer_low_watermark;\nint send_buffer_watermark;\nint send_buffer_watermark_factor;\n<\/code><\/pre>\n<p><strong>&#8220;And there are buffers at the disk layer:&#8221;<\/strong><\/p>\n<pre><code>int max_queued_disk_bytes;\nint max_queued_disk_bytes_low_watermark;\n<\/code><\/pre>\n<p>If the performance issue happens with uTP but not TCP though, it&#8217;s probably<br \/>\njust the first ones that matters.<\/p>\n<p>Also, the uTP implementation needs a system call for each packet sent and<br \/>\nreceived (i.e. it does not use sendmmsg()\/recvmmsg()) which also makes it<br \/>\nmore expensive than TCP, but that would primarily cause additional CPU<br \/>\nusage, and only slow-downs once a CPU core is pegged.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>An user on the libtorrent mailing list had the following problem: I&#8217;m doing some testing for a libtorrent application that will use a small number of peers (often just 1 seed and 1 downloaded) and high bandwidth delay product links (in the hundreds of Mb\/s and 100ms+ round trip). I&#8217;m unable to get more than [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3470,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1475,15,30,60],"tags":[204,1476,1477,703,1478],"class_list":["post-3469","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bittorrent","category-code","category-geeklife","category-p2p","tag-bittorrent","tag-jlibtorrent","tag-libtorrent","tag-networking","tag-performance"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2016\/01\/latency.jpg?fit=1000%2C667&ssl=1","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5Unzf-TX","jetpack-related-posts":[{"id":994,"url":"https:\/\/www.gubatron.com\/blog\/new-frostwire-4172-for-windows-is-out\/","url_meta":{"origin":3469,"position":0},"title":"New FrostWire 4.17.2 for Windows is out","author":"gubatron","date":"November 23, 2008","format":false,"excerpt":"Download FrostWire 4.17.2 for Windows CHANGELOG: Version 4.17.2 (November 2008) Fixes a newly introduced bug in Windows which would make FrostWire(tm) take over the .bittorrent file association without asking the user. Reduces DHT network load. The LimeWire team found out that the Mojito \u201cstore forwarding\u201d feature would not provide extra\u2026","rel":"","context":"In &quot;Geeklife&quot;","block_context":{"text":"Geeklife","link":"https:\/\/www.gubatron.com\/blog\/category\/geeklife\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1210,"url":"https:\/\/www.gubatron.com\/blog\/geek-t-shirt-collection-14-frostwire\/","url_meta":{"origin":3469,"position":1},"title":"Geek T-Shirt Collection #14 &#8211; FrostWire","author":"gubatron","date":"April 4, 2009","format":false,"excerpt":"This is the official FrostWire T-Shirt. I contribute to this open source project to keep my java skills up to date. We had a lot of these t-shirt printed to gather donations for the project. Thanks to the people that support us there's only a few left (only M size)\u2026","rel":"","context":"In &quot;Geeklife&quot;","block_context":{"text":"Geeklife","link":"https:\/\/www.gubatron.com\/blog\/category\/geeklife\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2664,"url":"https:\/\/www.gubatron.com\/blog\/the-tables-are-turning\/","url_meta":{"origin":3469,"position":2},"title":"The tables are turning","author":"gubatron","date":"February 15, 2012","format":false,"excerpt":"The internet already allows for zero cost content distribution to large amounts of people with technologies like BitTorrent. As the time goes by, labels will be lucky if they're still getting artists signed, sites like Bandcamp and YouTube empower artists to go directly to their fans. The tools at hand\u2026","rel":"","context":"In &quot;Creative Commons&quot;","block_context":{"text":"Creative Commons","link":"https:\/\/www.gubatron.com\/blog\/category\/creative-commons\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":379,"url":"https:\/\/www.gubatron.com\/blog\/hoy-empieza-la-tercera-temporada-de-lost\/","url_meta":{"origin":3469,"position":3},"title":"Hoy empieza la tercera temporada de Lost","author":"gubatron","date":"October 4, 2006","format":false,"excerpt":"Finalmente empieza hoy la tercera temporada de Lost. Las otras 2 las vi en iTunes y luego en DVD... no se lo que es esperar por propagandas o esperar toda una semana por un episodio de Lost. El dilema de este geek es ahora... espero un par de horas y\u2026","rel":"","context":"In &quot;Geeklife&quot;","block_context":{"text":"Geeklife","link":"https:\/\/www.gubatron.com\/blog\/category\/geeklife\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":490,"url":"https:\/\/www.gubatron.com\/blog\/descarga-50-wallpapers-de-scarlett-johansson-en-frostclickcom\/","url_meta":{"origin":3469,"position":4},"title":"Descarga 50 Wallpapers de Scarlett Johansson en FrostClick.com","author":"gubatron","date":"April 4, 2007","format":false,"excerpt":"Asi se ve mi escritorio Kubuntu hoy despues de ver 50 wallpapers de alta resolution (1920x1200) disponibles en FrostClick.com, alli encontraras un torrent que puedes utilizar con FrostWire o tu cliente de BitTorrent Favorito.","rel":"","context":"In &quot;Geeklife&quot;","block_context":{"text":"Geeklife","link":"https:\/\/www.gubatron.com\/blog\/category\/geeklife\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":945,"url":"https:\/\/www.gubatron.com\/blog\/new-frostwire-4171-released\/","url_meta":{"origin":3469,"position":5},"title":"New FrostWire 4.17.1 Released","author":"gubatron","date":"November 8, 2008","format":false,"excerpt":"Source FOR IMMEDIATE RELEASE: Official FrostWire 4.17.1 Download link FrostWire.com -- The last of the 4.17.x FrostWire series is finally out. The following is a list of the most important updates made for this release, which irons out most of the complains received from the community in regards to 4.17.0.\u2026","rel":"","context":"In &quot;FrostWire&quot;","block_context":{"text":"FrostWire","link":"https:\/\/www.gubatron.com\/blog\/category\/frostwire\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/3469","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/comments?post=3469"}],"version-history":[{"count":3,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/3469\/revisions"}],"predecessor-version":[{"id":3473,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/3469\/revisions\/3473"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/media\/3470"}],"wp:attachment":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/media?parent=3469"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/categories?post=3469"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/tags?post=3469"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}