Blog
Notes on data structures & algorithms, system design, and things I learn along the way.
Learning DSA? Follow the structured path — ordered articles from recursion to dynamic programming.→Most RAG failures are retrieval failures, not generation failures. How chunking and embeddings decide what the model ever sees, the similarity-is-not-relevance trap, and what actually fixes it.
The window is a budget you refill from scratch every turn. Where the tokens actually go in an agent, why prompt caching is a prefix match, and the difference between clearing context and compacting it.
A naive retry loop is a denial-of-service attack you wrote yourself. Exponential backoff, why jitter matters more than the backoff, idempotency, and retry budgets.
Replication copies the same data; sharding splits different data. What each one actually buys you, how routing and failover behave, and the problems sharding creates that you have to live with.
A tool is a name, a description, and a JSON Schema — and the description is prompt text that gets read every turn. Schema design, validation, error messages that repair, and why fewer tools work better.
One extra term in the priority function turns an exhaustive search into a guided one. What admissible and consistent heuristics mean, why they preserve optimality, and where A* degrades.
An agent is a while loop around a stateless API. What stop_reason really controls, why the transcript is resent on every turn, and the failure modes that show up once tools are in the mix.
Precompute once, answer range queries in O(1). How prefix sums work, the sentinel zero that removes every edge case, difference arrays for range updates, and the 2D version.
A stack that refuses to hold out-of-order values turns a pile of quadratic problems into linear ones. How the invariant works, why the amortised cost is O(n), and the four questions it answers.
Adding a cache in front of a database is easy. Deciding when the cache gets populated and how writes stay consistent with the source of truth is where cache-aside, write-through, write-back and refresh-ahead diverge. Plus the stale-read race in cache-aside, TTLs, eviction policies, cache layers, and how to tell whether a cache is working.
202 posts · page 16 of 21