<story><title>Rust programs versus Go</title><url>https://benchmarksgame-team.pages.debian.net/benchmarksgame/faster/rust-go.html</url></story><parent_chain><item><author>simias</author><text>I expect Rust to be faster than Go as a rule because of its somewhat lower level nature and cost-less &amp;quot;unmanaged&amp;quot; abstractions but I didn&amp;#x27;t expect it to be a full order of 
magnitude faster than Go for some benchmarks. Are the Go snippets not properly optimized or is there something else going on?&lt;p&gt;I think pitting Go against Rust is somewhat inflammatory but if you look at the Rust vs. C++ benchmark the results are much more similar: &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;benchmarksgame-team.pages.debian.net&amp;#x2F;benchmarksgame&amp;#x2F;faster&amp;#x2F;rust-gpp.html&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;benchmarksgame-team.pages.debian.net&amp;#x2F;benchmarksgame&amp;#x2F;...&lt;/a&gt; so clearly it&amp;#x27;s not Rust doing something right, it&amp;#x27;s the Go implementation doing something wrong. Actually even Java fares (mostly) better: &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;benchmarksgame-team.pages.debian.net&amp;#x2F;benchmarksgame&amp;#x2F;faster&amp;#x2F;rust-java.html&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;benchmarksgame-team.pages.debian.net&amp;#x2F;benchmarksgame&amp;#x2F;...&lt;/a&gt;</text></item></parent_chain><comment><author>Tuna-Fish</author><text>Explanations for the few largest offenders:&lt;p&gt;1. regex-redux&lt;p&gt;Rust has it&amp;#x27;s own regexp engine, that lacks a few of the bells and whistles of PCRE, but is much faster than it. (And has no sheer perfomance cliffs where a carefully crafted target string or search expression can DOS the app.) Also, I think the rust implementation can do less copying.&lt;p&gt;GO just uses PCRE. (Which is weird, isn&amp;#x27;t RE2 a google project?)&lt;p&gt;2. binary-trees&lt;p&gt;The benchmark needs to build a massive binary tree. The Rust implementation allocates it&amp;#x27;s tree in a TypedArena, which is basically a bump allocator for objects that are all dropped simultaneously. It requires very minimal metadata or work per allocation. (Not zero, because it does properly call all destructors.) The GO implementation has to use the platform allocator. The results shouldn&amp;#x27;t be very surprising...&lt;p&gt;3. Manderbrot&lt;p&gt;Not sure, but I think the Rust version is designed for autovectorization while the Go one is scalar.&lt;p&gt;After that the Go runtimes are within 2.5x of the Rust ones.</text></comment>
<story><title>Rust programs versus Go</title><url>https://benchmarksgame-team.pages.debian.net/benchmarksgame/faster/rust-go.html</url></story><parent_chain><item><author>simias</author><text>I expect Rust to be faster than Go as a rule because of its somewhat lower level nature and cost-less &amp;quot;unmanaged&amp;quot; abstractions but I didn&amp;#x27;t expect it to be a full order of 
magnitude faster than Go for some benchmarks. Are the Go snippets not properly optimized or is there something else going on?&lt;p&gt;I think pitting Go against Rust is somewhat inflammatory but if you look at the Rust vs. C++ benchmark the results are much more similar: &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;benchmarksgame-team.pages.debian.net&amp;#x2F;benchmarksgame&amp;#x2F;faster&amp;#x2F;rust-gpp.html&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;benchmarksgame-team.pages.debian.net&amp;#x2F;benchmarksgame&amp;#x2F;...&lt;/a&gt; so clearly it&amp;#x27;s not Rust doing something right, it&amp;#x27;s the Go implementation doing something wrong. Actually even Java fares (mostly) better: &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;benchmarksgame-team.pages.debian.net&amp;#x2F;benchmarksgame&amp;#x2F;faster&amp;#x2F;rust-java.html&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;benchmarksgame-team.pages.debian.net&amp;#x2F;benchmarksgame&amp;#x2F;...&lt;/a&gt;</text></item></parent_chain><comment><author>oblio</author><text>The JVM has a ton of work put into it, it wouldn&amp;#x27;t surprise me if Java is faster than Go for quite a few things.</text></comment>