-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Add Pool option initialSize
which create connections when the pool is started.
#499
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
…ol is started. 2. .bind() change to closure function. (closure is 10x faster than bind) 3. Fix some with refactoring.
Thanks for all the work! 💖 It looks good to me on first sight, but I won't be able to do a full review. Maybe @dresende @NateLillich can comment as well? About the performance tweak for bind: How often is the relevant code executed? Unless it's >= 1 Mhz it's probably not worth to micro optimise stuff. Last but not least: I've given you commit access to the project. Once you're happy with your patch, feel free to merge it in. |
I'm out of time now but will certainly look at it. Feel free to push it, |
I wonder when do you need to have a fixed amount of connections set up before use? Why is that better than just lazy create them when needed? |
@@ -307,3 +307,8 @@ Protocol.prototype._debugPacket = function(incoming, packet) { | |||
console.log(packet); | |||
console.log(''); | |||
}; | |||
|
|||
Protocol.prototype.reset = function() { | |||
this._queue = []; |
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.
Won't this lead to bugs where callbacks is not called?
What about emiting an error if there is any sequences in the queue?
Btw, I believe this._queue.length = 0
is faster. Should probably be tested.
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.
Yes. this._queue.length = 0
is faster. I'll fix. thanks.
If queue has the unexecuted query after connection.end()
was called,
I think there is no need to execute surely. (unusual circumstances. such as logic error)
The opposite case is likely to be problematic.
I'll think of a better way to solve.
@felixge @dresende @tellnes |
I had a look. Anyway, I don't really care as long as it doesn't make the code much more complicated, which shouldn't be the case here.
You'd have to clarify by what you mean by "expensive". MySQL is sort of optimized for a lot of connects / disconnects (because that's how a lot of PHP apps are configured to run), so it shouldn't be a problem for most cases.
How? What's the difference between creating the connections right away vs. when it's needed? Given a busy server, both should behave identical. |
bind initialSize If This is the result of a simple benchmark.
|
I assume this does not count the pool initialization time? If not, what happens in the meantime? Clients are not being served? |
Thank you for your interest. It's my zero downtime deployment policy. loop (servers)
I excepted the connection creation time because there was the 4 stage. I have been working to add features such as DBCP. Enjoy the reset of your stay. :) |
connection.connect(function(err) { | ||
if (!err) { | ||
successfulConnect++; | ||
self._allConnectionsLength++; |
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.
Will not successfulConnect
and self._allConnectionsLenght
always be the same?
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.
OK. This is the side-effect because of the revision. I'll remove unused variable. (Thanks!)
I'm at jsconf right now, so I won't get to review this right away. But maybe somebody else can chime in meanwhile? |
Fix : Pool.end() will not run if it is already running.
I will request again including the other features. |
(Please excuse my poor English. It's my first pull request. :])
I have been working to improve the pool features.
initialSize
which create connections when the pool is started.