<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Go Performance Engineering on Atharva Pandey</title><link>https://atharva.page/series/go-performance-engineering/</link><description>Recent content in Go Performance Engineering on Atharva Pandey</description><generator>Hugo</generator><language>en-us</language><copyright>Copyright ©</copyright><lastBuildDate>Thu, 10 Apr 2025 00:00:00 +0000</lastBuildDate><atom:link href="https://atharva.page/series/go-performance-engineering/index.xml" rel="self" type="application/rss+xml"/><item><title>Lesson 8: Avoiding Premature Optimization — Measure first, optimize never (usually)</title><link>https://atharva.page/post/go/go-perf-premature-optimization/</link><pubDate>Thu, 10 Apr 2025 00:00:00 +0000</pubDate><guid>https://atharva.page/post/go/go-perf-premature-optimization/</guid><description>&lt;p&gt;I&amp;rsquo;ve spent time in this series showing you how to make Go programs faster — escape analysis, stack allocation, pre-sizing data structures, zero-copy string handling, benchmarking discipline, pprof profiling, CPU vs memory tradeoffs. Every technique is real and useful. And every single one of them has been misapplied, including by me, when applied before understanding whether they were needed. The last lesson isn&amp;rsquo;t another technique. It&amp;rsquo;s the discipline that makes all the other techniques worth using: measure first, understand where the actual cost is, and optimize only there.&lt;/p&gt;</description></item><item><title>Lesson 7: CPU vs Memory Tradeoffs — Cache it or compute it, pick one</title><link>https://atharva.page/post/go/go-perf-cpu-memory/</link><pubDate>Thu, 20 Feb 2025 00:00:00 +0000</pubDate><guid>https://atharva.page/post/go/go-perf-cpu-memory/</guid><description>&lt;p&gt;Every performance optimization ultimately makes the same trade: you&amp;rsquo;re giving up memory to gain CPU time, or giving up CPU time to reduce memory usage. There&amp;rsquo;s no free lunch. The skill isn&amp;rsquo;t knowing that the tradeoff exists — it&amp;rsquo;s knowing which side of it you&amp;rsquo;re on, and making the choice consciously rather than accidentally. I&amp;rsquo;ve optimized for memory when the bottleneck was CPU, and optimized for CPU when memory was the problem. Both directions are wrong when you pick them without data.&lt;/p&gt;</description></item><item><title>Lesson 6: pprof Deep Dive — CPU, memory, goroutine — read all three</title><link>https://atharva.page/post/go/go-perf-pprof/</link><pubDate>Sun, 05 Jan 2025 00:00:00 +0000</pubDate><guid>https://atharva.page/post/go/go-perf-pprof/</guid><description>&lt;p&gt;When I first learned about &lt;code&gt;pprof&lt;/code&gt;, I thought it was a single tool that told you &amp;ldquo;what&amp;rsquo;s slow.&amp;rdquo; It took me an embarrassingly long time to understand that it&amp;rsquo;s actually a family of profilers — CPU, heap, allocs, goroutine, mutex, block — each answering a completely different question. Reading one profile and ignoring the others is like diagnosing engine trouble by only checking the oil. You might find something. You&amp;rsquo;ll definitely miss something. The profilers are designed to work together, and once you start reading all three, performance diagnosis goes from guesswork to diagnosis.&lt;/p&gt;</description></item><item><title>Lesson 5: Benchmarking Done Right — testing.B is not what you think</title><link>https://atharva.page/post/go/go-perf-benchmarking/</link><pubDate>Sun, 10 Nov 2024 00:00:00 +0000</pubDate><guid>https://atharva.page/post/go/go-perf-benchmarking/</guid><description>&lt;p&gt;Writing a Go benchmark feels simple. You drop &lt;code&gt;Benchmark&lt;/code&gt; in front of a function name, loop from 0 to &lt;code&gt;b.N&lt;/code&gt;, run &lt;code&gt;go test -bench=.&lt;/code&gt;, and get a number. The number feels authoritative. I spent about a year trusting benchmark numbers that were wrong — not wrong because of bugs, but wrong because of how the benchmark was written. The Go benchmark framework is excellent, but it has sharp edges that will mislead you until you learn to see them.&lt;/p&gt;</description></item><item><title>Lesson 4: String and Byte Conversions — The copy nobody sees</title><link>https://atharva.page/post/go/go-perf-string-bytes/</link><pubDate>Wed, 25 Sep 2024 00:00:00 +0000</pubDate><guid>https://atharva.page/post/go/go-perf-string-bytes/</guid><description>&lt;p&gt;Go strings are immutable. Byte slices are mutable. Converting between them requires copying the data — every time, without exception, unless you use unsafe tricks you almost certainly shouldn&amp;rsquo;t. That sounds like a minor footnote, but it becomes a significant issue the moment you start handling large volumes of text: parsing HTTP requests, processing log lines, building JSON responses. I&amp;rsquo;ve watched a single &lt;code&gt;string(b)&lt;/code&gt; call inside a tight loop add measurable latency to a production API, and the fix was two lines of code once I knew what to look for.&lt;/p&gt;</description></item><item><title>Lesson 3: Slice and Map Performance — The data structure tax</title><link>https://atharva.page/post/go/go-perf-slice-map/</link><pubDate>Tue, 20 Aug 2024 00:00:00 +0000</pubDate><guid>https://atharva.page/post/go/go-perf-slice-map/</guid><description>&lt;p&gt;Slices and maps are so convenient in Go that it&amp;rsquo;s easy to forget they&amp;rsquo;re not free. They have hidden costs — in allocations, in CPU cache misses, in GC scanning time — that only become visible when you push them into a hot path and watch your benchmarks light up. I&amp;rsquo;ve been burned by both, sometimes in embarrassing ways, and building intuition for when those costs matter has saved me more than one production incident.&lt;/p&gt;</description></item><item><title>Lesson 2: Stack vs Heap Intuition — The allocation you didn't know you made</title><link>https://atharva.page/post/go/go-perf-stack-heap/</link><pubDate>Tue, 16 Jul 2024 00:00:00 +0000</pubDate><guid>https://atharva.page/post/go/go-perf-stack-heap/</guid><description>&lt;p&gt;There&amp;rsquo;s a class of performance bugs in Go that doesn&amp;rsquo;t show up in code review, doesn&amp;rsquo;t trigger the race detector, and doesn&amp;rsquo;t cause test failures. It just makes your service slowly worse under load. The source is almost always the same: heap allocations happening in places you didn&amp;rsquo;t intend, turning what should be fast stack operations into GC-visible objects that pile up until the collector has to stop and clean them up. Building an intuition for when Go allocates on the heap versus the stack was one of the single highest-leverage things I did to improve the services I work on.&lt;/p&gt;</description></item><item><title>Lesson 1: Escape Analysis — Where your data lives matters more than how you write it</title><link>https://atharva.page/post/go/go-perf-escape-analysis/</link><pubDate>Thu, 20 Jun 2024 00:00:00 +0000</pubDate><guid>https://atharva.page/post/go/go-perf-escape-analysis/</guid><description>&lt;p&gt;I spent the first two years of writing Go completely unaware that the compiler was making decisions about my code that I never asked for — and that those decisions were quietly shaping the performance profile of everything I shipped. Escape analysis is the mechanism behind all of it. Once I understood it, I started reading code differently. Not just &amp;ldquo;does this work?&amp;rdquo; but &amp;ldquo;where does this data live, and did I give the compiler a chance to put it somewhere fast?&amp;rdquo;&lt;/p&gt;</description></item></channel></rss>