Skip to content

Async performance issue since version 5.3.0 #3692

Open
@d33kayyy

Description

@d33kayyy

The unannounced introduction of asyncio.Lock when acquiring a connection from the pool in #3445 is causing noticeable performance degradation:

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions