<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Data Structures on miti99</title><link>https://miti99.com/en/tags/data-structures/</link><description>Recent content in Data Structures on miti99</description><generator>Hugo</generator><language>en</language><lastBuildDate>Mon, 16 Nov 2026 17:39:19 +0700</lastBuildDate><atom:link href="https://miti99.com/en/tags/data-structures/index.xml" rel="self" type="application/rss+xml"/><item><title>Newsletter #130</title><link>https://miti99.com/en/post/2026/09/08/</link><pubDate>Tue, 08 Sep 2026 00:00:00 +0700</pubDate><guid>https://miti99.com/en/post/2026/09/08/</guid><description>&lt;p&gt;&lt;em&gt;Enjoy Newsletter #130.&lt;/em&gt;&lt;/p&gt;
&lt;h2 id="how-anthropic-runs-large-scale-code-migrations-with-claude-code"&gt;&lt;a href="https://claude.com/blog/ai-code-migration" rel="noopener noreferrer"&gt;How Anthropic runs large-scale code migrations with Claude Code&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Migrating a large codebase to another language used to be a multi-year endeavor undertaken only as a last resort. Anthropic shows how that calculus has changed: Bun migrated one million lines of code from Zig to Rust in under two weeks, consuming roughly 5.9 billion input tokens and 690 million output tokens (around $165,000 at standard API pricing). In return, the entire existing test suite passed before merging (19 regressions surfaced afterward and were all fixed), the binary shrank by 19%, runtime performance improved by 2–5%, and one memory benchmark dropped from 6,745 MB to 609 MB. In another example, 165,000 lines of Python were migrated to TypeScript over a single weekend.&lt;/p&gt;
&lt;p&gt;The workflow follows six steps: author a translation rulebook alongside a dependency graph, pilot the rules on a sample batch of files, translate the codebase in parallel using worker agents, run a compilation loop pairing a fixer agent with an adversarial reviewer agent, run fast tests to catch runtime bugs, and finally verify behavioral parity against the original implementation. The core lesson is to fix the generation loop rather than hand-patching generated code: whenever a mistake repeats, update the rulebook and regenerate. Doing so requires an objective &amp;ldquo;oracle&amp;rdquo;—such as a compiler and test suite—up front, plus a resumable work queue. Compute spend should also be tiered deliberately: smaller models like Sonnet handle bulk translation, while larger models like Fable or Opus write the rulebook and perform adversarial reviews.&lt;/p&gt;
&lt;h2 id="the-vfs"&gt;&lt;a href="https://internals-for-interns.com/posts/linux-kernel-vfs/" rel="noopener noreferrer"&gt;The VFS&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Whether you read a file on ext4, a virtual file in &lt;code&gt;/proc&lt;/code&gt; that exists only in kernel memory, or a remote file over NFS, you use the exact same system calls and file descriptor semantics. The layer that makes this possible is the VFS (Virtual File System), sitting between the syscall interface and concrete filesystems. This article explains the VFS as a textbook application of &amp;ldquo;program to an interface, not an implementation&amp;rdquo;—where, in C, an interface is simply a struct of function pointers. Four core objects do the heavy lifting: a &lt;code&gt;superblock&lt;/code&gt; represents a mounted filesystem, an &lt;code&gt;inode&lt;/code&gt; represents an object within it (a file, directory, or link), a &lt;code&gt;dentry&lt;/code&gt; binds a name to an inode (since inodes themselves don&amp;rsquo;t know their own filenames), and a &lt;code&gt;file&lt;/code&gt; represents a specific open handle held by a process with its own read/write offset. The &lt;code&gt;super_operations&lt;/code&gt;, &lt;code&gt;inode_operations&lt;/code&gt;, and &lt;code&gt;file_operations&lt;/code&gt; tables hold filesystem-specific behaviors, falling back to generic VFS implementations whenever a hook is left unimplemented.&lt;/p&gt;
&lt;p&gt;In practice, most work is handled by shared VFS code before ever touching a filesystem driver. When resolving a path like &lt;code&gt;/etc/hostname&lt;/code&gt;, the kernel walks component by component and calls the filesystem&amp;rsquo;s &lt;code&gt;lookup&lt;/code&gt; hook only when the dentry cache (dcache) misses. That cache even remembers nonexistent paths (negative dentries) and is read locklessly via RCU. Reading file contents works similarly: most reads simply copy bytes out of the page cache without touching the disk, and a user-space file descriptor is nothing more than an index into the process&amp;rsquo;s &lt;code&gt;struct file *&lt;/code&gt; array.&lt;/p&gt;
&lt;h2 id="text-editor-data-structures"&gt;&lt;a href="https://cdacamar.github.io/data%20structures/algorithms/benchmarking/text%20editors/c&amp;#43;&amp;#43;/editor-data-structures/" rel="noopener noreferrer"&gt;Text Editor Data Structures&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;When building a text editor from scratch, the first question is how to represent file contents in memory. Cameron DaCamara starts by laying out his requirements: fast insertions and deletions, fast undo/redo, UTF-8 support, and simultaneous multi-cursor editing. From there, he systematically eliminates candidates. A single contiguous string is simple to render, but bogs down on files over 1 MB, reallocations can turn $O(n)$ edits into $O(n^2)$, and snapshotting for undo/redo burns memory. Emacs-style gap buffers are simple but poorly suited to multiple cursors. Ropes give $O(\log n)$ operations, but copy-on-write overhead bloats memory usage. Traditional piece tables, once used in Microsoft Word, hit contiguous-array bottlenecks during long editing sessions. VS Code&amp;rsquo;s piece tree combines the strengths of ropes and piece tables by backing the piece table with a red-black tree.&lt;/p&gt;
&lt;p&gt;DaCamara takes that approach a step further by building an &lt;em&gt;immutable&lt;/em&gt; piece tree called &lt;code&gt;fredbuf&lt;/code&gt;. A purely functional red-black tree needs no parent pointers and allows cheap $O(1)$ snapshots at any point, turning undo and redo into two simple linked lists of tree roots. CRLF line-ending normalization is handled outside the tree, and a &lt;code&gt;TreeWalker&lt;/code&gt; abstraction simplifies character iteration and correctness testing. Two takeaways stand out: analyzing constraints up front saves wasted effort, and investing in debugging tools—like visual tree dumpers—is what gets a complex project across the finish line, especially when implementing notoriously tricky immutable red-black tree deletions. The library is MIT-licensed and requires only C++20.&lt;/p&gt;
&lt;h2 id="scaling-to-1-million-concurrent-sandboxes-in-seconds"&gt;&lt;a href="https://modal.com/blog/scaling-to-1-million-concurrent-sandboxes-in-seconds" rel="noopener noreferrer"&gt;Scaling to 1 million concurrent sandboxes in seconds&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Modal rewrote its entire sandbox control plane from the ground up and demonstrated the result with a striking milestone: spinning up one million concurrent sandboxes in under 60 seconds. Their previous architecture, much like Kubernetes, relied on strong consistency across the backend: every placement decision required global coordination, and database writes scaled linearly with sandbox count, making horizontal scaling impossible once demand reached millions of concurrent sandboxes and tens of thousands of creations per second.&lt;/p&gt;
&lt;p&gt;The new architecture embraces decentralization. Instead of a single serialized central scheduler, multiple scheduler servers run in parallel using load-balancing algorithms over in-memory state. Each worker node becomes the source of truth for its own sandboxes, periodically publishing state to Redis rather than writing synchronously to a central datastore, removing Postgres from the sandbox creation hot path entirely. RPC calls that previously scaled per sandbox are coalesced into batches. As a result, creating a sandbox takes just two network hops and a single CPU operation with zero central coordination, achieving a median startup time under 500 ms and scheduling latency of just a few tens of milliseconds. The multi-month effort began with an intense prototyping sprint by four engineers before reimplementing every feature, monitoring pipeline, and container runtime detail—including tracking down and fixing Linux kernel &lt;code&gt;rtnl&lt;/code&gt; lock contention when spinning up containers en masse.&lt;/p&gt;
&lt;h2 id="making-768-servers-look-like-1"&gt;&lt;a href="https://planetscale.com/blog/making-768-servers-look-like-1" rel="noopener noreferrer"&gt;Making 768 servers look like 1&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;When an application has to serve millions of queries per second over petabytes of data, a single database server is no longer enough. PlanetScale outlines three fundamental walls in single-primary scaling: writes always funnel into one machine because the write-ahead log (WAL) is a serialization bottleneck regardless of how many read replicas you add; replicas duplicate the full dataset rather than dividing it; and backing up or restoring a massive monolithic database can take hours or days. The solution is horizontal sharding—splitting both data and queries across many independent primary servers. In the article&amp;rsquo;s example, one petabyte is split across 256 shards of roughly 4 TB each, with one primary and two replicas per shard, totaling 768 servers.&lt;/p&gt;
&lt;p&gt;To shield application developers from that complexity, a routing proxy layer sits between the app and the shards—Vitess for MySQL and Neki for Postgres. Unlike simple connection poolers such as PgBouncer, this router parses SQL queries, understands how data is distributed, plans and scatters queries to the right shards, and merges the results back together. The sharding topology is declared in JSON (a VSchema)—for instance, sharding the &lt;code&gt;user&lt;/code&gt; table by a hash of its &lt;code&gt;id&lt;/code&gt; column. Ultimately, the application connects to a single hostname like &lt;code&gt;mydb.pscale.com&lt;/code&gt;: DNS resolves to network load balancers that distribute connections across stateless query routers, and the application never knows 768 database servers are working behind the scenes.&lt;/p&gt;
&lt;h2 id="branchavoidant-programming"&gt;&lt;a href="https://easylang.online/blog/branchless" rel="noopener noreferrer"&gt;Branch‑Avoidant Programming&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Modern CPUs speculate on which way branches will go to keep their instruction pipelines full; when a prediction is wrong, the pipeline must be flushed and refilled at a steep penalty. This article illustrates the cost by filtering numbers smaller than 500 out of a random array—a workload where the branch predictor is essentially guessing a coin flip. The trick is to eliminate the &lt;code&gt;if&lt;/code&gt; statement: unconditionally write the current number into the output slot, and conditionally advance the output index with &lt;code&gt;smlen += (numbers[i] &amp;lt; 500);&lt;/code&gt;. You perform extra writes, but they are far cheaper than branch mispredictions. Filtering 100,000 numbers 1,000 times on an Apple M1 takes 0.345 seconds with an &lt;code&gt;if&lt;/code&gt; branch versus just 0.036 seconds branchless—nearly 10x faster; on an Intel Xeon, it drops from 0.576 to 0.110 seconds. Inspecting the assembly shows why: conditional jump instructions like &lt;code&gt;b.gt&lt;/code&gt; (ARM) or &lt;code&gt;jg&lt;/code&gt; (x86) are replaced by predication instructions like &lt;code&gt;cinc&lt;/code&gt; or &lt;code&gt;setle&lt;/code&gt;, keeping control flow completely straight.&lt;/p&gt;
&lt;p&gt;Compilers don&amp;rsquo;t apply this transformation automatically because they don&amp;rsquo;t know the statistical distribution of your runtime data, nor can they safely assume that a conditional memory write is valid to execute unconditionally (since the destination buffer might only be sized for matching elements or could trigger a data race). Developers therefore have to write branchless loops deliberately when profiling calls for it. The author notes that quicksort partitioning is a prime candidate, as partitioning is fundamentally conditional data movement around a pivot.&lt;/p&gt;
&lt;h2 id="your-redis-leaderboard-is-probably-breaking-ties-wrong"&gt;&lt;a href="https://dev.to/trungdlp/your-redis-leaderboard-is-probably-breaking-ties-wrong-39k4" rel="noopener noreferrer"&gt;Your Redis Leaderboard Is Probably Breaking Ties Wrong&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Building a leaderboard with a Redis sorted set is a classic pattern, but few developers think about what happens when two players have the exact same score. By default, Redis breaks ties lexicographically by member string, meaning the player ID arbitrarily decides who ranks higher—deterministic, but meaningless to players. Common quick fixes have flaws of their own: millisecond timestamps collide under concurrency and suffer from clock skew across servers, while packing both score and timestamp into a single 64-bit IEEE 754 &lt;code&gt;double&lt;/code&gt; eats into the precision and safe range of both numbers.&lt;/p&gt;
&lt;p&gt;Podium, an open-source leaderboard service, implements a clean rule: whoever reaches a tied score first ranks higher. Each leaderboard maintains a monotonic counter initialized to the maximum signed 64-bit integer; whenever a player posts a new score, a Lua script decrements the counter and prepends that 19-digit number to the player&amp;rsquo;s public ID, ensuring earlier arrivals have a lexicographically larger prefix and sort ahead in descending queries. The script atomically updates four keys: the descending sorted set, an ascending sorted set (where counter digits are inverted so earlier arrivals still win ties), a hash mapping public IDs to internal member strings, and the counter itself. If a submitted score equals the player&amp;rsquo;s current score, their existing internal member name is preserved, making retries idempotent. The trade-off is roughly 11–17% higher write latency and 287 bytes per member instead of 99 bytes in local benchmarks—a reasonable price for fair, intuitive tie-breaking.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;&lt;em&gt;This post was rewritten by Claude Code with Opus 5.5 on 27/09/2026; reviewed and edited by Codex with GPT 6.1 Sol on 09/11/2026, and re-verified by Claude Code with Sonnet 5.5 on 16/11/2026.&lt;/em&gt;&lt;/p&gt;</description></item><item><title>Newsletter #51</title><link>https://miti99.com/en/post/2025/08/31/</link><pubDate>Sun, 31 Aug 2025 00:00:00 +0700</pubDate><guid>https://miti99.com/en/post/2025/08/31/</guid><description>&lt;p&gt;&lt;em&gt;Hey everyone, I&amp;rsquo;ve hit one of my lazy cycles again (and honestly, since I churned through quite a bit of material earlier, there isn&amp;rsquo;t that much backlog left anyway), so I&amp;rsquo;ll be switching to roughly 1–2 posts a week depending on my mood. Also, last week my idol ✨🌙 recommended the book &lt;del&gt;&lt;a href="https://nhanam.vn/tim-minh-trong-the-gioi-hau-tuoi-tho-nha-nam" rel="noopener noreferrer"&gt;Tìm mình trong thế giới hậu tuổi thơ&lt;/a&gt;&lt;/del&gt; (Finding Yourself in the Post-Childhood World), which is quite a good read—feel free to check it out if you&amp;rsquo;re interested. For now, enjoy Newsletter #51.&lt;/em&gt;&lt;/p&gt;
&lt;h2 id="p-fast-trie-lexically-ordered-hash-map"&gt;&lt;a href="https://dotat.at/@/2025-08-04-p-fast-trie.html" rel="noopener noreferrer"&gt;p-fast trie: lexically ordered hash map&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Tony Finch sketches out a data structure idea that even he isn&amp;rsquo;t sure is actually a good one: the &amp;ldquo;p-fast trie,&amp;rdquo; a hash map that preserves the lexicographical order of its keys. Instead of maintaining a tree with internal pointers like a qp-trie, a p-fast trie stores every proper prefix of every key in a hash map partitioned by prefix length, where each prefix corresponds to an internal branch node. Keys are treated as bit strings sliced into 6-bit chunks; each internal node contains a 64-bit bitmap marking which next chunks exist, along with a popcount-compressed array pointing to the nearest preceding leaf. The leaves themselves are linked into a circular doubly linked list in sorted order, so finding the preceding leaf immediately gives you the succeeding one as well. As a result, exact lookups take a single O(1) hash map probe, while predecessor/successor queries use binary search over the prefix length, achieving O(log k) instead of O(k) like a qp-trie (where k is the key length).&lt;/p&gt;
&lt;p&gt;The author is candid about its weaknesses: a p-fast trie uses far more memory because it requires so many internal nodes, insertions and deletions must update multiple prefixes at once—making concurrent access hard to implement safely—and jumping around across long prefixes is much less friendly to CPU caches than a qp-trie. Its remaining advantage is that predecessor/successor searches only require one pass rather than two. A concise read for anyone interested in how an engineer weighs trade-offs when designing data structures.&lt;/p&gt;
&lt;h2 id="big-o-vs-hardware-better-complexity--better-performance"&gt;&lt;a href="https://blog.codingconfessions.com/p/big-o-vs-hardware" rel="noopener noreferrer"&gt;Big O vs Hardware: Better Complexity ≠ Better Performance&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Abhinav Upadhyay demonstrates that better asymptotic complexity does not guarantee faster execution on real hardware. He grounds his analysis in the &amp;ldquo;Iron Law&amp;rdquo; of processor performance: execution time depends on the number of instructions executed and the number of instructions the CPU completes per cycle (IPC). The article compares three algorithms for computing the greatest common divisor (GCD): Euclid&amp;rsquo;s subtraction algorithm at O(max(a, b)), Euclid&amp;rsquo;s modulo algorithm at O(log(max(a, b))), and Stein&amp;rsquo;s binary GCD algorithm. For very large inputs, the modulo version is roughly 10,000 times faster than the subtraction version. Yet for &lt;code&gt;a = 130000, b = 13&lt;/code&gt;, the subtraction version—despite looping nearly 10,000 times—finishes earlier than the modulo version, which needs only a single step, because on Intel Skylake integer addition/subtraction has a 1-cycle latency and can execute 4 instructions per cycle, whereas integer division has a latency of 42–95 cycles.&lt;/p&gt;
&lt;p&gt;Stein&amp;rsquo;s algorithm is much more hardware-friendly: it replaces division with bit shifts and trailing-zero counts, keeping the instruction count low while maintaining high IPC. In the author&amp;rsquo;s benchmark across number pairs in &lt;code&gt;[1, 100000)&lt;/code&gt; with a step of 5, Stein&amp;rsquo;s algorithm came out fastest; the modulo version executed the fewest instructions (13 billion) but achieved an IPC of just 0.15, making it the slowest overall, whereas the subtraction version executed 97 billion instructions and still finished 1.5 seconds earlier. The takeaway: Big O still matters at scale, but real-world speed requires understanding instruction costs on modern CPUs, profiling with tools like &lt;code&gt;perf&lt;/code&gt;, and considering hybrid algorithms tailored to input size.&lt;/p&gt;
&lt;h2 id="claude-code-is-all-you-need"&gt;&lt;a href="https://dwyer.co.za/static/claude-code-is-all-you-need.html" rel="noopener noreferrer"&gt;Claude Code Is All You Need&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Gareth Dwyer, a long-time &lt;code&gt;vim&lt;/code&gt; user, reflects on several weeks with Claude Code, Anthropic&amp;rsquo;s terminal-based AI coding tool, sharing three main takeaways: give it high autonomy (he runs it with permission prompts bypassed, even on live servers), feed it plenty of input because output quality scales with context, and note that it designs surprisingly good UIs. A standout example is SmartSplit, a Splitwise clone generated in one shot from a ~500-word specification file; still, the model remains inconsistent, and a vague spec produced a completely broken app. He also found the model writes PHP remarkably well and argues that frameworks exist mainly to serve humans rather than AI.&lt;/p&gt;
&lt;p&gt;According to the author, Claude Code&amp;rsquo;s power comes from a simple loop that calls the model repeatedly. He tried extending that loop into an &amp;ldquo;autonomous startup&amp;rdquo; on a VPS: Claude wrote its own prompts, picked an idea, and stood up a full web application complete with Nginx and TLS certificates—even though its product idea made no sense—before eventually getting blocked for violating usage policies. On real work, Claude Code helped him migrate an unfamiliar Laravel/MySQL application to a cheap VPS, saving an estimated 16–32 hours, though it still needed his supervision. Other projects included a Hacker News comment-scoring plugin, a poster generator, and categorizing bank statements. As for the article itself, he wrote nearly all of it by hand, finding that the model is much better at organizing existing material than at creative writing.&lt;/p&gt;
&lt;h2 id="http-is-not-simple"&gt;&lt;a href="https://daniel.haxx.se/blog/2025/08/08/http-is-not-simple/" rel="noopener noreferrer"&gt;HTTP is not simple&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Daniel Stenberg—author of &lt;code&gt;curl&lt;/code&gt;, with nearly three decades of writing client-side HTTP code and contributing to HTTP specifications at the IETF—pushes back against the notion that &amp;ldquo;HTTP is a simple protocol.&amp;rdquo; HTTP/1 looks approachable because it is human-readable text and anyone can &lt;code&gt;telnet&lt;/code&gt; into a server and type &lt;code&gt;GET&lt;/code&gt; by hand, but the machinery underneath is anything but simple. Headers are line-oriented with no specification limit on line length, terminated by CRLF (or sometimes bare LF), and consist of raw octets rather than UTF-8. Whitespace is mandatory in some places and optional in others, and tokens may or may not be quoted. There are at least three ways to determine where a response body ends (&lt;code&gt;Content-Length&lt;/code&gt;, chunked transfer encoding, &lt;code&gt;Connection: close&lt;/code&gt;)—the source of countless security vulnerabilities; parsing numbers in text form requires handling overflow, signs, and leading zeros; and headers can be combined or &amp;ldquo;folded&amp;rdquo; across multiple lines.&lt;/p&gt;
&lt;p&gt;On top of that, features exist in the spec that rarely work reliably in practice, such as pipelining or &lt;code&gt;100 Continue&lt;/code&gt; responses; sending a request body with &lt;code&gt;GET&lt;/code&gt; lacks broad interoperability (prompting the proposed &lt;code&gt;QUERY&lt;/code&gt; method); and browsers routinely guess user intent instead of rejecting malformed input, forcing other HTTP clients to mimic browser quirks rather than strictly following the spec. &amp;ldquo;HTTP/1.1&amp;rdquo; appears in at least 40 RFCs, and RFCs 9110–9112 alone run 95,740 words—over seven hours of nonstop reading. The author suggests complexity may simply be the price of success, as DNS and SMTP also started out simple before growing complex over time, and HTTP will only get more complex from here.&lt;/p&gt;
&lt;h2 id="building-a-web-search-engine-from-scratch-in-two-months-with-3-billion-neural-embeddings"&gt;&lt;a href="https://blog.wilsonl.in/search-engine/" rel="noopener noreferrer"&gt;Building a web search engine from scratch in two months with 3 billion neural embeddings&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Wilson Lin chronicles his two-month journey building a web search engine from scratch, motivated by two observations: traditional search results are increasingly overrun with SEO spam, while transformer-based text embedding models have become remarkably good at understanding natural language. His goal was to capture the intent of a full query rather than matching keywords. Web pages are normalized to strip out menus, footers, and comment sections, keeping only semantically meaningful prose, which is then split into sentences using spaCy; each sentence is augmented with context from section headings or lead-in lines before lists so indirect references don&amp;rsquo;t lose their meaning.&lt;/p&gt;
&lt;p&gt;At scale, a cluster of 200 GPUs generated 3 billion SBERT embeddings, while hundreds of crawlers peaked at 50,000 pages per second to index 280 million pages; RocksDB and HNSW were sharded across 200 CPU cores, 4 TB of RAM, and 82 TB of SSD storage, delivering end-to-end query latency around 500 ms. The post also explains why he had to abandon object storage and then PostgreSQL in favor of RocksDB, and how combining Hetzner, Oracle Cloud, and Runpod kept infrastructure costs dozens of times cheaper than AWS. His two biggest takeaways: quantity has a quality all its own, because a search engine is useless if it hasn&amp;rsquo;t indexed what you&amp;rsquo;re looking for; and crawling and content filtering are the hardest parts of the job. Next steps include leveraging Common Crawl, adopting static embedding models, rewriting the crawler in Rust, and curating a high-signal index.&lt;/p&gt;
&lt;h2 id="bonus-cool-diagrams-from-bytebytego"&gt;Bonus: Cool diagrams from &lt;a href="https://bytebytego.com/" rel="noopener noreferrer"&gt;ByteByteGo&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;img src="https://substack-post-media.s3.amazonaws.com/public/images/7136a64a-5300-4eed-852f-cdaf6cf73c6a_3000x3900.png" alt="What is the SOLID Principle?"&gt;
&lt;img src="https://substack-post-media.s3.amazonaws.com/public/images/fe53c806-a56f-4004-97e8-bbc6b5b9eb3d_3000x3900.jpeg" alt="Common HTTP Status Codes"&gt;
&lt;img src="https://substack-post-media.s3.amazonaws.com/public/images/db0481bd-807d-419c-a71e-913a13cb855e_1280x808.jpeg" alt="How Clean Architecture Works?"&gt;
&lt;img src="https://substack-post-media.s3.amazonaws.com/public/images/ba21dab1-a39e-4c3a-a815-08d8be09de49_2360x2492.png" alt="How does Docker Work?"&gt;
&lt;img src="https://substack-post-media.s3.amazonaws.com/public/images/7f891bc7-8657-47ff-8974-efcfcc0f0bb1_2250x2624.png" alt="A Guide to Top Caching Strategies"&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;&lt;em&gt;This post was rewritten by Claude Code with Opus 5.5 on 27/09/2026; reviewed and edited by Codex with GPT 6.1 Sol on 09/11/2026, and re-verified by Claude Code with Sonnet 5.5 on 16/11/2026.&lt;/em&gt;&lt;/p&gt;</description></item><item><title>Newsletter #14</title><link>https://miti99.com/en/post/2025/04/30/</link><pubDate>Wed, 30 Apr 2025 00:00:00 +0700</pubDate><guid>https://miti99.com/en/post/2025/04/30/</guid><description>&lt;p&gt;&lt;em&gt;Enjoy Newsletter #14.&lt;/em&gt;&lt;/p&gt;
&lt;h2 id="bloom-filter-a-deep-dive"&gt;&lt;a href="https://www.kirupa.com/data_structures_algorithms/bloom_filter.htm" rel="noopener noreferrer"&gt;Bloom Filter: A Deep Dive&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Kirupa Chinnathambi explains Bloom filters through a classic real-world problem: checking whether a username is already taken during sign-up on a social network with tens of millions of users. Scanning the database on every keystroke is too slow, while keeping every username string in an in-memory hash table eats up too much RAM. A Bloom filter sits in front of the database as a compact probabilistic gatekeeper: instead of storing the strings themselves, it stores bit &amp;ldquo;fingerprints&amp;rdquo; inside a fixed-size bit array. Each inserted item is run through $k$ independent hash functions, each mapping to an index in the array whose bit is flipped to &lt;code&gt;1&lt;/code&gt;. On lookup, if even a single one of those $k$ bits is &lt;code&gt;0&lt;/code&gt;, the item is guaranteed &lt;em&gt;not&lt;/em&gt; to exist; if all $k$ bits are &lt;code&gt;1&lt;/code&gt;, the item &lt;em&gt;might&lt;/em&gt; exist and you fall back to a database query, because other items may have happened to set those same bits (a false positive).&lt;/p&gt;
&lt;p&gt;The second half walks through the formulas for picking the optimal bit-array size $m$ and number of hash functions $k$ given an expected item count $n$ and target false-positive rate $p$. For 10 million usernames at a 1% false-positive rate ($p = 0.01$), a Bloom filter needs only about 95.85 million bits (~12 MB) and 7 hash functions—whereas an equivalent in-memory hash table would consume 160 MB to 240 MB, or 13x to 20x more memory. Trading a tiny, tunable chance of an extra database lookup for massive memory savings makes the Bloom filter one of the most practical probabilistic data structures in systems engineering.&lt;/p&gt;
&lt;h2 id="rethinking-llm-inference-why-developer-ai-needs-a-different-approach"&gt;&lt;a href="https://www.augmentcode.com/blog/rethinking-llm-inference-why-developer-ai-needs-a-different-approach" rel="noopener noreferrer"&gt;Rethinking LLM inference: Why developer AI needs a different approach&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Augment Code explains why AI coding assistants demand a fundamentally different LLM inference architecture than consumer chatbots: repository-aware coding requires feeding tens of thousands of tokens of codebase context into the model, and suggestion quality keeps climbing well past 10,000 input tokens. Unlike chat workloads (roughly ~100 input tokens to generate hundreds of output tokens), developer AI workloads are heavily &lt;strong&gt;prefill-dominated&lt;/strong&gt;—thousands of context tokens in, only a few dozen completion tokens out—whereas off-the-shelf engines like vLLM and TensorRT-LLM are tuned primarily for decode-heavy workloads. Because of this, Augment optimizes ruthlessly for prefill throughput and time-to-first-token (TTFT). After showing why single-token autoregressive decoding leaves GPUs below 1% compute utilization (memory-bandwidth bound), the post explains &lt;strong&gt;token-level batching&lt;/strong&gt; (known in academia as &lt;em&gt;chunked prefill&lt;/em&gt;), where lightweight decode steps &amp;ldquo;piggyback&amp;rdquo; onto another request&amp;rsquo;s compute-bound prefill batch, sized right at the ridge point between memory-bandwidth bound and FLOPS bound.&lt;/p&gt;
&lt;p&gt;The article also details production systems requirements like reliable request cancellation as a developer types rapidly, alongside low-level GPU optimizations: CUDA Graphs to eliminate CPU launch overhead, FP8 quantization, FlashAttention-3, and custom fused CUDA kernels. Together, these optimizations deliver a time-to-first-token under 300ms for a 10,000-token prompt on Llama 3 70B—a 3x speedup—while sustaining nearly 10 requests per second across an 8x H100 node. It&amp;rsquo;s a great case study in why LLM inference tuning has to match the exact input/output shape of your application.&lt;/p&gt;
&lt;h2 id="floyds-cycle-algorithm-fraud-detection-in-java-systems"&gt;&lt;a href="https://dzone.com/articles/floyds-cycle-algorithm-fraud-detection-java-systems" rel="noopener noreferrer"&gt;Floyd’s Cycle Algorithm: Fraud Detection in Java Systems&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;This DZone article illustrates how Floyd&amp;rsquo;s Cycle-Finding Algorithm (the &amp;ldquo;tortoise and the hare&amp;rdquo;) can be applied to spot circular money transfers in banking systems. Bank accounts are modeled as vertices and wire transfers as directed edges in a graph; a loop like &lt;code&gt;A → B → C → D → B&lt;/code&gt; forms a cycle, a classic pattern in money laundering (&amp;ldquo;round-tripping&amp;rdquo;) used to obscure the origin of funds. Floyd&amp;rsquo;s algorithm advances two pointers through the sequence—a slow pointer moving one step at a time and a fast pointer moving two steps at a time; if a cycle exists, the two pointers are guaranteed to meet inside the loop. The Java walkthrough provides a &lt;code&gt;TransactionGraph&lt;/code&gt; backed by a &lt;code&gt;HashMap&lt;/code&gt; adjacency list, a &lt;code&gt;FraudDetection&lt;/code&gt; cycle checker, and a test harness with sample transfer data.&lt;/p&gt;
&lt;p&gt;The appeal of Floyd&amp;rsquo;s algorithm is its simplicity, $O(N)$ time complexity, and $O(1)$ auxiliary memory footprint, making it attractive for lightweight real-time checks. However, an important caveat applies: Floyd&amp;rsquo;s tortoise-and-hare algorithm assumes each node has at most &lt;em&gt;one&lt;/em&gt; outgoing edge (a functional graph or linked list). In a general transaction graph where an account sends money to multiple recipients, following only a single outgoing edge per node can miss cycles on other branches—meaning full Depth-First Search (DFS) or Johnson&amp;rsquo;s/Tarjan&amp;rsquo;s strongly connected components algorithms are needed for general multi-branch graphs, and any detected cycle is merely a heuristic flag for deeper investigation rather than proof of fraud on its own. The post also notes applications in network routing loop detection, DNA motif analysis, ML pipelines, and blockchain transaction graphs.&lt;/p&gt;
&lt;h2 id="succinct-data-structures"&gt;&lt;a href="https://blog.startifact.com/posts/succinct/" rel="noopener noreferrer"&gt;Succinct data structures&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Martijn Faassen introduces &lt;strong&gt;succinct data structures&lt;/strong&gt;—a family of data structures he was delighted to discover. Like compression algorithms, they store data in space close to the information-theoretic minimum; unlike standard compression, however, you don&amp;rsquo;t need to decompress them before use—you can run fast queries directly on the compact representation. The foundational building block is a bitvector supporting two constant-time ($O(1)$) operations with tiny memory overhead: &lt;code&gt;rank&lt;/code&gt; (count how many &lt;code&gt;1&lt;/code&gt; bits appear up to index $i$) and &lt;code&gt;select&lt;/code&gt; (find the index of the $n$-th &lt;code&gt;1&lt;/code&gt; bit). From that primitive, a &lt;strong&gt;Wavelet Matrix&lt;/strong&gt; generalizes &lt;code&gt;rank&lt;/code&gt; and &lt;code&gt;select&lt;/code&gt; to larger alphabets like DNA bases or 256-byte text; an &lt;strong&gt;FM-index&lt;/strong&gt; enables compact full-text search that counts and locates substrings rapidly (widely used in bioinformatics); and &lt;strong&gt;balanced parentheses&lt;/strong&gt; bitvectors encode arbitrary trees using just &lt;em&gt;2 bits per node&lt;/em&gt; instead of bulky 64-bit pointers while still supporting fast navigation to parent, child, and sibling nodes.&lt;/p&gt;
&lt;p&gt;Faassen walks through an XML querying prototype he built by combining a balanced-parentheses tree with sparse bitvectors to jump straight to elements matching a specific tag name, and sketches how the same trick could shrink compiler ASTs in memory. He closes with pointers to Rust crates in this space, including &lt;code&gt;vers&lt;/code&gt; (blazing fast with minimal overhead), &lt;code&gt;sucds&lt;/code&gt; (offering sparse bitvectors like &lt;code&gt;SArray&lt;/code&gt;), and &lt;code&gt;fm-index&lt;/code&gt;. Though still relatively niche outside bioinformatics, succinct data structures hold huge promise anywhere fitting a working set into CPU cache or RAM is the key to speed.&lt;/p&gt;
&lt;h2 id="the-art-of-engineering-team-focus-less-is-more"&gt;&lt;a href="https://github.com/resources/insights/engineering-team-focus" rel="noopener noreferrer"&gt;The art of engineering team focus: less is more&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;This GitHub Resources piece makes a counterintuitive case: if you want your engineering team to ship &lt;em&gt;more&lt;/em&gt;, they need to work on &lt;em&gt;fewer&lt;/em&gt; things at the same time. Unshipped work delivers zero value to users, yet leaders often struggle to say &amp;ldquo;no&amp;rdquo; to stakeholders, slicing the team across half a dozen parallel initiatives under the illusion that everything is moving forward. The antidote starts with making all work visible so leadership confronts the team&amp;rsquo;s true capacity and actively kills or pauses lower-priority tracks; breaking projects into 1–2 week milestones to keep momentum high, shrink pull requests, de-risk deployments, and create natural pivot points; and strictly limiting Work in Progress (WIP), since every context switch can cost up to 23 minutes to regain deep focus while driving up bug rates and burnout.&lt;/p&gt;
&lt;p&gt;The author goes further and recommends &amp;ldquo;stacking&amp;rdquo; engineers onto the single highest-priority initiative until adding another person would literally cause them to trip over one another, and only then staffing the #2 priority. Finally, never plan a team to 100% utilization—leave roughly a 20% capacity buffer to absorb unexpected bugs and production interrupts, because a highway at 100% capacity is a parking lot. Teams with slack in the system consistently ship faster, innovate more, and burn out less.&lt;/p&gt;
&lt;h2 id="performance-optimization-and-how-to-do-it-wrong"&gt;&lt;a href="https://genna.win/blog/convolution-simd/" rel="noopener noreferrer"&gt;Performance optimization, and how to do it wrong&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The author, a contributor to the Rust &lt;code&gt;burn&lt;/code&gt; machine learning framework, shares a humbling war story about optimizing direct 2D CPU convolution using SIMD intrinsics. Even after implementing an academic paper&amp;rsquo;s optimal loop ordering and register blocking scheme, the new SIMD kernel ran more than &lt;em&gt;twice as slow&lt;/em&gt; as the naive baseline. Standard profilers like &lt;code&gt;cargo-flamegraph&lt;/code&gt;, &lt;code&gt;samply&lt;/code&gt;, and AMD μProf couldn&amp;rsquo;t pinpoint why, forcing the author to strip the kernel down piece by piece to isolate the regression. The culprits turned out to be a combination of &lt;strong&gt;SIMD register spilling&lt;/strong&gt; (x86 AVX2 provides only 16 YMM registers) and &lt;strong&gt;excessive branching inside the hot inner loop&lt;/strong&gt; to handle boundary padding. Splitting the loop into a branchless fast path for interior pixels and a separate edge path—plus using compile-time monomorphization (const generics) to specialize common cases like zero padding or stride 1—brought massive speedups.&lt;/p&gt;
&lt;p&gt;The biggest plot twist came from the Rust compiler itself: adding one more specialized branch pushed the outer function past LLVM&amp;rsquo;s inlining size threshold, causing the compiler to stop inlining the inner SIMD routines and tanking performance all over again. Adding &lt;code&gt;#[inline(always)]&lt;/code&gt; to the top-level functions immediately restored the speedup. It&amp;rsquo;s a classic lesson in low-level optimization: measure everything, understand your hardware&amp;rsquo;s register file, and never assume the compiler is doing what you think it&amp;rsquo;s doing.&lt;/p&gt;
&lt;h2 id="supercharging-discord-mobile-our-journey-to-a-faster-app"&gt;&lt;a href="https://discord.com/blog/supercharging-discord-mobile-our-journey-to-a-faster-app" rel="noopener noreferrer"&gt;Supercharging Discord Mobile: Our Journey to a Faster App&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Discord shares a sweeping set of mobile performance improvements for their React Native app, aimed especially at power users in hundreds of servers. First, they virtualized the server list so only on-screen server icons stay mounted in memory, cutting startup memory usage by 14% and cold-start time by 10% for users in 100+ servers. For the chat message list (already a native component), they overhauled view recycling, lazily initialized rarely used message attachments, and pre-populated the recycle pool at startup with common row types—reducing slow frames by up to 60% and trimming memory by ~12%. On Android, they rewrote the emoji picker completely in native Kotlin views to eliminate blank white flashes during fast fling scrolls on budget devices, and switched animated emojis from GIF to WebP to hit a smooth 60 FPS.&lt;/p&gt;
&lt;p&gt;For the channel list, the team actually migrated &lt;em&gt;back&lt;/em&gt; from Shopify&amp;rsquo;s &lt;code&gt;FlashList&lt;/code&gt; to their own in-house &lt;code&gt;FastList&lt;/code&gt; after finding that &lt;code&gt;FlashList&lt;/code&gt; frequently rendered blank cells on low-end Android phones, and went on to build &lt;code&gt;FastestList&lt;/code&gt; backed by Android&amp;rsquo;s native &lt;code&gt;RecyclerView&lt;/code&gt;. On iOS, the media picker now displays a fast low-resolution thumbnail first while streaming in the high-res asset and requests 256×256 previews to hit Apple PhotoKit&amp;rsquo;s fast system cache, eliminating a 4.5-second freeze when opening large camera rolls. Looking ahead to 2025, Discord plans to enable React Native&amp;rsquo;s New Architecture, experiment with Static Hermes, and move core client state logic to Rust.&lt;/p&gt;
&lt;h2 id="git-without-a-forge"&gt;&lt;a href="https://www.chiark.greenend.org.uk/~sgtatham/quasiblog/git-no-forge/" rel="noopener noreferrer"&gt;Git without a forge&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Simon Tatham, creator of PuTTY, explains why he still hosts his open-source projects on plain bare Git repositories on his own server rather than moving to a web forge like GitHub or GitLab. He trusts machines administered by friends more than corporate platforms whose ownership and policies can shift overnight; he has no desire to sysadmin a heavy self-hosted forge instance himself; he dislikes how forges bake in rigid opinions about issue tracking and pull-request workflows; he doesn&amp;rsquo;t want to force drive-by contributors to register yet another web account just to send a patch; and he worries about platform lock-in trapping years of issue and PR discussions outside the Git repository itself. He also candidly admits that sheer inertia plays a part.&lt;/p&gt;
&lt;p&gt;In the second half, Tatham ranks ways contributors can send him patches without a forge, from best to worst: sending a public Git repo URL and branch name he can &lt;code&gt;git fetch&lt;/code&gt; directly (giving all the benefits of a pull request with zero forge lock-in), emailing a &lt;code&gt;git bundle&lt;/code&gt; binary file containing the exact commits, attaching files generated by &lt;code&gt;git format-patch&lt;/code&gt;, sending a raw &lt;code&gt;git diff&lt;/code&gt; (which loses commit messages and base-commit metadata), and dead last, &lt;code&gt;git send-email&lt;/code&gt;, which turns a patch series into a burst of separate emails he has to reassemble by hand. While he acknowledges that public forges help newcomers gauge how welcoming a project is from past PR threads, he remains holding out for a lightweight, decentralized code-review protocol that keeps discussion portable.&lt;/p&gt;
&lt;h2 id="40-thoughts-on-turning-40"&gt;&lt;a href="https://newsletter.pathlesspath.com/p/40-thoughts-on-turning-40-287" rel="noopener noreferrer"&gt;40 Thoughts On Turning 40&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Paul Millerd, author of &lt;em&gt;The Pathless Path&lt;/em&gt;, shares 40 reflections on turning 40, spanning reinvention, work, money, relationships, fatherhood, and happiness. Looking back, he considers walking away from a conventional high-status consulting career into uncertainty the defining decision of his 30s, noting that real personal transformation is slow, messy, and gradual rather than a single cinematic epiphany. On work, he argues that the FIRE movement&amp;rsquo;s dream of &amp;ldquo;escaping work&amp;rdquo; through early retirement misses the point: you don&amp;rsquo;t transcend work by avoiding it, you transcend it by finding &lt;strong&gt;good work&lt;/strong&gt;—work that feels meaningful both in the moment and in hindsight. Everyone should try freelancing or self-employment for at least a year, he suggests, adding that taking a steep pay cut after quitting his corporate job was the fastest way to discover what he actually valued.&lt;/p&gt;
&lt;p&gt;On life outside work, he reflects on how lucky he feels to have met his wife and encourages anyone still looking for a partner not to give up, while calling fatherhood the most humbling experience of his life. His closing thoughts are pithy reminders: following breaking news has never made anyone happier, deep rest is a skill that takes practice, &amp;ldquo;doing less&amp;rdquo; is the most underrated way to get unstuck, and writing in public remains one of the most powerful forces for personal clarity—even if it forces you to confront what you truly want.&lt;/p&gt;
&lt;h2 id="bonus-interesting-images-from-bytebytego"&gt;Bonus: Interesting images from &lt;a href="https://bytebytego.com/" rel="noopener noreferrer"&gt;ByteByteGo&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;img src="https://substack-post-media.s3.amazonaws.com/public/images/f7fc4f19-ebd8-45a0-9398-469805bb4a26_1280x1532.gif" alt="A Cheatsheet on Comparing Key-Value Stores"&gt;
&lt;img src="https://substack-post-media.s3.amazonaws.com/public/images/16fe4308-ed47-451f-a852-c476ecfb4167_1280x1977.jpeg" alt="A Handy Cheatsheet for the Most Popular Cloud Services"&gt;
&lt;img src="https://substack-post-media.s3.amazonaws.com/public/images/89a09e07-6548-4c12-87c6-0486c6177ea7_1308x1536.jpeg" alt="Which Database Should I Use on AWS?"&gt;&lt;/p&gt;
&lt;h2 id="bonus-2-interesting-videos-from-bytebytego"&gt;Bonus 2: Interesting videos from &lt;a href="https://bytebytego.com/" rel="noopener noreferrer"&gt;ByteByteGo&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=hFURlsMwU7c" rel="noopener noreferrer"&gt;What Is the Most Popular Open-Source AI Stack?&lt;/a&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;&lt;em&gt;This post was rewritten by Claude Code with Opus 5.5 on 27/09/2026; reviewed and edited by Codex with GPT 6.1 Sol on 09/11/2026, and re-verified by Claude Code with Sonnet 5.5 on 16/11/2026.&lt;/em&gt;&lt;/p&gt;</description></item></channel></rss>