Home›Discover›Programming›Daniel Lemire

Daniel Lemire

Posts per week · about 00 subscribersenProgramming
lemire.me

Recent articles

Subscribe and these — and every new article — show up in your reader

Writing a paper is no longer a signal

AI summaryA journal editor argues that AI agents can now generate entire research papers—with plots, tables, and discussion—so easily that writing a paper, even a serious-looking one or a PhD thesis, no longer signals high ability and will lose its prestige. The author contends that academic publishing has already been irreversibly disrupted, even if societal norms take time to adjust. Academics should therefore focus on solving actual problems, since while writing about curing cancer is now trivial, curing cancer itself remains a genuine challenge.

Our textbook on machine learning and artificial intelligence is out

AI summaryRobert Godin and the author have released a new 741-page textbook, 'Introduction to Machine Learning and Artificial Intelligence with Python,' available in paperback and Kindle editions. The book is aimed at college students taking a first course or Python programmers wanting to learn machine learning, covering NumPy, Pandas, linear regression, decision trees, building a neural network from scratch, and then moving to PyTorch, transformers, model libraries, language models, reinforcement learning, and deploying a model in a container. Each chapter includes runnable examples and exercises with solutions.

Don’t be Andy Bernard

AI summaryThe article argues that prestige—reputation by association with elite institutions or signals—is not the same as genuine reputation, which is earned slowly through reliable work and can be lost quickly. Prestige is noisy, gamified, and time-delayed, and relying on it too long becomes a negative signal, as illustrated by Andy Bernard from The Office constantly touting his Cornell degree. The author's advice is to skip the shortcuts and build real reputation by doing good work.

Command-line JSON filtering at 20 GB/s

AI summarysjq is a new command-line tool that implements the jq filter language on top of the simdjson parser, filtering NDJSON at 3.5 GB/s on a single thread (about 37 times faster than jq) and up to 20 GB/s with multiple threads. It is highly compatible with jq, passing 728 of jq's 781 tests and supporting most of its features, while adding extras like the --fractured option for readable, table-like JSON output. sjq can be installed on Linux, macOS, and Windows via an install script, Homebrew, or Scoop.

Cheaters are Innovators

AI summaryThe article argues that true innovation comes from those willing to bypass or 'cheat' rigid systems rather than seeking approval within them. Instead of convincing established institutions to change, innovators build alternatives—like starting their own platforms or founding companies such as SpaceX—that render the old system unnecessary. The author encourages readers to test ideas independently and find ways to work around existing rules rather than waiting for permission.

Seeing the machine code of your Java program, with a few lines of Java

AI summaryThe article demonstrates the instructive library, which samples which machine instruction is running every 10 ms to reveal where JIT-compiled code spends CPU time, using only a few lines added to an ordinary Java program. Profiling RoaringBitmap's andCardinality shows that on an Apple M4 each population count waits on the previous one through a shared vector register, but JDK 27 vectorizes the loop for a sevenfold speedup, while an Intel Xeon with AVX-512 is fast under both JDK versions thanks to vpopcntq. Compared with JMH's perfasm profiler, instructive requires no benchmark project, root privileges, or external tools, and produces a profile as a Java object that can be analyzed programmatically.

Decoding base64 email attachments: a speed ranking of programming languages

AI summaryThe author benchmarks MIME base64 decoding (with 76-character lines and CRLF endings) across popular programming languages on an Intel Xeon server, finding a thirtyfold speed gap from C++ with simdutf (18.4 GB/s) down to current PHP (0.61 GB/s). The top six systems all use the simdutf library, which strips line endings inside its SIMD loop so decoders never fall back to a slow path. By porting simdutf to PHP via a pull request, MIME decoding becomes 28 times faster, moving PHP from last to second place.

Java4Shell: when base64 decoding leads to remote code execution?

AI summaryThe article describes CVE-2026-114938, an out-of-bounds write in OpenJDK's Base64 decoder (present since JDK 17.0.6) that is triggered by decoding a 128-character string ending in '='. The bug lies in hand-written AVX-512 assembly: a negative remainder length is truncated to 255 in the 8-bit mask count, so the masked store writes 62 bytes past the end of the allocated output array. The author clarifies that the flaw is not in the Muła & Lemire vectorized algorithm itself, whose newer whitespace-tolerant version has shipped in major browsers and JavaScript runtimes with 30x or better speedups.

Cognitive radius

AI summaryThe article argues that AI's most significant impact on software work is not faster coding but the expansion of what the author calls 'cognitive radius'—the range of projects, technologies, and context an engineer can keep coherent at once. Where developers once specialized because holding large amounts of context was costly, AI tools now allow them to load and operate on much larger working sets, dramatically reducing the cost of switching between codebases. However, this benefit is not automatic: engineers must learn to feed the model the right context, frame questions carefully, and verify results, treating it as a high-bandwidth interface rather than a magic solution.

Reading JSON at 277 GB/s in Python

AI summaryThe article presents fastsimdjson, a Python library that combines SIMD-based parsing with multithreading (enabled by Python 3.14's free-threaded, GIL-less build) to read NDJSON data far faster than the standard json module, orjson, or msgspec. In a benchmark counting GitHub star events across 7.6 GB of data, it processed 138 GB/s with 192 threads, beating the best msgspec process pool at 116 GB/s. On other benchmark files, extracting selected fields reached up to 277 GB/s, with four of six files exceeding 100 GB/s.

Telling your number parser what to expect

AI summaryThe fast_float library is adding optional performance hints (unpredictable_sign, short_numbers, and assume_round_to_nearest), passed as template arguments, that let developers eliminate costly branch mispredictions when they know something about their data. Benchmarks on Intel and Apple processors show that correctly matched hints can boost parsing speed by up to more than twice (e.g., from 153 to 345 million numbers per second on the Apple M4 Max), while mismatched hints can actually slow parsing down. The hints never change results, except when a programmer wrongly promises assume_round_to_nearest while code elsewhere changes the rounding mode.

A performance trap: when store forwarding fails

AI summaryThe article explains store forwarding, where a load reads bytes from the store buffer before they reach the cache, and shows that it fails—and becomes costly—when the load is wider than the store or only partially overlaps it. A C example illustrates the problem (a 1-byte store followed by an 8-byte load) along with a register-based workaround. Benchmarks on Xeon, EPYC, Graviton 5, and Apple M4 Max show that such mismatches can cost around 19 cycles on Xeon and 14 on EPYC, versus only about 5 cycles on the M4 and Graviton 5.

Open source as a research method

AI summaryThe author argues that innovation is driven by real demand and customers rather than a linear academic-to-product pipeline, and illustrates this through his open source projects (simdjson, the Eisel-Lemire algorithm, simdutf), each born from bottlenecks discovered while building. He contends that open source users and contributors provide tougher, more valuable feedback than academic peer review, echoing Stonebraker, Brooks, and Patterson, and notes that AI tools have increased rather than decreased contributions to his code. The piece closes by reporting his invited talk on these ideas at the October 2026 launch of SERIQ, a new Quebec software engineering research centre, alongside speakers Lionel Briand, Marsha Chechik, and Yves Daoust.

In C++, = default and {} are not the same constructor

AI summaryIn C++, declaring a default constructor as `span() = default` versus `span() {}` has different semantics: the former keeps the class trivial (so value-initialization zeroes the object without running the constructor), while the latter is user-provided and makes the class non-trivial. This distinction can significantly affect generated code and performance, as shown in a benchmark where GCC 15 and 16 compiled the `= default` version over four times slower (about 8 ns/span versus 1.73 ns/span) due to copies through a temporary.

Beating the compiler at signed 32-bit division

AI summaryThe article explains that compilers replace division by a constant with multiplication and shifts, but for signed 32-bit integers, about 38% of divisors require a 33-bit multiplier that forces compilers to emit extra correction instructions. The author shows that on a 64-bit processor, a carefully chosen unsigned multiplier always fits in a signed 64-bit product, eliminating the correction step, shortening the critical path by two instructions, and cutting division latency by roughly two cycles on Intel and 12% on Apple M4. The same insight enables a branchless signed division for runtime divisors in the fastmod library, which is up to four times faster than the previous version and more than twice as fast as the hardware division instruction.

Billion-query-per-second lookup tables in C++

AI summaryThe article introduces a C++23 single-header library that builds compile-time perfect hash maps for known string keys, eliminating runtime collision handling so a lookup costs only about five cycles (roughly a billion lookups per second on an Apple M4). It combines a greedy constexpr algorithm that finds a collision-free hash function with SIMD-based 16-byte vector comparisons instead of byte-by-byte string loops. Benchmarks on an Apple M3 Max show it is 3 to 17 times faster than GNU gperf and 7 to 13 times faster than std::unordered_map.

Decoding base64 in Python at 10 gigabytes per second

AI summaryThe article introduces fastpybase64, a new Python binding to the simdutf library that uses SIMD instructions to provide drop-in base64 encoding and decoding, replacing Python's character-at-a-time standard module. Benchmarks on a single core of an Intel Xeon Gold 6548N show it decoding at over 13 GB/s, roughly four times faster than pybase64 and 27 times faster than the standard library. The package is available on PyPI for Linux, macOS, and Windows, supporting Python 3.10 through 3.14, including the free-threaded build.

Redis now has compressed bitmaps (Roaring)

AI summaryRedis is adding support for Roaring compressed bitmaps (expected in Redis 8.12), contributed by Antonio Viggiano and enabled with a single configuration setting. Roaring adapts its storage to the data—storing sparse regions as integer lists and dense regions as bitsets—allowing fast counts, intersections, and unions without decompression. Benchmarks show Roaring can be much faster than uncompressed bitmap strings, especially for sparse data like scattered 32-bit ids where an uncompressed bitmap spans 512 MB, though tradeoffs exist.

Parsing JSON at tens of gigabytes per second… in Python

AI summaryThe article demonstrates that Python 3.14's free-threaded version (without the GIL) combined with fastsimdjson, a Python binding for simdjson, can parse 7.6 GB of GitHub event JSON (2.2 million events) at about 66 GB/s using 64 threads in a single process. Using lazy views that only create Python objects for accessed fields, the approach is 31 times faster than a single core and outperforms alternatives like msgspec, orjson, and the standard library json module.

WebSocket servers in JavaScript: Node.js, Bun and Deno in 2026

AI summaryThe author re-ran a corrected WebSocket ping-pong benchmark in 2026 comparing JavaScript servers on Node.js 26, Bun 1.4.2, and Deno 2.9.7, using a fast C client to fix the slow JavaScript clients that skewed earlier results. Node.js with uWebSockets.js proved fastest at 49,000 round trips per second (approaching a simple C relay at 54,000), ahead of Deno's built-in server at 40,000 and Bun's at 37,000. A second test with the ws package on all three runtimes confirmed the same ranking, with Node.js first, Bun second, and Deno last.