Daniel Lemire's blog

Science and Technology links (January 26th, 2018)

, 4 min read

We have reached “peak coal” meaning that coal usage is going to diminish in the coming years. McGill professor Ishiang Shih has been accused by the US government of leaking chip designs to the Chinese government. The professor runs a business called JYS Technologies. This sounds impressive and…

Initializing arrays quickly in Swift: be wary of Sadun´s initializers

, 2 min read

Swift is Apple’s go-to programming language. It is the new default to build applications for iPhones. It also runs well on Linux. It is not as low-level as C or C++, but it has characteristics that I like. For example, it does not use a “fancy” garbage collector, relying instead on…

Microbenchmarking is hard: virtual machine edition

, 4 min read

To better understand software performance, we often use small controlled experiments called microbenchmarks. In an earlier post, I remarked that it is hard to reason from a Java benchmark. This brought me some criticism from Aleksey Shipilëv who is one of the top experts on Java benchmarking. I…

Science and Technology links (January 19th, 2018)

, 3 min read

The Raspberry Pi 3, a $15-dollar computer that I use for various fun projects, is 15 times more powerful than the Cray-1 supercomputer, but it is 130,000 times lighter. The Cray-1 was worth $9 million in 1977. (Source: Joe Armstrong) Stem cells can be used to replace or modify the behavior of our…

Ridiculously fast base64 encoding and decoding

, 3 min read

Computers store data as streams of bits. Binary files like image, audio or video files are allowed to contain just about any sequence of bits. However, we also often use text formats; for example, web pages and emails are required to be text. So how do we send images by email? How do we embed…

Microbenchmarking calls for idealized conditions

, 24 min read

Programmers use software benchmarking to measure the speed of software. We need to distinguish system benchmarking, where one seeks to measure the performance of a system, with microbenchmarking, where one seeks to measure the performance of a small, isolated operation. For example, if you are…

Science and Technology links (January 12th, 2018)

, 2 min read

A few years ago, researchers in Danemark expressed concerns regarding high concentrations of pesticides that are showing up in urine samples of Danish mothers and children. Last time I was in Danemark, a newspaper was reporting that there are surprising amounts of pesticides in the products sold…

How fast can you bit-interleave 32-bit integers? (SIMD edition)

, 4 min read

In a previous post, I asked how fast one could interleave the bits between two 32-bit integers. That is, given 0b1011 (11 in decimal) and 0b1100 (12 in decimal), I want the number 0b11011010. On recent (2013) Intel processors, the answer is that you process one pair of integers every two cycles…

How fast can you bit-interleave 32-bit integers?

, 2 min read

A practical trick in software is to “bit-interleave” your data. Suppose that I have two 4-bit integers like 0b1011 (11 in decimal) and 0b1100 (12 in decimal). I can interleave the two numbers to get one 8-bit number 0b11011010 where I simply pick the most significant bit from the first number,…

Can 32-byte alignment alleviate 4K aliasing?

, 7 min read

In my previous post, I considered some performance problems that can plague simple loops that read and write data… for (int i = 0; i < a.length; ++i) { a[i] += s * b[i]; } Once vectorized, such a loop can suffer from what Intel calls 4K Aliasing: if the arrays are stored in memory at…

Science and Technology links (January 5th, 2018)

, 2 min read

Regarding solar energy, Tyler Cowen writes: There is now a doctrine of what I call solar triumphalism: the price of panels has been falling exponentially, the technology makes good practical sense, and only a few further nudges are needed for solar to become a major energy source. Unfortunately,…

Don´t make it appear like you are reading your own recent writes

, 5 min read

Richard Statin recently published a Java benchmark where the performance of a loop varies drastically depending on the size of the arrays involved. The loop is simple: for (int i = 0; i < a.length; ++i) { a[i] += s * b[i]; } If the array size is 1000, the performance is lower than if the…

Year 2017: technological highlights

, 2 min read

DeepStack and Libratus become the first computer programs to beat professional poker players. We are using synthetic cartilage to help people with arthritis. Stem cells can regrow a whole new tooth. We have made significant progress in rejuvenating old tissues and organs with senolytics. Senescent…

Multicore versus SIMD instructions: the “fasta” case study

, 3 min read

Setting aside graphics processors, most commodity processors support at least two distinct parallel execution models. Most programmers are familiar with the multicore model whereas we split the computation into distinct parts that get executed on distinct cores using threads or goroutine.Speeding…

Science and Technology links (December 29th, 2017)

, 2 min read

It is often believed that, in the developed world, more land is used to host human beings as time goes by, reducing space for forest and wildlife. That is not true: Forests are spreading in almost all Western countries, with the fastest growth in places that historically had rather few trees. In…

Personal reflections on 2017

, 8 min read

Year 2017 is coming to an end. As a kid, I would have surely imagined that by 2017, I would be living in space. But then I can chat with Amazon’s servers through the “Alexa” persona. It is not space, but it is cool. It is the first year I used a tablet (an iPad) for actual work. It is not a…

Science and Technology links (December 22nd, 2017)

, 3 min read

Bitcoins are electronic records that are meant to be used as currency. They have become increasingly popular and expensive. Reportedly, the famous investment bank Goldman Sachs is planning to offer bitcoin financial services in the summer of 2018. Doing away with television and switching to…