191
lock contention
Everyone queues on one lock. The lock is correct and the throughput is gone.
What is lock contention?
Contention is threads waiting on the same lock. The section is too coarse, too long, or hotter than you thought. Making the lock faster is sometimes wrong; splitting the lock or not locking (because the work is independent) is right.
Why does lock contention matter when vibe coding?
Models guard a whole service with one mutex to “be safe.” Requests line up. Name the grain of the lock.
How do you do lock contention?
Lock the smallest state. Do not hold it during I/O. Shard counters. If the data is per user, the lock is per user, not global.
How do you ask a model for lock contention?
The lock around (state) is too coarse. Narrow it so unrelated requests do not wait. Do not hold it during network or disk. Prefer a lock per (key) over one global lock.
What goes wrong with lock contention?
Removing the lock and calling it a performance fix. You traded contention for a race. Split the state instead.