-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
improve: significantly speed up the server launching time by async preloading tool providers #9146
Conversation
It has been tested on the local machine. Greatly helpful for development use and shrinking the restart time for production re-deployment. |
We plan to address this issue more thoroughly, so this PR will not be merged. |
It's still worth considering as a quick fix with no side effects before a thorough refactoring. |
Have you tried using separate threads to accomplish this function? In our environment, threads are managed by gevent, which helps maintain a consistent coding style. |
In current implementation, asyncio's implicit event loop is used. It is dispatching an async task rather than holding a new dedicated thread to prevent over-design left unused for the rest time. As for the gevent , it would be considered if we do want a separate thread here, and also gevent's patching adapts the usages on standard library cooperative by default . |
Sorry for the misunderstanding. What I meant is that we can use the standard library’s threading here, and gevent will handle converting it to asynchronous behavior. I would prefer not to introduce the asyncio module at this point. |
e2f9241
to
40d47a6
Compare
e7f2dd7
to
63f9c40
Compare
Well done! This startup acceleration is awesome. |
Have changed to use simple threading to execute the async task. Please have a review on it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks for the reconsideration and merging. |
…eloading tool providers (#9146)
…eloading tool providers (#9146)
…eloading tool providers (langgenius#9146)
Checklist:
Important
Please review the checklist below before submitting your pull request.
dev/reformat
(backend) andcd web && npx lint-staged
(frontend) to appease the lint godsDescription
aync preloading the tool providers, which is thread-safe as it does check the status and locking
(Tested on Apple MBP with M1pro chip)
Before:
Type of Change
Testing Instructions
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration