Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why 24.7 is slower than 22.12 ? #192

Open
d-nishchay opened this issue Sep 7, 2024 · 5 comments
Open

Why 24.7 is slower than 22.12 ? #192

d-nishchay opened this issue Sep 7, 2024 · 5 comments

Comments

@d-nishchay
Copy link

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
Copy link
Author

Via 22.12 version:
image

Via 24.7 version:
image

Same code, only version upgraded via poetry.

@dimaqq
Copy link
Contributor

dimaqq commented Sep 7, 2024

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
Copy link
Contributor

ojii commented Sep 9, 2024

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

  • Can you share the code used?
  • Are you sure that the aiodynamo version is the only thing changed (could it be a dependency of aiodynamo that got upgrade alongside it? did no other code/dependency change?)
  • As dimaqq said, a git bisect to narrow down which change in aiodynamo seems to have caused this would be useful, or if that's impossible, at least which version between 22.21 and 24.7?

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

  • Always re-use Credentials. Your app/script should only ever create a single Credentials instance.
  • Always re-use the HTTP client. All your aiodynamo clients should use the same HTTP client session.
  • Make sure your HTTP client is configured correctly. In one project where we use aiohttp as the HTTP client we doubled the per-host connection limit (the limit argument to TCPConnector and added logging (see tracing) to get warned if we hit that limit. httpx presumably has similar tuning options.

@d-nishchay
Copy link
Author

d-nishchay commented Sep 9, 2024

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
Copy link
Contributor

ojii commented Sep 11, 2024

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants