<?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: Pooja</title>
    <description>The latest articles on DEV Community by Pooja (@conqueror_queen).</description>
    <link>https://dev.to/conqueror_queen</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%2F4111783%2Ff8e897ff-f6e6-4a4a-855a-2bbfb955fa6e.png</url>
      <title>DEV Community: Pooja</title>
      <link>https://dev.to/conqueror_queen</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/conqueror_queen"/>
    <language>en</language>
    <item>
      <title>We Shipped an Optimization Our Own Benchmark Said Not To</title>
      <dc:creator>Pooja</dc:creator>
      <pubDate>Mon, 07 Sep 2026 01:46:20 +0000</pubDate>
      <link>https://dev.to/conqueror_queen/we-shipped-an-optimization-our-own-benchmark-said-not-to-3883</link>
      <guid>https://dev.to/conqueror_queen/we-shipped-an-optimization-our-own-benchmark-said-not-to-3883</guid>
      <description>&lt;p&gt;Here's the number first: we added a flag that parallelizes the slowest part of our log query tool across 8 goroutines, ran it against a real 76.3MB file, and it finished in 7.558 seconds. The same query, same file, one worker: 6.535 seconds. Eight workers lost to one by 16%.&lt;/p&gt;

&lt;p&gt;We shipped the flag anyway.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;logq is a command-line log query tool&lt;/strong&gt; — filter, group, count, percentile, and time-window a JSONL/logfmt/plain-text file the size of your disk, from one static binary, zero third-party dependencies. Built for Track B (Parsers &amp;amp; Data Formats) of the &lt;a href="https://zerodepshack.com" rel="noopener noreferrer"&gt;Zero Dependency Hackathon&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;At a glance&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;-j 8&lt;/code&gt; (8 parallel workers) measured &lt;strong&gt;16% slower&lt;/strong&gt; than &lt;code&gt;-j 1&lt;/code&gt; on a real 76.3MB file — shipped anyway, disclosed the moment it was found&lt;/li&gt;
&lt;li&gt;Replaced &lt;a href="https://pkg.go.dev/github.com/tidwall/gjson" rel="noopener noreferrer"&gt;&lt;code&gt;tidwall/gjson&lt;/code&gt;&lt;/a&gt; (10,420 known importers) with ~150 lines on top of stdlib's own &lt;a href="https://pkg.go.dev/encoding/json" rel="noopener noreferrer"&gt;&lt;code&gt;encoding/json&lt;/code&gt;&lt;/a&gt; decoder&lt;/li&gt;
&lt;li&gt;A three-valued &lt;code&gt;MISSING&lt;/code&gt;/&lt;code&gt;null&lt;/code&gt;/&lt;code&gt;false&lt;/code&gt; evaluator — the single design decision we're proudest of, and it isn't a package replacement at all&lt;/li&gt;
&lt;li&gt;Added CI two days before submission; it failed for a reason we never fully diagnosed, so we removed it rather than leave an unexplained red badge&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;We're citing exact commit hashes and timestamps throughout this post instead of describing things from memory, because &lt;a href="https://github.com/pooja-conqueror/LOGQ/blob/main/STDLIB.md" rel="noopener noreferrer"&gt;&lt;code&gt;STDLIB.md&lt;/code&gt;&lt;/a&gt;, this project's own dependency ledger, is built the same way: &lt;em&gt;"this ledger is built incrementally... so the git log itself is the evidence trail for the rationale."&lt;/em&gt; If a claim below has a hash next to it, &lt;code&gt;git show &amp;lt;hash&amp;gt;&lt;/code&gt; in the &lt;a href="https://github.com/pooja-conqueror/LOGQ" rel="noopener noreferrer"&gt;public repo&lt;/a&gt; is where it actually came from.&lt;/p&gt;

&lt;h2&gt;
  
  
  The bug most log tools ship anyway
&lt;/h2&gt;

&lt;p&gt;Most query tools treat "this field doesn't exist on this record" and "this field exists and is JSON &lt;code&gt;null&lt;/code&gt;" as the same case — or they don't think about the distinction until a record shaped differently from the rest crashes the whole run. logq treats &lt;code&gt;MISSING&lt;/code&gt;, &lt;code&gt;null&lt;/code&gt;, and &lt;code&gt;false&lt;/code&gt; as three genuinely different states, all the way through the evaluator, and it's the first real design decision in the project's history: commit &lt;code&gt;e04368a&lt;/code&gt; (&lt;code&gt;Value&lt;/code&gt;/&lt;code&gt;Record&lt;/code&gt; model, &lt;code&gt;MISSING&lt;/code&gt; vs &lt;code&gt;Null&lt;/code&gt;) and &lt;code&gt;8849137&lt;/code&gt; (the three-valued evaluator, with a generated truth-table matrix of tests) land ten minutes apart, twenty-eight minutes into the whole build — before there was a JSON decoder, before there was a CLI, before there was anything to actually filter yet.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;any comparison (&lt;code&gt;==&lt;/code&gt;, &lt;code&gt;&amp;gt;=&lt;/code&gt;, ...)&lt;/th&gt;
&lt;th&gt;&lt;code&gt;exists(field)&lt;/code&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;field absent&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;false&lt;/code&gt; — never an error&lt;/td&gt;
&lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;field present, &lt;code&gt;null&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;false&lt;/code&gt;, except it matches the &lt;code&gt;null&lt;/code&gt; literal&lt;/td&gt;
&lt;td&gt;&lt;code&gt;true&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;field present, &lt;code&gt;false&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;evaluates normally&lt;/td&gt;
&lt;td&gt;&lt;code&gt;true&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The practical effect: a filter query never crashes partway through a file just because one record has a different shape than the rest. It also never quietly tells you &lt;code&gt;null&lt;/code&gt; "equals" missing, which is the kind of wrong answer that shows up with no error message attached — the worst kind, because nothing tells you to go check.&lt;/p&gt;

&lt;h2&gt;
  
  
  The package with 10,420 reasons to exist
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;tidwall/gjson&lt;/code&gt; has 10,420 known importers on pkg.go.dev — checked live twice, a day apart, so the number in this post wouldn't be stale by the time anyone read it. People reach for it because Go's own &lt;code&gt;encoding/json&lt;/code&gt;, decoded the default way into &lt;code&gt;map[string]any&lt;/code&gt;, does two things quietly: it decodes every number to &lt;code&gt;float64&lt;/code&gt; (losing precision past 2^53 — a snowflake ID or trace ID comes back a &lt;em&gt;different&lt;/em&gt;, confidently-printed number, no error), and Go maps have no defined iteration order, so a re-printed record's fields land in a different order than the source line.&lt;/p&gt;

&lt;p&gt;Commit &lt;code&gt;09dd14c&lt;/code&gt;, four minutes after the truth-table commit above, replaces both properties with the same tokenizer gjson itself sits on top of: &lt;code&gt;encoding/json&lt;/code&gt;'s &lt;a href="https://pkg.go.dev/encoding/json#Decoder.Token" rel="noopener noreferrer"&gt;&lt;code&gt;Decoder.Token()&lt;/code&gt;&lt;/a&gt;, streamed into a hand-written ordered map, with &lt;a href="https://pkg.go.dev/encoding/json#Number" rel="noopener noreferrer"&gt;&lt;code&gt;json.Number&lt;/code&gt;&lt;/a&gt; instead of the &lt;code&gt;float64&lt;/code&gt; default. About 150 lines. Not a smaller gjson — the same stdlib primitive gjson wraps, pointed at the two specific things gjson exists to fix. Full trade-off table in &lt;a href="https://github.com/pooja-conqueror/LOGQ/blob/main/STDLIB.md" rel="noopener noreferrer"&gt;&lt;code&gt;STDLIB.md&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;It's not a strictly better trade, and &lt;a href="https://github.com/pooja-conqueror/LOGQ/blob/main/BENCHMARKS.md" rel="noopener noreferrer"&gt;&lt;code&gt;BENCHMARKS.md&lt;/code&gt;&lt;/a&gt; says so directly: gjson can extract one path from a large object without decoding the fields around it. This decoder builds the full ordered record regardless of what the query touches. For a query reading one field out of thirty, gjson wins. Written down, not hidden.&lt;/p&gt;

&lt;h2&gt;
  
  
  We shipped an optimization our own benchmark said not to
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;-j N&lt;/code&gt; exists because the obvious complaint about a single-threaded aggregation stage is "why isn't this parallel." Commit &lt;code&gt;a29a587&lt;/code&gt;, twenty-three and a half hours into the project, makes it parallel: &lt;code&gt;stats&lt;/code&gt;' per-group aggregation shards across N goroutines, routed by a hash of the group key so a group's records always land on the same shard — no round-robin, no cross-shard merge beyond a trivial flush at the end.&lt;/p&gt;

&lt;p&gt;Correctness got verified in that same commit: byte-identical output between &lt;code&gt;-j 1&lt;/code&gt; and &lt;code&gt;-j 16&lt;/code&gt; over a 2,000-record fixture. Speed didn't. That's worth being honest about — the flag shipped on the strength of being &lt;em&gt;correct&lt;/em&gt;, not on the strength of being measured. The obvious assumption, more workers means faster, rode along unexamined for two and a half more hours, until commit &lt;code&gt;58da5cf&lt;/code&gt; — a release-readiness sweep whose own message admits it bundles ten different things into one sitting, benchmarking included — actually ran the numbers:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fe8hj1lxe7h0x59qt3kc8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fe8hj1lxe7h0x59qt3kc8.png" alt="Bar chart: logq's -j 1 (single-threaded) finishes a 76.3MB real-file query in 6.535 seconds; -j 8 (8 parallel&lt;br&gt;
  workers) takes 7.558 seconds — 16% slower, because -j only shards aggregation while JSON decoding, the real&lt;br&gt;
  bottleneck, stays&lt;br&gt;
  single-threaded" width="800" height="448"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Eight workers, 16% slower than one, on a real 467,715-line file. The root cause isn't subtle once you look at what &lt;code&gt;-j&lt;/code&gt; actually touches: it shards the aggregation math, the count/sum/percentile bookkeeping per group. It does nothing to JSON decoding, which is the part that actually dominates per-line cost. So &lt;code&gt;-j N&lt;/code&gt; spends real wall-clock time on channel dispatch and cross-goroutine coordination to parallelize the cheap 20% of the work, while the expensive 80%, decode, stays exactly as single-threaded as it was at &lt;code&gt;-j 1&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The honest options at that point were: quietly remove the flag before anyone benchmarks it, quietly leave it in and hope nobody does, or publish the number and ship it anyway. We did the third one, in the same commit that found the regression, not a follow-up two weeks later titled "fix docs." The flag stays because a future version that actually shards decoding will make &lt;code&gt;-j&lt;/code&gt; worth having — and when that lands, this number is the baseline it has to beat, not something quietly removed from the history first.&lt;/p&gt;
&lt;h2&gt;
  
  
  The CI we couldn't explain, so we removed it
&lt;/h2&gt;

&lt;p&gt;CI landed in that same sweep commit, &lt;code&gt;58da5cf&lt;/code&gt;: matrix build across Linux/macOS/Windows, a coverage gate, &lt;code&gt;-race&lt;/code&gt;, fuzzing, a reproducibility check. It sat in the repo for a full day without ever actually running.&lt;/p&gt;

&lt;p&gt;It ran for the first time two days later, triggered by commit &lt;code&gt;d098ba7&lt;/code&gt; — a docs-only push, README and a slide deck, no Go code touched. &lt;code&gt;build&lt;/code&gt; passed on all three OSes. &lt;code&gt;test&lt;/code&gt; failed on all three. &lt;code&gt;race&lt;/code&gt; failed too, and there was no way to see why: the repository wasn't reachable from the sandbox this project was built in, no way to pull the actual failing log output.&lt;/p&gt;

&lt;p&gt;We spent the next hour doing what was actually reachable instead: downloaded the exact Go 1.23.4 toolchain CI resolves to and ran the full build/vet/test suite with it locally — clean. Cross-vetted for Linux and macOS explicitly, for the first time ever rather than just cross-&lt;em&gt;compiling&lt;/em&gt; for them — clean. Checked the one binary fixture in the repo for line-ending corruption, a real risk given this dev machine's Windows git config — untouched. Every avenue actually reachable came back clean, and the real CI failure stayed unexplained.&lt;/p&gt;

&lt;p&gt;Commit &lt;code&gt;0ab77e6&lt;/code&gt; is the decision that came out of that hour, 55 minutes after &lt;code&gt;d098ba7&lt;/code&gt; by the log's own timestamps: remove the workflow entirely rather than leave a red badge nobody could explain, or worse, quietly disable just the failing jobs so it would go green without the underlying question ever getting answered. No CI beats a badge that's lying, even by omission.&lt;/p&gt;
&lt;h2&gt;
  
  
  Watch it run
&lt;/h2&gt;

&lt;p&gt;Numbers on a page are one thing. Here's the compiled binary, live: the same three queries from the top of this post, the &lt;code&gt;-j&lt;/code&gt; regression, gzip and logfmt input handled transparently, and a typo caught with a positioned "did you mean" suggestion instead of a stack trace.&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/PrXcMudgD6w" width="710" height="399"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  The numbers, together
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Filter throughput:      19.24 MB/s in-process (20K lines) / ~15-16 MB/s real 76.3MB file
Memory across 10x scale: 344,272 -&amp;gt; 353,968 bytes (9,696-byte delta, ~48MB envelope)
Tests:                   746 passing, 14 packages, 89.6% line coverage (internal/*)
Fuzzing:                 10.4M executions against the parser, zero crashes
Reproducible build:      two builds, identical SHA-256 hash
-j 8 vs -j 1:             16% SLOWER on a real 467,715-line file — shipped and disclosed anyway
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All of it reproducible from a clean checkout: &lt;code&gt;make bench&lt;/code&gt;, &lt;code&gt;make soak-manual&lt;/code&gt;, &lt;code&gt;make cover&lt;/code&gt;, &lt;code&gt;make repro-check&lt;/code&gt;, documented in full in the &lt;a href="https://github.com/pooja-conqueror/LOGQ#readme" rel="noopener noreferrer"&gt;README&lt;/a&gt;. None of it is estimated, and none of the numbers above were softened for this post — they're the same ones sitting in the repo's own markdown files, checked against &lt;code&gt;git log&lt;/code&gt; before a word of this was written.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;We're Team Vanquisher&lt;/strong&gt; — a team entry for Track B of the &lt;a href="https://zerodepshack.com" rel="noopener noreferrer"&gt;Zero Dependency Hackathon&lt;/a&gt; (Aug 28–31, 2026). Every hash above is checkable in the &lt;a href="https://github.com/pooja-conqueror/LOGQ" rel="noopener noreferrer"&gt;public repo&lt;/a&gt; with &lt;code&gt;git log --format="%h|%ad|%s" --reverse&lt;/code&gt;. Source under &lt;a href="https://github.com/pooja-conqueror/LOGQ/blob/main/LICENSE" rel="noopener noreferrer"&gt;MIT&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>go</category>
      <category>showdev</category>
      <category>opensource</category>
      <category>hackathonraptors</category>
    </item>
  </channel>
</rss>
