Visualizers

Learn by moving things

Interactive explainers for the ideas behind retrieval, embeddings, and agents. A formula tells you what is true; dragging a vector shows you why. Each one also appears inside the article it belongs to, and runs entirely in your browser, so drag, poke, and break it.

Portrait of Sachin Gupta rendered in binary

Only the first request that misses takes a lock and goes to the database; the rest wait for it instead of piling on. One query refills the cache and everyone waiting shares the result.

Locking: one fetches for everyoneauto
requestscacheempty, lockeddatabase1 query1st request holds the lockwaitwaitwaitwait

On the miss, only the first request takes a lock and goes to the database. The other four see the lock and wait instead of piling on. The database gets one query.

On expiry, keep serving the slightly stale value so nobody waits, and kick off a single background refresh. No request is blocked and the database takes exactly one query.

Stale-while-revalidate: serve old, refresh behindauto
requestscachestale, still serveddatabase1 query1 background refresh

On expiry, keep serving the slightly stale value to everyone immediately, so nobody waits, and kick off a single background refresh to the database.

As the TTL runs down, each request has a small, rising chance of refreshing early in the background. One volunteers before the timer hits zero, so the key is never empty and the herd never forms.

Early expiration: refresh before the crowdauto
time to live5s left
chance a request refreshes early8%

The key still has plenty of time to live, so the chance any request refreshes early is tiny. Everyone just hits the cache.

Visualizers — Sachin Gupta