Daniel Lemire's blog

Description
This channel can be used to follow Daniel Lemire's blog. It is COVID-free. If you would like news on COVID, follow https://t.me/covidinfoenglish
Advertising
We recommend to visit

Community chat: https://t.me/hamster_kombat_chat_2

Twitter: x.com/hamster_kombat

YouTube: https://www.youtube.com/@HamsterKombat_Official

Bot: https://t.me/hamster_kombat_bot
Game: https://t.me/hamster_kombat_bot/

Last updated 3 Monate, 1 Woche her

Your easy, fun crypto trading app for buying and trading any crypto on the market

Last updated 3 Monate her

Turn your endless taps into a financial tool.
Join @tapswap_bot


Collaboration - @taping_Guru

Last updated 2 Tage, 5 Stunden her

4 months, 2 weeks ago

Converting ASCII strings to lower case at crazy speeds with AVX-512

AMD Zen 4 and Zen 5, as well as server-side recent Intel processors, support an advanced set of instructions called AVX-512. They are powerful SIMD (Single Instruction, Multiple Data) instructions. Importantly, they allow ‘masked’ operations. That is, you can compute a mask and only do an operation on bytes indicated by the mask. Thus you can easily store only the first k bytes of a block of 64 bytes of memory as one instruction. Tony Finch recently described how you can take an ASCII string of arbitrary length and convert them to lower case quickly using AVX-512. Finch’s results is that for both tiny and large strings, the AVX-512 approach is faster. In his work, Finch assumes that the length of the string is known up front. However, C strings are stored as a pointer to the beginning of the string with a null character ( ) indicating its end. Thus the string love is stored in memory as love . Can we extend his work to C strings? With AVX-512 is that you can load 64 bytes at…

https://lemire.me/blog/2024/08/03/converting-ascii-strings-to-lower-case-at-crazy-speeds-with-avx-512/

4 months, 3 weeks ago

Evolution of iPhone storage capacity

People who should know better often underestimate how fast our storage capacity has grown. We have been able to get 1 TB of storage on iPhones for the last three generations. 2010 | iPhone 4 | 32 GB ------------------------------ 2012 | iPhone 5 | 64 GB ------------------------------ 2014 | iPhone 6 | 128 GB ------------------------------ 2016 | iPhone 7 | 256 GB ------------------------------ 2018 | iPhone XS | 512 GB ------------------------------ 2019 | iPhone 11 Pro | 512 GB ------------------------------ 2020 | iPhone 12 Pro | 512 GB ------------------------------ 2021 | iPhone 13 Pro | 1 TB ------------------------------ 2022 | iPhone 14 Pro | 1 TB ------------------------------ 2023 | iPhone 15 Pro | 1 TB

https://lemire.me/blog/2024/07/28/evolution-of-iphone-storage-capacity/

4 months, 3 weeks ago

Storage costs are plummeting

Storage costs are plummeting like a skydiver in freefall—between 10 and 100 times cheaper with each passing decade. Meanwhile, the programmer population is growing at a leisurely pace, like a tortoise in a marathon, increasing by about 50% per decade. And the Linux kernel? It is maybe doubling in size every ten years. The net result: we are using storage of data (videos, images, model weights) while code is taking a backseat, fading into the background.

https://lemire.me/blog/2024/07/27/storage-costs-are-plummeting/

7 months ago

Science and Technology links (May 25 2024)

  1. Artificial intelligence is far more efficient at producing content than human beings, as far as carbon emissions go. 2. Human brains got larger by over 5% between 1930 and 1970. 3. Replacing plastics by ‘environment friendly’ alternatives typically results in greater greenhouse gas emissions. 4. Prostate-specific antigen screening has only a small effect on men’s risk of dying in absolute terms. 5. Local exposure to poor individuals reduces support for redistribution among the well-off. In other words, wealthy people are more likely to favor government programs helping the poor if they never see poor people. 6. Happier looking people are judged better. If you want to be viewed as a good person, make sure you appear happy. 7. Females mount stronger immune responses to many pathogens, they awaken more frequently at night, they express greater concern about physically dangerous stimuli, they exert more effort to avoid social conflicts, they exhibit a personality style more focused on life’s dangers, they react to threats with greater fear, disgust…

https://lemire.me/blog/2024/05/26/science-and-technology-links-may-25-2024/

Nature

The carbon emissions of writing and illustrating are lower for AI than for humans

Scientific Reports - The carbon emissions of writing and illustrating are lower for AI than for humans

Science and Technology links (May 25 2024)
7 months, 1 week ago

Learning from the object-oriented mania

Back when I started programming professionally, every expert andevery software engineering professor would swear by object-oriented programming. Resistance was futile. History had spoken: the future was object-oriented. It is hard to understate how strong the mania was. In education, we started calling textbooks and videos ‘learning objects‘. Educators would soon ‘combine learning objects and reuse them‘. A competitor to a client I was working on at the time had written a server in C. They had to pay lip service to object-oriented programming, so they said that their code was ‘object-oriented. I once led a project to build an image compression system. They insisted that before we even wrote a single line of code, we planned it out using ‘UML’. It had to be object-oriented from the start, you see. You had to know your object-oriented design patterns, or you could not be taken seriously. People rewrote their database engines so that they would be object-oriented. More than 25 years later, we can finally say, without needing much courage, that it was insane, outrageous, and terribly wasteful. Yet, even…

https://lemire.me/blog/2024/05/14/learning-from-the-object-oriented-mania/

7 months, 1 week ago

Forwarding references in C++

In C++, there are different ways to pass a value to a function. Typically, at any given time, an object in C++ ‘belongs’ to a single function. The various ways to call a function differ in who owns the object, the caller or the callee (the function being called). The simplest one is that we pass by value. In such cases, a copy is typically made of the object and both the caller and the callee own a copy. void value(MyClass obj) {} We can pass by reference. You recognize a reference by the single ampersand (&). The caller owns the object, but the callee gets access to it. void reference(MyClass& obj) {} You can also pass by an “rvalue reference” which you recognize by the ‘&&’ symbols. In such cases while the caller initially creates the object, but its ownership is passed to the callee. I personally dislike the expression ‘rvalue reference’ and I would have preferred something less technical. void rvalue_reference(MyClass&& obj) {} However, in some instances, you do not care whether your function gets to own…

https://lemire.me/blog/2024/05/13/forwarding-references-in-c/

7 months, 2 weeks ago

How fast can construct small list of strings in C for Python?

Python is probably the most popular programming language in the world right now. Python is easy to extend using C code. You may want to return from Python a small data structure. When crossing from C to Python, there is an overhead. Thus, if performance is a concern, you do not want to return lots of small values such as hundreds of individual small strings. However, you may want to return a list of strings such as
['zero elephant', 'one elephant is having fun', 'two elephants are having fun', 'three elephants are meeting with the president', 'four elephants', 'five elephants in an hexagon', 'six elephants are playing the saxophone', 'seven elephants are visiting the school', 'eight elephants are at Church', 'nine elephants are having a party']
I am going to assume that these strings are in an array called ‘numbers’ in my C code. Of course, if the strings are known at compile time, I could just precomputed the array and return it. However, I want to generate the content dynamically. A reasonable C function which will…

https://lemire.me/blog/2024/05/09/how-fast-can-construct-small-list-of-strings-in-c-for-python/

7 months, 3 weeks ago

Should Node.js be built with ClangCL under Windows?

Under Windows, when using Visual Studio to build C++ code, there are two possible compiler strategies. The Visual Studio compiler (often referred to as MSVC) is the default compiler provided by Microsoft for Windows development. In Debug mode, the regular Visual Studio compiler produces faster compilation times and more performant code compared to ClangCL. ClangCL is part of the Clang/LLVM project, which is an open-source compiler toolchain. ClangCL is compatible with the Visual Studio runtime and links with the Microsoft implementation of the Standard Library. It’s available as an optional component in Visual Studio 2019 and later versions. In Debug mode, I find that the regular Visual Studio compiler builds faster. However, in release mode, I found empirically that ClangCL approach may provide more performant code. On some micro-benchmarks, the difference can be large (e.g., 40%) although I expect more modest gains on complex systems. As of Chrome 64, Google Chrome for Windows is compiled with ClangCL. Thus Clang is now used to build Chrome for all platforms it runs on, including macOS, iOS, Linux, Chrome OS,…

https://lemire.me/blog/2024/05/02/should-node-js-be-built-with-clangcl-under-windows/

8 months ago

How do you recognize an expert?

Go back to the roots: experience. An expert is someone who has repeatedly solved the concrete problem you are encountering. If your toilet leaks, an experienced plumber is an expert. An expert has a track record and has had to face the consequences of their work. Failing is part of what makes an expert: any expert should have stories about how things went wrong. I associate the word expert with ‘the problem’ because we know that expertise does not transfer well: a plumber does not necessarily make a good electrician. And within plumbing, there are problems that only some plumbers should solve. Furthermore, you cannot abstract a problem: you can study fluid mechanics all you want, but it won’t turn you into an expert plumber. That’s one reason why employers ask for relevant experience: they seek expertise they can rely on. It is sometimes difficult to acquire expertise in an academic or bureaucratic setting because the problems are distant or abstract. Your experience may not translate well into practice. Sadly we live in a society where we often lose…

https://lemire.me/blog/2024/04/21/how-do-you-recognize-an-expert/

9 months, 2 weeks ago

How to read files quickly in JavaScript

Suppose you need to read several files on a server using JavaScript. There are many ways to read files in JavaScript with a runtime like Node.js. Which one is best? Let us consider the various approaches. Using fs.promises
const fs = require('fs/promises'); const readFile = fs.readFile; readFile("lipsum.txt", { encoding: 'utf\-8' }) .then((data) => {...}) .catch((err) => {...})
Using fs.readFile and util.promisify
const fs = require('fs'); const util = require('util'); const readFile = util.promisify(fs.readFile); readFile("lipsum.txt", { encoding: 'utf\-8' }) .then((data) => {...}) .catch((err) => {...})
Using fs.readFileSync
const fs = require('fs'); const readFileSync = fs.readFileSync; var data = readFileSync("lipsum.txt", { encoding: 'utf\-8' })
Using await fs.readFileSync
const fs = require('fs'); const readFileSync = fs.readFileSync; async function f(name, options) { return await readFileSync(name, options); }
Using fs.readFile
const fs = require('fs'); const readFile = fs.readFile; fs.readFile('lipsum.txt', function read(err, data) {...});
Benchmark I wrote a small benchmark where I repeated read a file from

https://lemire.me/blog/2024/03/12/how-to-read-files-quickly-in-javascript/

GitHub

Code-used-on-Daniel-Lemire-s-blog/2024/03/12 at master · lemire/Code-used-on-Daniel-Lemire-s-blog

This is a repository for the code posted on my blog - lemire/Code-used-on-Daniel-Lemire-s-blog

We recommend to visit

Community chat: https://t.me/hamster_kombat_chat_2

Twitter: x.com/hamster_kombat

YouTube: https://www.youtube.com/@HamsterKombat_Official

Bot: https://t.me/hamster_kombat_bot
Game: https://t.me/hamster_kombat_bot/

Last updated 3 Monate, 1 Woche her

Your easy, fun crypto trading app for buying and trading any crypto on the market

Last updated 3 Monate her

Turn your endless taps into a financial tool.
Join @tapswap_bot


Collaboration - @taping_Guru

Last updated 2 Tage, 5 Stunden her