Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It will only bring your application to a grinding halt if it's on the critical path. Most data in most programs can be protected with a plain old mutex and everyone is happy with the performance. Even on the hot path you may get trivial scaling to 2 or 4 threads with a global mutex protecting critical data, as we see with memcached. Sharing doesn't start to offend Amdahl until you have many threads and the critical section is relatively costly compared to the rest of the program.


Worth calling out that the introduction of multiple locks can lead to deadlocks etc.

It would actually make for a nice library to have lock acquisition decoupled from lock scope in the caller. Eg every call to lock acquire passes some identifier, and the lock implementation decides what it will do with that identifier eg global lock, scoped lock etc


I find that thread safety annotations in clang help prevent deadlocks when there’s a tricky section.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: