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

perf: by default calling setNoDelay on the stream #406

Merged
merged 1 commit into from
Dec 2, 2016
Merged

Conversation

luin
Copy link
Collaborator

@luin luin commented Dec 2, 2016

@@ -295,6 +298,10 @@ Redis.prototype.connect = function (callback) {
});
}

if (_this.options.noDelay) {
stream.setNoDelay(true);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for TLS stream interface would look like stream.socket.setNoDelay(), I suppose we should add extra checks here

@AVVS
Copy link
Collaborator

AVVS commented Dec 2, 2016

@luin dont have write access, but probably would do the following to ensure tls support and make sure it doesn't crash here. Afaik there were some changes to TLS sockets, but this actually could make it implementation agnostic for the future, as in unix pipes might have different interface, etc:

P.S. don't have write access to push it to the branch, nor to merge when it all passes tests

      if (_this.options.noDelay) {
        if ('setNoDelay' in stream) {
          debug('disabling Naggle on raw tcp socket');
          stream.setNoDelay(true);
        }

        // NOTE: can also check based on _this.options.tls,
        // but this seems good enough
        if ('socket' in stream && 'setNoDelay' in stream.socket) {
          debug('disabling Naggle on tls socket');
          stream.socket.setNoDelay(true);
        }
      }

@luin
Copy link
Collaborator Author

luin commented Dec 2, 2016

I've sent a invite link to you so that you should be able to write to this repo. You can check out https://github.com/luin/ioredis/invitations if you don't see it.

It seems tls.TLSSocket is the subclass of net.Socket, so I think it should have the setNoDelay method (ref: nodejs/node-v0.x-archive#6194).

@AVVS
Copy link
Collaborator

AVVS commented Dec 2, 2016

@luin you seem to be right, at least for the latest versions, methods are proxied:
https://github.com/nodejs/node/blob/master/lib/_tls_wrap.js#L290-L305

In that case this should be good to go

@AVVS AVVS merged commit 990a221 into master Dec 2, 2016
@AVVS AVVS deleted the set-nodelay branch December 2, 2016 14:57
luin added a commit that referenced this pull request Jan 25, 2017
Disables Nagle's algorithm on the underlaying socket by default. Can be controlled via `options.noDelay`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants