# Concurrency lock contention, thread/worker sizing, race conditions. ## Measure - concurrency profiling → locks, critical sections - thread dump analysis → states, blocked, deadlocks - lock analysis → hold times, wait times, contention rate - metrics → lock wait, thread utilization, context switch rate, contention ratio ## Optimize - lock-free data structures → atomics over locks - reduce critical sections → minimize locked work - tune worker pools → match pool to workload (CPU vs I/O bound) - async processing → offload blocking work - partition data → sharding reduces shared structure contention - read-write locks → read-heavy workloads ## Pitfalls - premature lock removal → complex, error-prone; only when contention measured - over-parallelism → context switch overhead - false sharing → adjacent writes invalidate cache lines - deadlock risk → changing lock order; test thoroughly