Multi-threading is always the wrong design (2023)
Published on: 2025-05-14 10:39:42
Multi-threading is always the wrong design
“We’ll just do that on a background thread” uNetworking AB · Follow 4 min read · Nov 29, 2023 -- 34 Listen Share
Say what you want about Node.js. It sucks, a lot. But it was made with one very accurate observation: multithreading sucks even more.
A CPU with 4 cores doesn’t work like you are taught from entry level computer science. There is no “shared memory” with “random time access”. That’s a lie, it’s not how a CPU works. It’s not even how RAM works.
A CPU with 4 cores is going to have the capacity of executing 4 seconds of CPU-time per second. It does not matter how much “background idle threading” you do or don’t. The CPU doesn’t care. You always have 4 seconds of CPU-time per second. That’s an important concept to understand.
If you write a program in the design of Node.js — isolating a portion of the problem, pinning it to 1 thread on one CPU core, letting it access an isolated portion of RAM with no data sharing, then you have a d
... Read full article.