<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mozzammel Haque</title>
    <description>The latest articles on DEV Community by Mozzammel Haque (@mozzammel_haque_c8417e84f).</description>
    <link>https://dev.to/mozzammel_haque_c8417e84f</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4124826%2Faed41d4a-9d1a-45b8-ba4d-780c9a1ffb54.jpg</url>
      <title>DEV Community: Mozzammel Haque</title>
      <link>https://dev.to/mozzammel_haque_c8417e84f</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mozzammel_haque_c8417e84f"/>
    <language>en</language>
    <item>
      <title>Calling Rust from Node with napi-rs: 6x faster for heavy work, 19x slower for tiny calls</title>
      <dc:creator>Mozzammel Haque</dc:creator>
      <pubDate>Mon, 12 Oct 2026 15:27:42 +0000</pubDate>
      <link>https://dev.to/mozzammel_haque_c8417e84f/calling-rust-from-node-with-napi-rs-6x-faster-for-heavy-work-19x-slower-for-tiny-calls-3ej9</link>
      <guid>https://dev.to/mozzammel_haque_c8417e84f/calling-rust-from-node-with-napi-rs-6x-faster-for-heavy-work-19x-slower-for-tiny-calls-3ej9</guid>
      <description>&lt;p&gt;I called a Rust function from Node 5 million times. It was 19x slower than the same function in plain JavaScript.&lt;/p&gt;

&lt;p&gt;The function just adds two numbers. About 106 ns per native call against 5.5 ns in JS, because V8 inlines the JS version and the native one has to cross the boundary every time.&lt;br&gt;
Then I gave Rust real work. Recursive fib(38) went from 726 ms to 116 ms, about 6x faster. A prime sieve over 20M numbers was only 1.5x faster.&lt;/p&gt;

&lt;p&gt;The part that surprised me most: passing a plain JS array of 1M numbers into Rust took 85 ms. A Float64Array took 1.3 ms, same as a JS loop.&lt;/p&gt;

&lt;p&gt;On my 2 vCPU box, native code started to pay off once the JS version of a call took around a microsecond. I did not test WASM because I couldn't install the target in my sandbox.&lt;/p&gt;

&lt;p&gt;Full numbers, code and raw output are in the article:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/gitconnected/calling-rust-from-node-with-napi-rs-6x-faster-for-heavy-work-19x-slower-for-tiny-calls-fe0f8828924b?sharedUserId=mozzammeluiu" rel="noopener noreferrer"&gt;https://medium.com/gitconnected/calling-rust-from-node-with-napi-rs-6x-faster-for-heavy-work-19x-slower-for-tiny-calls-fe0f8828924b?sharedUserId=mozzammeluiu&lt;/a&gt;&lt;/p&gt;

</description>
      <category>rust</category>
      <category>javascript</category>
      <category>backenddevelopment</category>
      <category>performance</category>
    </item>
  </channel>
</rss>
