-
Notifications
You must be signed in to change notification settings - Fork 185
feat(deadpool): cache num_cpus for better init performance #440
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
Conversation
bikeshedder
left a comment
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.
Please also add an entry to the CHANGELOG.md under the ## [Unreleased] describing the change.
b8857cc to
044303b
Compare
|
|
|
Oh, Should I switch it to |
044303b to
5dbab2e
Compare
|
I've switched to |
|
Sticking with the current MSRV of 1.75 is probably the better choice. btw. regarding the |
|
When running a container with 4 CPUs on an Ampere system with 192 cores I would not want to end up with a default pool size of 768 (192*4), would I? 🤔 |
|
Ah, I remember reading the documentation and went with |
|
I'm happy to merge this. I just would like to make a decision on that My vote would be to go with |
|
@PureWhiteWu I just merged this and created a separate PR for the default max pool size: |
On Linux environment, calling
num_cpus::get_physical()costs about 1-2ms per time, and in our scenario, we need to create hundreds to thousands ofPools dynamically(our services normally have hundreds to thousands of instances).Thus, it will cost a really long time to create the pools, which lead to service hang or request timeout.
This PR caches the result of
num_cpus::get_physicalto avoid calling it every time, which can greatly improve thenewperformance ofPool.Also, in container environment, we should call
num_cpus::get()instead ofnum_cpus::get_physical(), but since it may be a breaking change, I only added an TODO for it.PTAL, thanks!