Skip to content
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

refactor: flow control updates #92

Merged
merged 10 commits into from
Mar 19, 2018
Merged

refactor: flow control updates #92

merged 10 commits into from
Mar 19, 2018

Conversation

callmehiphop
Copy link
Contributor

@callmehiphop callmehiphop commented Mar 9, 2018

Depends on google-gax release including googleapis/gax-nodejs#197

Fixes #13
Fixes #50
Fixes #66
Closes #94

  • Tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Summary of changes

The overall goal of this PR is to refactor flow control.

Initially we thought a memory leak might be present (#13) however after investigating we found that writing to the server is significantly slower than reading from it and we needed to update our inventory after the write completes. Currently we update our inventory right before we write to the server, assuming that operation will resolve quickly, which sometimes it does not. This caused an increase in memory usage because we were flooding our write buffer with requests faster than they could be processed.

We also discovered a GAX issue, which would report a false positive on the completion time of writing data, this made it virtually impossible to implement any kind of flow control.

By addressing both of these issues, memory usage was cut down significantly and allows users to ack/nack messages as quickly as they please without any repercussions. It will also inadvertently fix #50 since we are now able to monitor when data is finished being written to the server.

Several smaller updates were also made in an attempt to cut back on duplicate messages, however until grpc/grpc-node#123 is resolved, its hard to say for certain if this will fix that issue entirely.

@callmehiphop callmehiphop added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Mar 9, 2018
connection.end(onEndCallback);
connection.pause();
connection.end(function(err) {
connection.cancel();

This comment was marked as spam.

pool.pause();
}

message.nack();

This comment was marked as spam.

@@ -86,7 +86,7 @@
"retry_params_name": "messaging"
},
"StreamingPull": {
"timeout_millis": 60000,

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@codecov
Copy link

codecov bot commented Mar 12, 2018

Codecov Report

Merging #92 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #92   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           8      8           
  Lines         848    863   +15     
=====================================
+ Hits          848    863   +15
Impacted Files Coverage Δ
src/connection-pool.js 100% <100%> (ø) ⬆️
src/subscription.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a7a4513...f7a8a5d. Read the comment docs.

@callmehiphop callmehiphop removed the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Mar 12, 2018
@callmehiphop
Copy link
Contributor Author

@stephenplusplus @alexander-fenster this should be ready for a final review, if you would care to take a look!

@@ -200,10 +219,13 @@ ConnectionPool.prototype.createConnection = function() {
.once(CHANNEL_ERROR_EVENT, onChannelError)
.once(CHANNEL_READY_EVENT, onChannelReady);

requestStream.on('status', function(status) {
setImmediate(() => onConnectionStatus(status));

This comment was marked as spam.

@googlebot
Copy link

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of the commit author(s) and merge this pull request when appropriate.

@stephenplusplus stephenplusplus merged commit 77b2d74 into googleapis:master Mar 19, 2018
@callmehiphop callmehiphop mentioned this pull request Mar 19, 2018
stephenplusplus pushed a commit to stephenplusplus/nodejs-pubsub that referenced this pull request Aug 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants