Problem
Spine uses a global LOCK_POOL mutex to manage access to database connections. In high-concurrency environments (e.g., 32+ threads), this mutex becomes a major contention point as every thread must lock/unlock it twice for every polling item.
Proposed Solution
Refactor db_get_connection and db_release_connection to use lock-free data structures or atomic operations (C11 stdatomic.h) to manage the pool state.
- Replace the linear search + mutex with an atomic bitmask or a lock-free stack of available connection pointers.
Problem
Spine uses a global
LOCK_POOLmutex to manage access to database connections. In high-concurrency environments (e.g., 32+ threads), this mutex becomes a major contention point as every thread must lock/unlock it twice for every polling item.Proposed Solution
Refactor
db_get_connectionanddb_release_connectionto use lock-free data structures or atomic operations (C11stdatomic.h) to manage the pool state.