Lock Granularity Trade-off

A concurrent hash table uses a single mutex for all operations. A colleague suggests switching to per-bucket locks. What is the trade-off?

A

A single mutex is always preferred because it avoids deadlock between buckets

B

Per-bucket locks are always better, with no downside

C

More parallelism, but more memory overhead and complexity for cross-bucket operations like resizing

D

Less parallelism because threads must acquire more locks