Skip to content
HomeVideosBooksBlogs
AllTop postsTopics
Podcasts
HistoryListsWatch laterLiked videosFollowing

The videos, books, blogs and podcasts Hacker News keeps recommending, all in one place.

VideosBooksBlogsPodcastsAboutPrivacySettings

Data from Hacker News, HackerTube, HackerBooks, HackerBlogs and Open Library. Credits · Not affiliated with Y Combinator.

HomeVideosBooksBlogsPodcasts
Ctrl K
    U

    Ulrich Drepper

    akkadia.org · Personal blog · on HN since 2010

    Ulrich Drepper, a longtime glibc maintainer, publishes technical papers on memory, shared libraries, thread-local storage, and futexes.

    Visit blogHN submissions
    Systems & PerformanceOpen Source & LinuxProgramming
    What HN says

    Commenters call his memory paper a fantastic read despite its clickbaity title, and link his TLS write-up and his static linking views.

    Stats for nerds
    97HN people shared it
    28linked in comments
    372story points
    Feb 2025last shared
    2012people per year2025

    Top posts on HN

    1. 1
      What Every Programmer Should Know About Memory (2007) [pdf]
      41 people · 234 points · first shared 2011 · 97 comments on HN
    2. 2
      How to Write Shared Libraries (2011) [pdf]
      22 people · 81 points · first shared 2010 · 1 comments on HN
    3. 3
      Static Linking Considered Harmful (2004)
      14 people · 51 points · first shared 2012 · 71 comments on HN
    4. 4
      Defensive Programming for Red Hat Enterprise Linux (2009) [pdf]
      1 person · 2 points · first shared 2014 · Discussion on HN
    5. 5
      Units in C++
      1 person · 2 points · first shared 2015 · Discussion on HN
    6. 6
      Unix crypt with SHA-256/512 (why bcrypt is not in glibc)
      3 people · 1 points · first shared 2011 · Discussion on HN
    7. 7
      Number of Threads to Create
      1 person · 1 points · first shared 2019 · 1 comments on HN
    8. 8
      Tls.pdf
      5 people · first shared 2015
    9. 9
      SHA crypt
      4 people · first shared 2012
    10. 10
      Drepper
      3 people · first shared 2012

    What HN people wrote when they linked it

    • nulltypeApr 2015

      I think this may be just how most programming (and perhaps everything else besides science experiments) has to be done.

      If you're writing assembly code, well, computers have some pretty solid low level abstractions, but do you really understand how many clock cycles that instruction there is going to take? What about all the error cases?

      If you're writing for the web, it's clear you can't even try to really understand how everything works in all cases across all machines.

      Few programmers really understand how computer memory works, but if everyone were to read this guide (http://www.akkadia.org/drepper/cpumemory.pdf) and really learn it throughly, the net benefit probably wouldn't be that great vs other things they could do with that time.

      It's great fun to track down every last misunderstanding or bug, but it's probably not worth it over the long term. The benefit of learning the internal details of a reliable subsystem is often not worth it and it's easier to just use it and get on with the project.

      That being said, when I do go to fix a bug, I try to get to the bottom of why it happens and not just stop at the first change that works. This is useful for a number of reasons:

      1) If you made the bug, you probably have some misunderstanding of the system that will be fixed when you understand the bug.

      2) If you're spending your time fixing an actual bug, then the misunderstanding empirically matters because this mistake has been made and actually affects someone.

      3)…

    • jlokierJul 2023

      snprintf_l() is not standard, but you can simulate it with uselocal() to save and restore the per-thread locale, which is standard (POSIX.1-2008) and supported by Glibc, FreeBSD, MacOS and other OSes, though Windows requires its own, different way of doing per-thread locale.

      It seems it was once an explicit design choice in Glibc. Here (https://sourceware.org/bugzilla/show_bug.cgi?id=10891) a Glibc ticket refers to documentation "Thread-aware Local Model, A Proposal" of the plans for the _l() functions (https://akkadia.org/drepper/tllocale.ps.gz) long ago, which are nowadays implemented in Glibc.

      It looks like snprintf_l() and other <stdio.h> functions were not part of that plan.

      That plan or something like it also made its way into POSIX.1-2008, so it seems likely that the committee gave some thought to including strftime_l() and not snprintf_l().

      The paper linked above includes a rationale that tiny, potentially performance-critical functions like isalpha() need a fast version that takes a local parameter, thus isalpha_l(), because of the overhead of fetching a thread-local value inside the function.

      Perhaps the intent is that only those tiny functions, or even macros, whose performance would be greatly affected by the cost of fetching the thread-local locale, need a _l() version. That mostly makes sense for the functions which have _l() versions in Glibc. But with that rationale, I don't see why there is strftime_l() but not snprintf_p().

    • kevindqcApr 2017

      There are "stream" instructions available on some CPU. These instructions tell the CPU to store data, but not to load it into a cache line (it might actually load it into a temporary cache line that is not part of the normal cache lines, depending on architecture). This is useful is you are writing data to memory but don't read it - there's no point in loading that data to the cache line since you will not access it again.

      One such instruction can be used with the _mm_stream_si128 intrinsic:

      void _mm_stream_si128(__m128i *p, __m128i a);

      Stores the data in a to the address p without polluting the caches. If the cache line containing address p is already in the cache, the cache will be updated. Address p must be 16 byte aligned.

      Learned about it in "What every programmer should know about memory":
      https://www.akkadia.org/drepper/cpumemory.pdf

      It's from 2007, but still relevant and a good read.

    • cpleppertFeb 2013

      The large pages feature (huge pages) still works the same way but the transparent huge pages patch has been integrated recently: http://www.slideshare.net/raghusiddarth/transparent-hugepages-in-rhel-6

      I personally wouldn't mess with the VM settings the way the author suggests. I don't remember doing that eight years ago anyway even with less RAM on a desktop. On a server you want the working set to fit in RAM anyway and the page cache is already pretty smart.

      The best resource is a general kernel book: http://www.amazon.com/Linux-Kernel-Development-3rd-Edition/dp/0672329468/ref=sr_1_1?ie=UTF8&qid=1360543016&sr=8-1&keywords=linux+kernel

      in terms of the interaction between memory, the cpu, and virtual memory What every Programmer should know about memory should be required reading: http://www.akkadia.org/drepper/cpumemory.pdf

    • pjc50Feb 2025

      I think this, and all the other weirdness, is because usage of thread-local variables is pretty low. Probably somebody wanted to have "lightweight" threads doing work as quickly as possible accessing only local variables.

      Edit: ah, see https://www.akkadia.org/drepper/tls.pdf which I was clued into by https://news.ycombinator.com/item?id=43079061

      The situation is much more complicated than it sounds, because the question of where the variables are isn't known at compile time. It has to be done at link time. Which may include dynamic link time as a library is loaded. That all sounds fairly horrible.

      All to handle static constructors. If you don't have thread-static variables, or they don't have constructors, it's much simpler.

    • sho_hnMay 2012

      If you want to read something more approachable that can serve as a gateway to this, I highly recommend Jon Stokes' Inside the Machine. It goes over microprocessor architecture in a very approachable way, and contains a good chapter on the memory/cache hierarchy that is sort of the light version of a good chunk of Drepper's paper, or at least will be a big help in making sense of it. If you've never been close to the metal, or you want to catch up on newer developments, consider checking it out.

      Also, here's Drepper's paper compiled into a single PDF, which I think was edited a little later than the LWN publication and might have had some minor errata fixes: http://www.akkadia.org/drepper/cpumemory.pdf

    Related

    John Regehrblog.regehr.org401 people

    Teaching C

    John Regehr
    Personal · last shared 2026
    Easyperfeasyperf.net36 people

    Precise timing of machine code with Linux perf

    Easyperf
    Personal · last shared 2026
    Karl Ruppkarlrupp.net16 people

    40 Years of Microprocessor Trend Data (2015)

    Karl Rupp
    Personal · last shared 2025
    Davin McCalldavmac.wordpress.com16 people

    Why do we keep building rotten foundations?

    Davin McCall
    Personal · last shared 2023
    Arm Community Blogcommunity.arm.com147 people

    An update on GNU performance

    Arm Community Blog
    Company · last shared 2025
    Ralf Jungralfj.de99 people

    There is no memory safety without thread safety

    Ralf Jung
    Personal · last shared 2026
    Poul-Henning Kampphk.freebsd.dk63 people

    You're doing it wrong: B-heap 10x faster than binary heap (2010)

    Poul-Henning Kamp
    Personal · last shared 2026
    Hans Wennborghanshq.net29 people

    Zip Files: History, Explanation and Implementation

    Hans Wennborg
    Personal · last shared 2026