nanassito opened a new pull request, #1944: URL: https://github.com/apache/cassandra-gocql-driver/pull/1944
We discovered during a load test of one of our service that there is a lot of locking going on in `host_source.go`. It turns out that a few can be optimized. Here are the set of changes in this PR: ## 1. ringDescriber / GetHosts The mutex surrounded all of getLocalHostInfo and getClusterPeerInfo (control-connection I/O). prevHosts / prevPartitioner were never written anywhere, so error returns were always nil / "". The mutex only serialized unrelated ring refreshes for no benefit. Removed mu, prevHosts, and prevPartitioner, and return nil, "", err on failure so concurrent GetHosts no longer block each other on network work. ## 2. HostInfo.ConnectAddressAndPort It only reads fields; it used Lock and blocked writers. Switched to RLock so it matches other read-only accessors. This is the most costly one exposed by our load test. ## 3. HostInfo.HostnameAndPort Uses a read-optimized path: RLock when hostname is already set (common case); Lock only when lazily filling hostname. ## 4. isValidPeer Previously mixed RPCAddress() (under lock) with direct reads of hostId, dataCenter, etc. (racy). One RLock covers all fields and avoids extra lock cycles from a separate RPCAddress call. ## 5. errorBroadcaster.broadcast Stopped holding the mutex while sending on listener channels (could stall other newListener / broadcast callers). Snapshot and clear listeners under the lock, then unlock and notify. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

