Work in progress: 181,232 of 181,233 sites checked so far, more every week · updated 2 Nov 2026Missing a blog? Tell us

Top all-time · #3304

E

Experiments in program optimisation ququMy blogwewe

Personal blog · pzemtsov.github.ioprogrammingsystems

Experiments in program optimisation ququMy blogwewe is a personal blog at pzemtsov.github.io about programming and systems. Since 2014, 23 different Hacker News readers have linked it 27 times, most often “A bug story: data alignment on x86”. The last post was in 2019, but the archive is still widely read.

Visit the blog
27mentions?
23HN people?
2014–2026first – last linked?
Links on Hacker News per year · peak 6 in 2017

Too few sampled comments (11) to say how often HN recommends it.?

Why HN links it

HN commenters link this blog for low-level performance and C pitfalls, especially its alignment bug story, and cite posts on syscalls, mmap, Game of Life hash tables and C-to-fast optimisation.

Summarised by Claude from a sample of 11 HN comments that link here. Each comment is marked recommending, critical or neutral (citing without judging); how this works.

Most-linked posts?

  1. A bug story: data alignment on x86
    6 people · 6 mentions · first linked 2016-11-07
  2. A bug story: data alignment on x86 (2016)
    4 people · 4 mentions · first linked 2019-07-05
  3. The slow currentTimeMillis()
    3 people · 4 mentions · first linked 2017-07-24

What Hacker News says?

  1. I think syscalls are not as slow as many people imagine they are, especially with modern CPUs and kernels (there are special instruction for syscalls that are faster than the old "interrupt" approach). See here: http://pzemtsov.github.io/2017/07/23/the-slow-currenttimemil... ("Off-topic: A system call"). But they will be slow with this mitigation.

    Comment linking /2017/07/23/the-slow-currenttimemillis.html

    on “Linux page table isolation is not needed on AMD processors”
  2. Submitted The slow currentTimeMillis() as a story · 323 points

    HN discussion
  3. Oh I see you didn't get to caveat 5: you can't read anything more complicated than raw bytes, i.e. chars, because of unaligned memory access errors. Let's say you mmap a file and do something like this: char *fileContents=...mmap etc...; int headerOffset=*(int*)fileContents; int *someListOfNumbers=(int*)(fileContents+headerOffset); int importantSum= someListOfNumbers[0] + someListOfNumbers[1] + someListOfNumbers[2]…

    Comment linking /2016/11/06/bug-story-alignment-on-x86.html

    on “Use mmap with care”
  4. Submitted A bug story: data alignment on x86 as a story · 151 points

    HN discussion
  5. Did you consider something like the following to speed up the calculation? This method can go forward _really_ fast. Not sur e if it can also go backward... https://pzemtsov.github.io/2015/04/24/game-of-life-hash-tabl...

    Comment linking /2015/04/24/game-of-life-hash-tables-and-hash-codes.html

    on “Finding Mona Lisa in the Game of Life”
  6. Submitted A bug story: data alignment in C on x86 (2016) as a story · 134 points

    HN discussion
  7. I believe the article was http://pzemtsov.github.io/2017/07/23/the-slow-currenttimemil... Although I couldn't easily find it in my history or on HN. I had to resort to the Googles.

    Comment linking /2017/07/23/the-slow-currenttimemillis.html

    on “How I implemented my own crypto”
  8. Submitted Abnormal String Hashing as a story · 52 points

    HN discussion
  9. > I am often mystified when people say C is "hard" Here are some examples of why people say C is hard: https://pzemtsov.github.io/2016/11/06/bug-story-alignment-on... https://blog.regehr.org/archives/1520 https://www.imperialviolet.org/2016/06/26/nonnull.html

    Comment linking /2016/11/06/bug-story-alignment-on-x86.html

    on “D as a C Replacement”
  10. Submitted A bug story: data alignment on x86 (2016) as a story · 40 points

    HN discussion
  11. > Optimizers don't look for undefined behaviour to then do whatever, they look for the set of defined behaviours and then try to generate the cheapest code that behaves correctly in all those cases--and if that means that undefined cases do weird stuff, that's an acceptable side effect. > if any of the bytes are not inside any valid C object, then that would produce undefined behaviour The compiler might also assume…

    Comment linking /2016/11/06/bug-story-alignment-on-x86.html

    on “A Branchless UTF-8 Decoder”
  12. Submitted Game of Life, hash tables and hash codes as a story · 34 points

    HN discussion
  13. > creating a super-optimized tight loop of a program in C++, C or (better) assembly might be much easier to do than in higher level JITted languages Sometimes, the situation is exactly opposite, though: http://pzemtsov.github.io/2014/05/15/how-to-make-C-as-fast-a...

    Comment linking /2014/05/15/how-to-make-C-as-fast-as-java.html

    on “Java vs. Scala: Divided We Fail”
  14. Submitted Making a fast char searcher in C as a story · 3 points

    HN discussion
  15. > I like the idea of software, libraries and application code all being accessible to each other and have the ability to call each other. Too much functionality is siloed behind application A or B, and the interface exposed by these applications is often woefully inadequate for anything interesting. Maybe I'm skeptical, but I've gotten to the point where I believe that this specific problem is not going to be solved…

    Comment linking /2016/11/06/bug-story-alignment-on-x86.html

    on “The Early History Of Smalltalk (1993)”
  16. Submitted Statistical variables in Java: not quite legal but very fast as a story · 3 points

    HN discussion
  17. oconnor663 · 2018-11-04Recommends
    > A compiled binary that worked correctly won't suddenly run into undefined behaviour, that can only happen if you upgrade compiler versions... Upgrading the compiler version and causing undefined behavior sounds pretty sudden. Here's my favorite story along those lines: http://pzemtsov.github.io/2016/11/06/bug-story-alignment-on-...

    Comment linking /2016/11/06/bug-story-alignment-on-x86.html

    on “A Guide to Undefined Behavior in C and C++ (2010)”
  18. Submitted Building a fast queue between C++ and Java as a story · 2 points

    HN discussion
  19. Interestingly enough, I've just checked the code from this article ( https://pzemtsov.github.io/2016/11/06/bug-story-alignment-on... ), linked by the OP's article, and guess what - CLANG generates code that does not crash, although it still uses SSE4.

    Comment linking /2016/11/06/bug-story-alignment-on-x86.html

    on “GCC always assumes aligned pointer accesses”
  20. Submitted The slow currentTimeMillis() as a story · 2 points

    HN discussion
  21. A concrete example of undefined behavior caused by an unaligned pointer: https://pzemtsov.github.io/2016/11/06/bug-story-alignment-on...

    Comment linking /2016/11/06/bug-story-alignment-on-x86.html

    on “Everything in C is undefined behavior”
  22. Submitted Home-made hash tables in Java as a story · 2 points

    HN discussion
  23. Submitted Demultiplexing of E1 Streams as a story · 1 points

    HN discussion
  24. Submitted Building a fast queue between C++ and Java (2018) as a story · 1 points

    HN discussion
  25. Submitted Searching for a Better IndexOf as a story · 1 points

    HN discussion
  26. Submitted The slow currentTimeMillis() as a story · 1 points

    HN discussion
  27. Submitted Searching in a constant set using conflict-free hashing as a story · 1 points

    HN discussion

Search all of HN for pzemtsov.github.io

Linked by the same people?