HENNGE / aiodynamo

Asynchronous, fast, pythonic DynamoDB Client
https://aiodynamo.readthedocs.io/
Other
75 stars 21 forks source link

Why 24.7 is slower than 22.12 ? #192

Open d-nishchay opened 1 month ago

d-nishchay commented 1 month ago

We are using 22.12 since long and whenever we try to use 24.7 version, the same queries which takes 8 seconds to complete via older version are taking 40 seconds via new version.

We have tested this many times and still facing the same performance.

What are we missing ?

d-nishchay commented 1 month ago

Via 22.12 version: image

Via 24.7 version: image

Same code, only version upgraded via poetry.

dimaqq commented 1 month ago

That’s probably too little to go on.

if you’ve got a local setup, perhaps you could run git bisect to narrow it down?

ojii commented 1 month ago

Agree with dimaqq, this isn't enough information to go on.

As a side-note, if performance is a concern to you, there's a few things you can/should do:

d-nishchay commented 1 month ago

Ok thanks for your responses, here's a sample code:

from aiodynamo.client import Client
from aiodynamo.credentials import Credentials
from aiodynamo.expressions import HashKey
from aiodynamo.http.aiohttp import AIOHTTP
from aiohttp import ClientSession

async def get_all_wars() -> list:
    """
    get_all_wars()
    """

    async with ClientSession() as session:
        client = Client(AIOHTTP(session), Credentials.auto(), "us-west-2")

        table = client.table("db_table_wars")
        all_wars = [record async for record in table.scan()]

        return all_wars

Now this code if run using 22.12 aiodynamo, would fetch me results in like 2 seconds (for example), but same if run via 24.7 (which is upgraded through poetry.toml file update) would fetch me results in like 8 seconds.

ojii commented 1 month ago

@d-nishchay can you provide profile output for the two versions in your environment? Basically run your script using python -m cProfile -o output.prof scriptname.py then upload the "output.prof" files for inspection.