Azure / azure-sdk-for-python

This repository is for active development of the Azure SDK for Python. For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/python/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-python.
MIT License
4.36k stars 2.71k forks source link

azure-ai-documentintelligence AIO capability is not working #36217

Closed jacky0218 closed 1 day ago

jacky0218 commented 1 week ago

Describe the bug The AIO version runs no faster than without AIO

To Reproduce I just followed the code example as below. (https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/documentintelligence/azure-ai-documentintelligence/samples/aio/sample_analyze_general_documents_async.py)

Expected behavior AIO-level speed.

github-actions[bot] commented 1 week ago

Thank you for your feedback. Tagging and routing to the team member best able to assist.

kristapratico commented 1 week ago

@jacky0218 thanks for your feedback, @YalinLi0312 will take a look and get back to you as soon as possible. Can I ask how you're measuring speed between sync and async?

jacky0218 commented 1 week ago

@kristapratico Thanks for the support. I've tested a 5-page PDF, and the speed from sync is 11.322867231443524. Async yields a speed of 11.022184098139405.

lmazuel commented 1 week ago

Hi @jacky0218

AIO programming means that the HTTP IOs under the hood are managed using async/await and an asyncio event loop, in order to avoid blocking code on sockets. If the Azure service needs 11 seconds to process your PDF, you can't finish faster than what the service will do, you just do a better usage of your local CPU and socket usage with aio. Therefore, the times you got here sounds reasonable given your limitation is service related, not Python related. To say it differently, if you run the same PDF through C# or Java SDK, you will still get 11 seconds, since the SDK is just a messenger here and there isn't heavy processing done by the SDK in this specific scenario.

github-actions[bot] commented 1 week ago

Hi @jacky0218. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text "/unresolve" to remove the "issue-addressed" label and continue the conversation.

github-actions[bot] commented 1 day ago

Hi @jacky0218, since you haven’t asked that we /unresolve the issue, we’ll close this out. If you believe further discussion is needed, please add a comment /unresolve to reopen the issue.