1024cores
1024cores.net · Personal blog · on HN since 2010
Dmitry Vyukov's site on lock-free algorithms, concurrent queues, race detection and scalable multicore programming.
What HN saysCommenters recommend it as a great resource for learning lock-free algorithms and concurrency, and remember reading it as early as 2011.
36HN people shared it
20linked it in comments
18stories submitted
356story points
11 months agolast shared
2010people per year2026
Most-shared posts
- 11024cores6 people · 74 points · first shared 2010 · 18 comments on HN
- 2Introduction to Lock-free Algorithms6 people · 11 points · first shared 2010 · discussion on HN
- 3Lockfree Algorithms (2010)5 people · 231 points · first shared 2012 · 42 comments on HN
- 4Intrusive MPSC node-based queue4 people · 1 points · first shared 2015 · discussion on HN
- 5Relacy Race Detector3 people · 23 points · first shared 2019 · 4 comments on HN
- 6Non-intrusive-mpsc-node-based-queue3 people · 1 points · first shared 2015 · discussion on HN
- 7Faster fibers on Linux3 people · 1 points · first shared 2011 · discussion on HN
- 8Cache-Oblivious Algorithms2 people · 8 points · first shared 2011 · discussion on HN
- 9Bounded mpmc queue2 people · first shared 2025
- 101024 Cores: Multi-Core Computing + Efficient Scaling Up: “General Recipe”1 people · 2 points · first shared 2015 · discussion on HN
- 111024cores1 people · 2 points · first shared 2012 · discussion on HN
- 12Scalability Prerequisites1 people · 1 points · first shared 2022 · discussion on HN
- 13Relacy Race Detector is a verifier for relaxed memory models1 people · 1 points · first shared 2025 · discussion on HN
- 14Wide finder 21 people · first shared 2011
- 15About me1 people · first shared 2011
What HN people wrote when they linked it
snakey · 2023-04-24
I too am a beginner with concurrent programming—it's a difficult topic to get your head around at first. Some resources that I've found super helpful:
- Dmitry Vyukov's Lockless Algorithms: https://www.1024cores.net/home/lock-free-algorithms
- Jeff Preshing's blog (worth exploring all adjacent articles): https://preshing.com/20120612/an-introduction-to-lock-free-programming…
- Bartosz Milewski: https://bartoszmilewski.com/2008/12/01/c-atomics-and-memory-ordering/
- Memory Barriers: a Hardware View for Software Hackers—P.McKenney: https://www.researchgate.net/publication/228824849_Memory_Barriers_a_H…
I hope you find some of these useful. I've re-read Paul McKenney's paper every 2-3 months in an attempt to get this stuff to stick! :)
edsrzf · 2013-03-28
Dmitry Vyukov keeps a great resource for learning about lock-free algorithms (and other interesting things) here: http://www.1024cores.net/home/lock-free-algorithms/introduction
sbahra · 2012-08-20
Please note that the code in this article is broken. It lacks proper use of atomics, memory barriers, let alone compiler barriers. You can find a similar and correct queue at http://concurrencykit.org (ck_fifo.h). The liblfds queue is very heavy-weight for a simple SPSC workload and is also lacking in correctness.
If you're looking for a learning resource, I suggest looking at http://www.rdrop.com/users/paulmck/perfbook/ and http://1024cores.net
ynniv · 2011-02-07
What a useless article title. Unfortunately, the article behind it also isn't particularly worthwhile.
TL;DR: Someone[1] who did great work[2] on a parallel benchmark[3] was recognized as being good by tbray, who told a Google recruiter to favor them. Said engineer now works at Google.
Unless you are trying to score a gig at the Goog, just skip to [2].
[1|http://www.1024cores.net/home/about-me]
[2|http://www.1024cores.net/home/scalable-architecture/wide-finder-2]
[3|http://wikis.sun.com/display/WideFinder/The+Benchmark]
jiggawatts · 2024-05-29
As far back as 2011, I was reading articles from this blog: https://www.1024cores.net/
I remember thinking: "That's crazy! One kilo-cores! They're processors, not memory!"
Then, almost immediately, it started sinking in that this is what Moore's law means. That yes, sooner or later, I'll be working on a single system with more than a thousand cores (or hardware threads) in it.
This behemoth of a server probably has 8 sockets and I'm guessing it is the size of half a rack or thereabouts.
An upcoming AMD EPYC processor is rumored to have 256 cores (512 threads), which means that a "normal sized" server will have 512c/1024t soon at a more reasonable cost: https://www.extremetech.com/computing/328692-future-256-core-amd-epyc-…
Similarly, Intel is planning a processor with 288 cores within a year, although it may or may not have hyper-threading: https://www.anandtech.com/show/21276/intel-previews-sierra-forest-with…
A challenge I like to pose to software developers is this: If you were given one of these servers, and you could install your software on it, would it get 100x faster for one user than a server with just 10 vCPUs?
snaury · 2023-09-11
When you protect an std::deque with a mutex you would need at least two atomic operations: to lock the queue before pushing, and to unlock the queue after pushing. Because you're using an std::deque it may need to allocate memory during a push, which would happen under the lock, which makes it more likely for a thread to suspend with the lock taken. While the queue is locked other threads will have to wait, possibly even suspend on a futex, and then the unlocking thread would have to wake another thread up.
The most expensive part of any mutex/futex is not locking, it's waking other threads up when the lock is contended. I'm actually surprised you only get 10 million messages per second, is that for a contended or an uncontended case? I would expect more, but it probably depends on the hardware a lot, these numbers are hard to compare.
My actor framework currently uses a lockfree intrusive mailbox [1]_, which consists of exactly two atomic exchange operations, so pushing a node is probably cheaper than with a mutex. But the nicest part about it is how I found a way to make it "edge triggered". A currently unowned (empty) queue is locked by the first push (almost for free, compared to a classic intrusive mpsc queue [2]_ the second part of push uses an exchange instead of a store), which may start dequeueing nodes or schedule it to an executor. The mailbox will stay locked until it is drained completely, after which it is guaranteed that a concurrent (or some future) push…
thrownaway2424 · 2012-12-29
All this and more at http://www.1024cores.net/
xavierxwang · 2025-12-16
Is there any chance to modify Vyukov's MPMC queue implement (https://www.1024cores.net/home/lock-free-algorithms/queues/bounded-mpm… to support drop handler? That work doesn't need 128 bit CAS.
rstuart4133 · 2025-01-18
Russian intellectuals are extraordinary. This guy's predictions, "One Day in the Life of Ivan Denisovich", their rocket engines which were often developed by one guy with a slide rule.
I'm analysing Dimitry Vyukov bounded lockless mcpc queue: https://www.1024cores.net/home/lock-free-algorithms/queues/bounded-mpm… Every line is an exquisite optimisation, many taking hours to understand how they interact with the others. A true masterpiece that will only be appreciated by a few. (But probably used by many, as it's in Rust's std library now.)
int08h · 2024-07-06
Yes, the (IMHO) the easiest one to use is the Relacy Race Detector (https://github.com/dvyukov/relacy and https://www.1024cores.net/home/relacy-race-detector)
It's been around a while and is easy to work with. Written by Dmitry Vyukov, an expert in the concurrency world.
shultays · 2022-09-22
Isn't the very first example error prone? The one under Wait-freedom
https://www.1024cores.net/home/lock-free-algorithms/introduction
A thread can easily decrease the reference count to zero and delete the object while another thread is trying to add reference
laddng · 2020-12-21
I found this blog to be very helpful for understanding lockfree algorithms: http://www.1024cores.net/home/lock-free-algorithms
zmmmmm · 2020-12-21
I don't know how authoritative it is but I was taking the definitions from here:
http://www.1024cores.net/home/lock-free-algorithms/introduction
They define wait free as not even having thread starvation and lock free as not having to wait for anything as long as you have CPU to actually run.
Its always interesting how any given topic always fragments into much more complexity than you expected once you start learning about it!
mratsim · 2020-01-06
See http://www.1024cores.net/home/lock-free-algorithms/tricks/fibers on ucontext
And for longjmp, Apple source for example https://opensource.apple.com/source/Libc/Libc-262/i386/sys/setjmp.s.au…
It does seem like glibc impl doesn't involve syscalls: https://groups.google.com/forum/#!topic/comp.unix.programmer/LvUP9H-7A…
grogers · 2019-05-28
There do exist frameworks that allow exhaustive testing of concurrent code. They never really became mainstream though.
https://www.microsoft.com/en-us/research/publication/chess-a-systemati…
http://www.1024cores.net/home/relacy-race-detector
jpfr · 2017-03-18
Aah. Sorry. The non-intrusive version is different substantially and corresponds to the code shown in the post.
http://www.1024cores.net/home/lock-free-algorithms/queues/non-intrusiv…
raphlinus · 2017-03-17
I like the terminology that Dmitry Vyukov uses[0], where "wait-free" means that any individual thread is guaranteed to make progress, and "lock-free" means that some thread is guaranteed to make progress. There's also the weaker guarantee "obstruction-free" where livelock is a possibility.
[0] http://www.1024cores.net/home/lock-free-algorithms/introduction
biokoda · 2016-07-17
Is it better than: http://www.1024cores.net/home/lock-free-algorithms/queues/non-intrusiv…
Which is what Rust mpsc uses. It has a big advantage in being short and easy to understand.
mjpt777 · 2015-03-29
Thanks for the link.
If you look at the implementation no thread is ever stopped from completing. If a producing thread was killed mid operation by another malicious thread then the stream is broken. Other threads are never blocked. Other writers can add via a finite number of steps and the stream will back pressure when flow control kicks in. The consumer is never blocked - it simply never sees more messages. The algorithm meets the definition.
Unless I missed it that paper does not not state that the algorithm must cope with a malicious thread to be wait-free.
Try applying your thinking to this other respected MPSC wait-free queue.
http://www.1024cores.net/home/lock-free-algorithms/queues/intrusive-mp…
dfritz · 2015-11-18
This is interesting, but I don't really understand the differences with
the existing coroutine libraries like libtask, libconcurrency or libcoro.
Of course, it uses the longjmp/setjmp trick, as suggested by Dmitry Vyukov.
http://www.1024cores.net/home/lock-free-algorithms/tricks/fibers
However, I'm not sure of the benefit of this approach, compared to
writing a few lines of stack switching assembly code per architecture.
Especially, how portable are the implementations of longjmp and setjmp
across the multitude of C libraries and operating systems?
But more importantly, it doesn't seem to solve the two main issues
of coroutines libraries written in C that were already solved in Go:
- How does the stack can grow or shrink? (specifying the stack size
in the worse case scenario doesn't scale well)
- How can a coroutine be moved to another operating system thread
and back? (useful when blocking or when parallelism is needed)