Daniel Lemire

lemire.me · Personal blog · on HN since 2010

Daniel Lemire, a computer science professor, writes about squeezing speed out of software, covering SIMD, number parsing, and low-level optimization.

What HN saysCommenters note his skill at getting performance from hardware, call his blog well worth reading, and say his technique explanations are easy to follow.
500HN people shared it
208linked it in comments
1.3Kstories submitted
20Kstory points
2 months agolast shared
2010people per year2026

Most-shared posts

  1. 1
    Reusing a thread in C++ for better performance
    27 people · 3 points · first shared 2016 · discussion on HN
  2. 2
    A fast alternative to the modulo reduction (2016)
    17 people · 188 points · first shared 2016 · 35 comments on HN
  3. 3
    Fast Float Parsing in Practice
    11 people · 8 points · first shared 2020 · discussion on HN
  4. 4
    Data alignment for speed: myth or reality? (2012)
    10 people · 5 points · first shared 2015 · discussion on HN
  5. 5
    I do not use a debugger (2016)
    9 people · 204 points · first shared 2016 · 182 comments on HN
  6. 6
    AVX-512: when and how to use these new instructions
    9 people · 188 points · first shared 2018 · 52 comments on HN
  7. 7
  8. 8
  9. 9
    Why I still program
    7 people · 26 points · first shared 2011 · 1 comments on HN
  10. 10
    How fast is C++26's std:hive?
    7 people · 10 points · first shared 2026 · discussion on HN
  11. 11
    En
    7 people · first shared 2017
  12. 12
    The Go Compiler Needs to Be Smarter
    6 people · 174 points · first shared 2020 · 117 comments on HN
  13. 13
    The dangers of AVX-512 throttling: a 3% impact
    6 people · 16 points · first shared 2018 · 4 comments on HN
  14. 14
    SWAR explained: parsing eight digits
    6 people · 3 points · first shared 2022 · discussion on HN
  15. 15

What HN people wrote when they linked it

tosh · 2026-06-06
nb: poster is Daniel Lemire (https://lemire.me), who is very skilled in getting performance out of compute hardware (e.g. via simd, cache usage etc)
youngtaff · 2024-12-24
Lemire’s blog is well worth a read if you’re interested in this sort of thing https://lemire.me/blog/
ftrobro · 2024-10-14
Integers are simple to parse, but from_chars is a great improvement when parsing floats. It's more standardized on different platforms than the old solutions (no need to worry about the locale, for example whether to use comma or dot as decimals separator) but also has more reliable performance in different compilers. The most advanced approaches to parsing floats can be surprisingly much faster than intermediately advanced approaches. The library used by GCC since version 12 (and also used by Chrome) claims to be 4 - 10 times faster than old strtod implementations: https://github.com/fastfloat/fast_float For more historical context: https://lemire.me/blog/2020/03/10/fast-float-parsing-in-practice/
vitus · 2024-06-21
> That only works when y is constant. Excellent point! That said, that was the case in this particular example. > This 16-bit modulo was just a final check that the correct number of bytes or bits were being sent (expecting remainder zero), so the denominator was going to be the same every time. (Libraries like libdivide allow you to memoize the magic numbers for frequently-used denominators, and if on x86 you have floating point operations with more precision than you need for integer division, you can potentially use the FPU instead of the ALU: https://lemire.me/blog/2017/11/16/fast-exact-integer-divisions-using-f…
unwind · 2024-03-26
Very good point, thanks! The ever-popular Mr Lemire often uses this technique, I think it's way easier to follow than straight up assembly. See for instance [1], his post about prefix-recognition in strings (not randomly chosen, it was simply the first post with code that I found when I searched for "simd"). [1]: https://lemire.me/blog/2023/07/14/recognizing-string-prefixes-with-sim…
svat · 2023-07-26
> There was a study a while back A couple of posts about how poor that paper was: • https://lemire.me/blog/2015/01/14/knauff-and-nejasmic-recommend-bannin… • https://blog.cr.yp.to/20201206-msword.html
slaymaker1907 · 2023-05-10
I don't think that's quite correct because there are many optimizations which are impossible (or nearly impossible) to do after a system is implemented. Daniel Lemire wrote an excellent post on this exact subject https://lemire.me/blog/2023/04/27/hotspot-performance-engineering-fail… In terms of programming languages, I think python is an excellent example of a language which has many features that have ended up making it extremely difficult to optimize even compared to other dynamic languages like LISPs. Even if you don't have to worry about backwards compatibility, there are design decisions that can limit performance which end up necessitating a rewrite of the entire system to actually change.
sgarland · 2023-03-01
> Two cpu generations later, the Pentium comes out, and both mul and div take 1 clock cycle. Where are you getting this information? Agner[0] lists DIV as taking 17 cycles at best (8-bit operand already in a register) on the P5, and MUL as taking 11 cycles. Even Tiger Lake takes 6 cycles for DIV. There are ways [1] to beat that, but I don't think you can get it down to a single cycle. [0]: https://www.agner.org/optimize/instruction_tables.pdf p.162 [1]: https://lemire.me/blog/2019/02/08/faster-remainders-when-the-divisor-i…
latency-guy2 · 2022-11-22
Dr. Daniel Lemire's blog: https://lemire.me/blog, covers lots of technical items on optimizations in various programming languages, Lemire's work is currently in use across a number of projects and he consistently delivers fantastic improvements, he usually accompanies these improvements with a blog post describing what he did. He also occasionally posts interesting Science and Technology links on various topics not limited to tech, but health and education as well.
wruza · 2022-09-14
This claims 3gb/s, saturating nvme full queued read. It’s not clear if they construct data or just parse it, but you have to construct data with any format. Other libs also do a great job. Also, io latency shoud be accounted for, because average jsons usually fit into one sdd block, afaiu. https://lemire.me/blog/2020/03/31/we-released-simdjson-0-3-the-fastest… (Edit: just realized this is the same site as subj, heh)
flohofwoe · 2022-04-21
I don't agree, C and C++ have excellent tools, they are just not evenly distributed (e.g. some IDEs have excellent integrated debuggers and profilers, other don't, some compilers have great integrated static analysis, others don't). The bigger problem is that in some programmer circles there seems to be an "ideological resistance" against using debugging tools (e.g. https://lemire.me/blog/2016/06/21/i-do-not-use-a-debugger/), which is frankly baffling to me.
bob1029 · 2022-04-15
Potentially relevant here... https://lemire.me/blog/2018/05/03/how-fast-can-you-parse-json/ http://www.vldb.org/pvldb/vol10/p1118-li.pdf "We experimentally evaluate Mison using representative real-world JSON datasets and the TPC-H benchmark, and show that Mison produces significant performance benefits over the best existing JSON parsers; in some cases, the performance improvement is over one order of magnitude."
jpgvm · 2022-01-01
Cloudflare etc that others have already posted are excellent by your definition. Uber blogs are surprisingly good. https://eng.uber.com/ Or more technical and less business goal focussed: https://jepsen.io/analyses https://lemire.me/blog/
Comevius · 2021-07-20
Daniel Lemire's blog is great as well, learned so much from it. https://lemire.me/blog/
specialist · 2021-07-10
Very cool post. Thank you. This article, and its many links, are helping noob me learn how to ask about I/O perf. TechEmpower benchmarks HTTP servers. While contestants continue to improve, I've long been curious what the theoretical fastest HTTP server could be. https://www.techempower.com/benchmarks/ Basically, an update to the "C10K problem" for the year 2021. https://en.wikipedia.org/wiki/C10k_problem A bit like how Daniel Lemire initially thought about parsing JSON. Paraphrasing: Why can't a JSON parser run at wire speed? "Parsing JSON quickly: early comparisons in the wild" https://lemire.me/blog/2019/03/02/parsing-json-quickly-early-compariso… -- Also, I really appreciate including the sound and cooling considerations. It's just great seeing the process of system design accommodating (balancing) multiple goals. Bravo.
shiny · 2020-12-28
https://lemire.me/blog/2020/12/01/interview-by-adam-gordon-bell/ Daniel Lemire details how he was able to massively speed up json parsing by thinking from first principles. TLDL: he removed all abstractions and coded directly for the hardware. Great interview. Makes me want to learn assembly programming (perhaps ARM64 since that seems to be the latest hotness thanks to the M1). I also enjoyed this interview on the upcoming JIT/AOT for the BEAM: https://thinkingelixir.com/podcast-episodes/017-jit-compiler-for-beam-…
mikaelsouza · 2020-11-29
Not sure what were the author's references, but "The Cool MIT Professor" reminds me of Daniel Lemire (https://lemire.me/blog/, even though he's not from MIT) and "the weird dude who writes HTML" reminded me of Dan Luu (https://danluu.com/). Both blogs are amazing and you should consider visiting them if you're interested in performance stuff.
michaelmior · 2020-10-13
It's especially powerful when you have someone with a deep knowledge of both hardware and software who can maximally exploit the performance of the hardware taking into account CPU caches, vectorization, etc. that most application programmers don't think about on a daily basis. Daniel Lemire[0] is a great example of someone who does this well. https://lemire.me/blog/
sradman · 2020-07-13
Search "daniel lemire" "AVX-512". Vectorizing random number generators for greater speed: PCG and xorshift128+ (AVX-512 edition) [1]. AVX-512: when and how to use these new instructions [2]. The dangers of AVX-512 throttling: a 3% impact [3]. [1] https://lemire.me/blog/2018/06/07/vectorizing-random-number-generators… [2] https://lemire.me/blog/2018/09/07/avx-512-when-and-how-to-use-these-ne… [3] https://lemire.me/blog/2018/08/15/the-dangers-of-avx-512-throttling-a-…
tarlinian · 2020-06-30
There is more recent work. This blog post by Travis Downs is the most detailed analysis of transition behavior I've seen: https://travisdowns.github.io/blog/2020/01/17/avxfreq1.html For general guidelines on when to use AVX-512, this (older post) remains best guide I've seen: https://lemire.me/blog/2018/09/07/avx-512-when-and-how-to-use-these-ne…
detaro · 2020-06-13
That article is a great example: It defines "debugger" as "single-stepping through code", and then argues against that. It's fine to argue against "single-stepping through code" as a default technique, but artificially limiting the scope. EDIT: one of the comments by the author makes it very clear: they don't consider lots of things you can do with e.g. gdb as "using a debugger": https://lemire.me/blog/2016/06/21/i-do-not-use-a-debugger/#comment-245… </EDIT> The submitted article here is similar, by opening with that ridiculous example and pretending that's what using a debugger means. Debuggers don't make you bad at finding problems. Not knowing when to use which tool makes you bad at it. (And knowing how to make new tools out of your existing ones is also quite helpful)
jdsully · 2020-05-07
Zen is great if you have moderate utilization code around the ~2-3 instructions per cycle mark. This is common for most compiled C and C++ where it hasn’t been specifically tuned for ILP. In these scenarios even if Intel has an extra ALU it won’t be used anyways. It took 3 days of tuning to get to a point where Intel started pulling away from my Zen2 chip. No matter what I did the Zen2 would not get faster because it was already at max utilization. Lemire had a blog [1] talking about this on here a few months ago as well. Most people were surprised because frankly Zen2 is very competitive with Intel for normal compiled code. https://lemire.me/blog/2019/12/05/instructions-per-cycle-amd-versus-in…
zokier · 2020-02-29
.25 cpb (1cycle/32bit) for xorshift and pcg with avx512 in here: https://lemire.me/blog/2018/06/07/vectorizing-random-number-generators…
matthewaveryusa · 2019-11-17
I disagree with such a blanket statement. Interfaces must remain simple, while implementations are free to be as complex as needed. Take a look at this article -- clearly the SIMD code is dense to get through, but it's very-much-so worth it for the performance gains. https://lemire.me/blog/2017/01/20/how-quickly-can-you-remove-spaces-fr…
amelius · 2015-06-08
> I'd love to use this. But in the back of my head I still think javascript should be optional if possible ... not that 99% of the rest of the world cares ... Stop worrying about Javascript. HTML+CSS is Turing-complete [1] [1] http://lemire.me/blog/archives/2011/03/08/breaking-news-htmlcss-is-tur…
baldfat · 2015-05-21
> 0. Spreadsheet is all you need. I HATE when people use Spreadsheets to do anything besides simple math. http://lemire.me/blog/archives/2014/05/23/you-shouldnt-use-a-spreadshe… TL:DR your work is not reproducible and we can't see what you did to get to your numbers. A million examples of why this is bad. Also > 1. Python script is good enough You mean Python with pandas and numpy? I use R which is also a great choice > 2. Java/Scala is way to go. For you but the vast majority of Data Scientist don't use either and their choice for people is not universal. Julia looks like a great new comer. I again mainly use R. > 3 & 4 are good points.
emptytheory · 2014-12-30
I guess the author agrees with me in another one of his articles (so maybe I just misinterpreted): "There is no trace of evidence that you can get the best out of people at high-level tasks through pressure and competition. The opposite is true. Worried people get dumber. They may be faster at carrying rocks… but they do not get smarter. Stressing out academics, students, engineers or any modern-day worker… makes them less effective. If we had any sense, we would minimize competition to optimize our performance." http://lemire.me/blog/archives/2014/12/05/academia-as-an-anxiety-machi…
pkolaczk · 2014-08-19
A factor of two difference is something that can be a result of using different C++ compilers or even different versions of the same compiler. See this: http://lemire.me/blog/archives/2012/07/23/is-cc-worth-it/ Particularly the comments section contains various results obtained from different compilers / versions. Variablility is higher than 2x for GCC. Comparing with Clojure is not fair, because it is not really statically typed, and known to be much harder to optimize for speed than e.g. pure old Java.

Keyboard shortcuts

/Search
j kNext / previous blog
EnterOpen selected blog
vVisit the blog site
fFollow / unfollow
lSwitch grid / list view
dSwitch dark mode
g hHome
g pTop posts
g tTopics
g fFollowing
g lLiked
g yHistory
g qFAQ
EscBack / close