<?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: Naman Jain</title>
    <description>The latest articles on DEV Community by Naman Jain (@namanoncode).</description>
    <link>https://dev.to/namanoncode</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%2F4053696%2Fbc620a4e-4814-4a58-8cbe-491e1162c524.jpeg</url>
      <title>DEV Community: Naman Jain</title>
      <link>https://dev.to/namanoncode</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/namanoncode"/>
    <language>en</language>
    <item>
      <title>What I learned while building a Linux-native Java runtime</title>
      <dc:creator>Naman Jain</dc:creator>
      <pubDate>Wed, 29 Jul 2026 17:36:30 +0000</pubDate>
      <link>https://dev.to/namanoncode/what-i-learned-while-building-a-linux-native-java-runtime-53i5</link>
      <guid>https://dev.to/namanoncode/what-i-learned-while-building-a-linux-native-java-runtime-53i5</guid>
      <description>&lt;p&gt;Building my own runtime taught me how modern event-driven systems actually work under the hood. Here are the five biggest lessons I learned about CPU usage, kernel APIs, and performance benchmarking.&lt;/p&gt;

&lt;p&gt;Building zThread taught me far more about Linux and the JVM than I expected.&lt;/p&gt;

&lt;p&gt;When I started this project, my goal wasn't to replace Netty or Project Reactor. I wanted to understand how modern event-driven systems actually work under the hood. (This same curiosity eventually led to building ReactiveChainDB v2 to bypass CPU limitations entirely.)&lt;/p&gt;

&lt;p&gt;After months of reading Linux documentation, JVM internals, NGINX, Netty, and implementing my own runtime, here are the five biggest lessons.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. "Zero CPU" doesn't exist
&lt;/h2&gt;

&lt;p&gt;When I first learned about NGINX and epoll, I kept hearing:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"NGINX uses almost no CPU while waiting."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I interpreted that as zero CPU.&lt;/p&gt;

&lt;p&gt;That's not actually true.&lt;/p&gt;

&lt;p&gt;What's really happening is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Application
↓
epoll_wait()
↓
Kernel blocks thread
↓
No CPU consumed while sleeping
↓
Kernel wakes thread only when an event occurs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The application still uses CPU while processing events.&lt;/p&gt;

&lt;p&gt;The real optimization is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Don't waste CPU while waiting.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That changed how I thought about concurrency.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. The kernel already solves waiting
&lt;/h2&gt;

&lt;p&gt;Before this project, I assumed event loops were mostly implemented in Java.&lt;/p&gt;

&lt;p&gt;They're not.&lt;/p&gt;

&lt;p&gt;Linux already provides mechanisms for nearly every kind of asynchronous waiting:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;epoll&lt;/li&gt;
&lt;li&gt;eventfd&lt;/li&gt;
&lt;li&gt;timerfd&lt;/li&gt;
&lt;li&gt;signalfd&lt;/li&gt;
&lt;li&gt;inotify&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Instead of writing complicated polling loops, applications can ask the kernel:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Wake me when something interesting happens."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That realization became the foundation of zThread.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Throughput benchmarks can be misleading
&lt;/h2&gt;

&lt;p&gt;One of my earliest benchmarks compared:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;ArrayBlockingQueue.offer()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;eventfd_write()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The results looked terrible.&lt;/p&gt;

&lt;p&gt;Then I realized I wasn't measuring equivalent work.&lt;/p&gt;

&lt;p&gt;A queue insertion is an in-memory operation.&lt;/p&gt;

&lt;p&gt;An &lt;code&gt;eventfd_write()&lt;/code&gt; crosses into the kernel and wakes an event loop.&lt;/p&gt;

&lt;p&gt;Those aren't comparable.&lt;/p&gt;

&lt;p&gt;I completely redesigned the benchmark suite to compare end-to-end event processing pipelines instead of isolated API calls.&lt;/p&gt;

&lt;p&gt;That was probably the most valuable lesson I learned about benchmarking.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Foreign Function &amp;amp; Memory API changes everything
&lt;/h2&gt;

&lt;p&gt;A few years ago, calling Linux APIs from Java usually meant JNI.&lt;/p&gt;

&lt;p&gt;Today, Java's Foreign Function &amp;amp; Memory (FFM) API makes native interoperability much more approachable.&lt;/p&gt;

&lt;p&gt;For zThread, that meant I could call Linux APIs like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;epoll_create1&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;epoll_wait&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;eventfd&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;timerfd_create&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;directly from Java with a much cleaner integration model.&lt;/p&gt;

&lt;p&gt;It's one of the most exciting additions to the modern JVM ecosystem.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Building the runtime was easier than building good benchmarks
&lt;/h2&gt;

&lt;p&gt;Ironically, writing the event loop wasn't the hardest part.&lt;/p&gt;

&lt;p&gt;Designing benchmarks that were:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;fair&lt;/li&gt;
&lt;li&gt;reproducible&lt;/li&gt;
&lt;li&gt;statistically meaningful&lt;/li&gt;
&lt;li&gt;comparable across frameworks&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;turned out to be significantly more challenging.&lt;/p&gt;

&lt;p&gt;It's surprisingly easy to publish impressive-looking numbers.&lt;/p&gt;

&lt;p&gt;It's much harder to build benchmarks that other engineers trust.&lt;/p&gt;

&lt;p&gt;That experience fundamentally changed how I read performance claims online.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's next for zThread?
&lt;/h2&gt;

&lt;p&gt;The project is now:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open source&lt;/li&gt;
&lt;li&gt;Available on Maven Central&lt;/li&gt;
&lt;li&gt;Focused on Linux event-driven programming in Java&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;My next goals are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Better benchmarking&lt;/li&gt;
&lt;li&gt;Reactor integration&lt;/li&gt;
&lt;li&gt;More examples&lt;/li&gt;
&lt;li&gt;Better documentation&lt;/li&gt;
&lt;li&gt;Community feedback&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Final thoughts
&lt;/h2&gt;

&lt;p&gt;This project started as a curiosity:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"How does NGINX actually wait without wasting CPU?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That single question led me down a rabbit hole of Linux kernel APIs, JVM internals, concurrency, benchmarking, and systems programming.&lt;/p&gt;

&lt;p&gt;Whether zThread becomes widely adopted or simply remains a learning project, it has already achieved its biggest goal:&lt;/p&gt;

&lt;p&gt;It taught me how modern event-driven systems really work.&lt;/p&gt;

&lt;p&gt;If you've worked on Netty, Reactor, Vert.x, or JVM performance engineering, I'd love to hear your thoughts or feedback.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Project link:&lt;/strong&gt; &lt;a href="https://github.com/namanONcode/zThread" rel="noopener noreferrer"&gt;https://github.com/namanONcode/zThread&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>linux</category>
      <category>performance</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
