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

Add receive_buffer_bytes config setting to optionally set socket receive buffer size in bytes #27

Closed
wants to merge 3 commits into from

Conversation

IrlJidel
Copy link
Contributor

@IrlJidel IrlJidel commented Oct 17, 2016

Fixes #22

I used receive_buffer_bytes as config option name as kafka plugin uses that name as well.

Also an interesting thing I noticed during testing is that when run under jruby, it appears that the receive buffer is actually set to only half the configured value of net.core.rmem_default. Behavior is the same under OpenJDK and Oracle Java

:~$ sysctl net.core.rmem_default
net.core.rmem_default = 212992

:~$ rvm use jruby
Using jruby-9.0.5.0
:~$ ruby -ve  'require "socket"; @udp = UDPSocket.new(Socket::AF_INET); puts @udp.getsockopt(Socket::SOL_SOCKET, Socket::SO_RCVBUF).unpack("i")[0]'
jruby 9.0.5.0 (2.2.3) 2016-01-26 7bee00d OpenJDK 64-Bit Server VM 25.91-b14 on 1.8.0_91-8u91-b14-0ubuntu4~14.04-b14 +jit [linux-amd64]
106496

$ rvm use jruby-1.7
Using jruby-1.7.23
~$ ruby -ve  'require "socket"; @udp = UDPSocket.new(Socket::AF_INET); puts @udp.getsockopt(Socket::SOL_SOCKET, Socket::SO_RCVBUF).unpack("i")[0]'
jruby 1.7.23 (1.9.3p551) 2015-11-24 f496dd5 on OpenJDK 64-Bit Server VM 1.8.0_91-8u91-b14-0ubuntu4~14.04-b14 +jit [linux-amd64]
106496

~$ rvm use ruby
Using ruby-2.3.0
~$ ruby -ve  'require "socket"; @udp = UDPSocket.new(Socket::AF_INET); puts @udp.getsockopt(Socket::SOL_SOCKET, Socket::SO_RCVBUF).unpack("i")[0]'
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]
212992

:~$ rvm use ruby-1.9
Using ruby-1.9.3-p551
~$ ruby -ve  'require "socket"; @udp = UDPSocket.new(Socket::AF_INET); puts @udp.getsockopt(Socket::SOL_SOCKET, Socket::SO_RCVBUF).unpack("i")[0]'
ruby 1.9.3p551 (2014-11-13 revision 48407) [x86_64-linux]
212992

@jsvd
Copy link
Contributor

jsvd commented Oct 17, 2016

@IrlJidel interesting, it seems like a misinterpretation of the documentation of the SO_RCVBUF:

              The kernel doubles this value (to allow space for bookkeeping
              overhead) when it is set using setsockopt(2), and this doubled
              value is returned by getsockopt(2).

@udp.setsockopt(Socket::SOL_SOCKET, Socket::SO_RCVBUF, @receive_buffer_bytes)
end
rcvbuf = @udp.getsockopt(Socket::SOL_SOCKET, Socket::SO_RCVBUF).unpack("i")[0]
if @receive_buffer_bytes and rcvbuf != @receive_buffer_bytes
Copy link
Contributor

Choose a reason for hiding this comment

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

please use && instead of and

@jsvd
Copy link
Contributor

jsvd commented Oct 17, 2016

very minor comment, will merge once addressed.

@IrlJidel
Copy link
Contributor Author

@jsvd updated PR to address 'and' vs '&&' usage

@elasticsearch-bot
Copy link

João Duarte merged this into the following branches!

Branch Commits
master b3903b1, 23c7af6, c8e57c9

elasticsearch-bot pushed a commit that referenced this pull request Oct 17, 2016
elasticsearch-bot pushed a commit that referenced this pull request Oct 17, 2016
@IrlJidel IrlJidel deleted the rcvbuf branch October 17, 2016 18:11
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.

None yet

3 participants