-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Open
Description
The unannounced introduction of asyncio.Lock
when acquiring a connection from the pool in #3445 is causing noticeable performance degradation:
redis-py/redis/asyncio/connection.py
Lines 1095 to 1105 in 653d9ef
async def get_connection(self, command_name=None, *keys, **options): | |
async with self._lock: | |
"""Get a connected connection from the pool""" | |
connection = self.get_available_connection() | |
try: | |
await self.ensure_connection(connection) | |
except BaseException: | |
await self.release(connection) | |
raise | |
return connection |
This becomes especially evident under high load, where lock contention becomes a bottleneck. The issue affects version 5.3.0 and later. Others have also reported performance impacts, as noted in #3624.
I kind of understand the rationale behind this change, but personally, I would acquire the lock only to pop a connection and then performs ensure_connection
outside the lock. Alternatively, if it didn’t appear to cause issues in earlier versions, may be no lock at all?
Metadata
Metadata
Assignees
Labels
No labels