news.volyx.in

No nuances, just buggy code (was: related to Spinlock implementation) (realworldtech.com)

540 points by shaklee3 · 2473 days ago · 274 comments on HN

Article summary

The article discusses the challenges of implementing spinlocks and the importance of using established libraries and frameworks to avoid common pitfalls. Linus Torvalds responds to a post related to spinlock implementation and the Linux Scheduler, emphasizing the difficulties of getting locking right. He advises against rolling one's own locking routines, suggesting that even experienced developers can get it wrong. The discussion highlights the complexities of synchronization primitives and the need for careful consideration when implementing them.

Main themes

  • spinlock implementation
  • synchronization primitives
  • locking routines
  • Linux Scheduler
  • cryptographic hashing
  • performance optimization
  • system design

What commenters say

  • Rolling one's own locking routines is generally a bad idea due to the high likelihood of errors and the existence of well-tested alternatives.
  • Synchronization primitives, such as spinlocks and semaphores, are incredibly fiddly to get absolutely right and should be avoided if possible.
  • Using established libraries and frameworks, like libdispatch, can help avoid common pitfalls and improve performance.
  • Some argue that certain cryptographic hashing algorithms, like SHA-512, are insufficient for storing passwords and that more secure alternatives, like bcrypt or scrypt, should be used instead.
  • The Linux Scheduler's responsiveness is a complex issue, and benchmarks using spinlocks incorrectly can lead to misleading results.
  • Different synchronization primitives, such as mutexes and semaphores, have different use cases and should be chosen carefully to avoid performance issues.
  • The choice of synchronization primitive can have significant performance implications, and a deep understanding of the underlying system is necessary to make informed decisions.