-
-
Notifications
You must be signed in to change notification settings - Fork 59
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
Pool grows beyond max_size, hits open files limit #171
Comments
🙄 that was silly of me, I disabled it a while back when I was investigating some hanging tests and it seems I forgot to put it back.
well my intention was similar, but I would fill up the pool first and then start reusing. guess the pool size could be lowered to 50 (once I fix the
my main intention was to keep dependencies to a minimum, but I was also trying out various different pooling frameworks at the time and with deadpool I noticed some hanging async tests (though it wasn't due to deadpool after all, as I figured out later).
see the documentation on Clone and Deref. in your code, it seems |
Out of curiosity, what's the reasoning behind filling up the pool first rather than reusing aggressively?
Fair enough. It is actually nice to see people doing this intentionally. :-) |
it was just more simple to implement but I'm open to the idea. PRs are welcome of course 😸 |
Fixed and released in 1.1.0. I've set the server pool size to 50. If you need to bypass the pool, you can use the Server::new_with_port methods. |
pool size of 50 is still a bit of aggressive for macos, since default fd limit is 256. Maybe allow passing a configurable pool?
Or even shall we rewrite the pool to reuses servers more aggressively, rather than feeling it up first. |
I'll make a PR for it. |
@xjewer @kornelski fixes released in 1.2.0 |
Here's a straightforward reproducer:
This results in the following on a Linux system with
ulimit -n
being 1024:liskin@ea7e583 demonstrates why this is happening:
self.created
is never being incremented, thereforeself.created < self.max_size
always evaluates to truemockito::Server::new
exhaust the limit (on MacOS, the default limit is much lower, so just 50 calls exhausts it)Ideally, the pool would first try to satisfy a request using any available (recycled) servers, thus keeping the resource (file descriptor, thread, memory) usage minimal. If there are no available servers, only then would it create new ones on demand.
(I believe this is how deadpool behaves. What was wrong with it?)
(Unrelated, but when playing around with the code I did this and it compiles and tests pass. Being quite new to Rust, I'm guessing I'm missing an important reason for those
clone
s… What is it?)The text was updated successfully, but these errors were encountered: