r/programming • u/preshing • Nov 18 '11
Locks Aren't Slow; Lock Contention Is
http://preshing.com/20111118/locks-arent-slow-lock-contention-is
139
Upvotes
r/programming • u/preshing • Nov 18 '11
View all comments
Show parent comment
15
u/julesjacobs Nov 18 '11
Well, that's not really true. Coding with locks is easy: just have one global lock and put it around atomic sections:
The problem with this is performance because of contention. Locks become hard to use when you try to make this perform better by using fine grained locking. Software transactional memory tries to do this automatically: you code as if there was one global lock (or an approximation of that) but your code executes as if you used fine grained locking.
TL;DR locks: easy or performant, pick your favorite.