Not logged in
Log in now
Create an account
Subscribe to LWN
LWN.net Weekly Edition for May 23, 2013
An "enum" for Python 3
An unexpected perf feature
LWN.net Weekly Edition for May 16, 2013
A look at the PyPy 2.0 release
Is there a good reason linux doesn't have lots of lockless data structures all over the place?
That would dramatically increase multi-core performance, yeah?
lockless data structures?
Posted Jul 31, 2008 21:38 UTC (Thu) by bronson (subscriber, #4806)
Yes. Lockless is quite simple in theory but gets really difficult in the real world (say,
where ring buffers actually wrap). You thought threading was hard to prove correct, debug,
and maintain? Lockless is harder in every way.
I converted a small event-based networking app I wrote two years ago to use lockless lists.
It was fun but ultimately a waste of time... It didn't run much faster but now it contained
subtle boundary conditions that, when violated by an unwary programmer, resulted in occasional
corruptions under load. Good luck trying to debug that (don't bother stepping through it in
There are a few areas where lockless really is worth it, especially when you have a hot,
high-contention buffer or stack. But be prepared for some tough maintenance.
Posted Aug 1, 2008 1:43 UTC (Fri) by maney (subscriber, #12630)
My personal opinion is that lock-free algorithms are not a good generic synchronization
technique, and are definitely very very complex and difficult to understand. However, in
certain specific cases, lock-free can be simple, elegant, and a huge performance advantage
over traditional approaches.
Posted Aug 1, 2008 15:42 UTC (Fri) by PaulMcKenney (subscriber, #9624)
We are still learning how best to use RCU to obtain good performance and scalability while keeping things (again, relatively) simple. For that matter, we are also still learning when not to use RCU. RCU is quite specialized, so is not always the right tool for the job, much though I might wish it otherwise. ;-)
Linus on lockless data structures
Posted Aug 1, 2008 14:01 UTC (Fri) by pflugstad (subscriber, #224)
Linus posts in a long thread over on RealWorldTech about lockless algorithms and SMP scaling:
Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds