<?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: Gan</title>
    <description>The latest articles on DEV Community by Gan (@jinganix).</description>
    <link>https://dev.to/jinganix</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%2F4245244%2Fd4f6505e-e966-45fc-b453-8076222ef15c.jpg</url>
      <title>DEV Community: Gan</title>
      <link>https://dev.to/jinganix</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jinganix"/>
    <language>en</language>
    <item>
      <title>AI Says This 20% Gap Can Never Be Closed. Can You Prove It Wrong?</title>
      <dc:creator>Gan</dc:creator>
      <pubDate>Mon, 16 Nov 2026 03:05:54 +0000</pubDate>
      <link>https://dev.to/jinganix/ai-says-this-20-gap-can-never-be-closed-can-you-prove-it-wrong-8gk</link>
      <guid>https://dev.to/jinganix/ai-says-this-20-gap-can-never-be-closed-can-you-prove-it-wrong-8gk</guid>
      <description>&lt;p&gt;Ten years ago I worked at a mobile game company. To speed up our gateway, I wrote &lt;a href="https://github.com/jinganix/enif_protobuf" rel="noopener noreferrer"&gt;enif_protobuf&lt;/a&gt; — Erlang has no official protobuf runtime, so I built a C core + NIF that raised gateway throughput several times over pure Erlang code (today's Erlang table still shows ~3.9x encode / ~2.3x decode vs pure-Erlang gpb).&lt;/p&gt;

&lt;p&gt;Recently, with AI help, I ported that same dynamic design into &lt;a href="https://github.com/jinganix/pbwire" rel="noopener noreferrer"&gt;pbwire&lt;/a&gt;: one C core, 23 language bindings, each benchmarked against its official counterpart. All numbers are in &lt;a href="https://github.com/jinganix/pbwire/blob/master/BENCHMARKS.md" rel="noopener noreferrer"&gt;BENCHMARKS.md&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;One rule: stay dynamic. Load a standard &lt;code&gt;FileDescriptorSet&lt;/code&gt; at runtime, no per-message generated code, and bytes must match &lt;code&gt;protoc&lt;/code&gt; exactly before anything is timed.&lt;/p&gt;

&lt;p&gt;It won almost everywhere. Java (pure Java, no JNI) does 1.13x / 1.95x on the 74KB tier. The single loss: &lt;strong&gt;136B encode at only ~0.7x&lt;/strong&gt; (~75ns vs ~58ns against &lt;code&gt;protobuf-java&lt;/code&gt;).&lt;/p&gt;

&lt;h2&gt;
  
  
  Why insist on dynamic?
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Generated code pins the schema at compile time — every &lt;code&gt;.proto&lt;/code&gt; change means regenerate, recompile, restart. No hot updates for a gateway.&lt;/li&gt;
&lt;li&gt;The output is big, unreadable, slow to compile, and pollutes the repo.&lt;/li&gt;
&lt;li&gt;Business needs annotations and custom field behavior; generated classes are hard to extend.&lt;/li&gt;
&lt;li&gt;Some languages have no official runtime at all (Erlang back then) — a shared dynamic core is the only reusable answer.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So my codegen emits only thin models, and all wire encoding goes through the same core. Winning this cell with a generated writer would mean losing the product.&lt;/p&gt;

&lt;h2&gt;
  
  
  The last 10 days: small wins, no breakthrough
&lt;/h2&gt;

&lt;p&gt;I ran many intensive rounds over the past 10 days. A few small optimizations landed, but nothing fundamental — the 136B cell never moved.&lt;/p&gt;

&lt;p&gt;The ledger is in &lt;a href="https://github.com/jinganix/pbwire/blob/master/docs/perf-attempts.md" rel="noopener noreferrer"&gt;perf-attempts&lt;/a&gt;: 8 targeted attempts all failed, and JNI is rejected too (small-tier encode at just 0.54x of pure Java). AI's verdict is a structural floor: stripping all byte writes still leaves 23.3ns of per-field skeleton (22 fields, ~1.06ns/field), while the official &lt;code&gt;writeTo()&lt;/code&gt; is straight-line code with no such loop. The second wall is HotSpot's inlining ceiling.&lt;/p&gt;

&lt;h2&gt;
  
  
  Help wanted
&lt;/h2&gt;

&lt;p&gt;Full context is in the &lt;a href="https://github.com/jinganix/pbwire/blob/master/docs/java-encode-help.md" rel="noopener noreferrer"&gt;help doc&lt;/a&gt; — please don't retry what's already there. I have no preset direction in mind; any idea is welcome as long as it keeps the dynamic constraint and comes with A/B numbers.&lt;/p&gt;

&lt;p&gt;Repro (needs JDK 17+ and &lt;code&gt;protoc&lt;/code&gt;; the baseline is stock &lt;code&gt;protobuf-java&lt;/code&gt; 4.36.2, auto-downloaded from Maven on first run, matching the pinned &lt;code&gt;protoc&lt;/code&gt; 36.2):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;make java-bench
&lt;span class="c"&gt;# A/B: build two class trees with ./build.sh, then run alternately&lt;/span&gt;
bindings/java/benchmarks/ab.sh /tmp/base out/classes
&lt;span class="c"&gt;# Only if you want a newer-than-Maven baseline, build it yourself:&lt;/span&gt;
&lt;span class="c"&gt;# export PROTOBUF_JAVA_JAR=/path/to/protobuf-java.jar&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A well-evidenced "0.7x is the floor" is equally welcome — it closes the issue. AI says this 20% can never be won back. Can you prove it wrong?&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
