proomt

Search

Search posts, papers, and topics

Hall of Fame

Hall of FameUlrich Drepper2007397 min readpaperadvanced

What Every Programmer Should Know About Memory

Summary

The paper explains how modern CPU caches, memory controllers, and NUMA architectures affect program performance and what developers can do to write cache‑friendly code. It provides concrete advice and tooling to reduce cache misses, avoid false sharing, and place memory near the accessing cores.

  • Cache lines are typically 64 B; accessing data with strides larger than this causes many cache misses—organize data for spatial locality.
  • False sharing degrades multi‑threaded performance; keep per‑thread data on separate cache lines or pad structs.
  • On NUMA systems, allocate memory on the node where the thread runs (e.g., numa_alloc_onnode) to avoid remote memory latency.
  • Use profiling tools like perf, OProfile, or cachegrind to locate cache‑miss hotspots and verify cache‑friendly access patterns.

Performance‑critical software engineers should understand these memory details to write faster, more scalable code on commodity hardware.

7/10

Related reading

  1. Textbook review: Is Parallel Programming Hard, And, If So, What Can You Do About It?

    A detailed, personal review of Paul McKenney’s free online textbook on parallel programming. The author, coming from a TLA⁺/distributed‑systems background, finds the early chapters excellent for building intuition about CPU caches, memory ordering, and false‑sharing, but notes gaps (e.g., shallow coverage of C++11 atomics and MESI). The review is concrete, cites specific chapters, and offers prac…

    Lobstersahelwer.ca8 minlobste.rs48
  2. Shared Selective Persistent Memory for Agentic LLM Systems

    Apple proposes a memory architecture for agentic LLMs that selectively persists reusable context (specs, schemas, configs, constraints) across sessions and users. Shared workspaces with role‑based access and a zero‑token data‑refresh mechanism cut token usage by 97×, reduce task time by 14×, and raise task‑completion rates to 96% versus 71%‑79% for baselines.

    Apple Machine Learning Researchapple.com1 minpaper
  3. Article: Your Next DSL Author Is a Language Model

    Typed Domain Grounding (TDG) embeds a DSL inside a mainstream language the LLM already knows (e.g., Kotlin) and uses the host compiler as an oracle. The author describes five building blocks—embedding, choosing a host language with high training‑data frequency, compiler‑driven type safety, a generate‑compile‑repair loop, and an on‑demand teaching tool—and shows measured results from kUML, a Kotli…

    InfoQinfoq.com18 min
  4. Accurate Models of AMD Matrix Cores

    The authors reverse‑engineer AMD’s CDNA matrix cores, build per‑architecture MATLAB models that match hardware bit‑for‑bit on 10 M random tests, and use them to compare AMD vs NVIDIA tensor‑core accuracy.

    Hacker News front pagearxiv.org2 minpaperHN7911
  5. Lies, Damn Lies and Benchmarks

    Codename One engineers dissect why benchmark numbers can be misleading, then share concrete work on GC tuning, proper weak/soft references, and a new probing sequence for their open‑addressed HashMap that cuts miss‑probe counts from >16 k to ~1.5 per lookup.

    CodeName Onecodenameone.com20 min