Project

General

Profile

Feature #11229

[PATCH] socket: allow exception-free nonblocking sendmsg/recvmsg

Added by Eric Wong over 1 year ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Target version:
-
[ruby-core:69473]

Description

As documented before, exceptions are expensive and IO::Wait*able are too
common in socket applications to be the exceptional case. Datagram
sockets deserve the same API which stream sockets are allowed with
read_nonblock and write_nonblock.

Note: this does not offer a performance advantage under optimal
conditions when both ends are equally matched in speed, but it it
does make debug output cleaner by avoiding exceptions whenever
the receiver slows down.

I think I have only one more change I'd like to add for recv/recvmsg* APIs
in the future: destination buffers to reduce GC overhead

Associated revisions

Revision 50910
Added by normal over 1 year ago

socket: allow exception-free nonblocking sendmsg/recvmsg

As documented before, exceptions are expensive and IO::Wait*able are too
common in socket applications to be the exceptional case. Datagram
sockets deserve the same API which stream sockets are allowed with
read_nonblock and write_nonblock.

Note: this does not offer a performance advantage under optimal
conditions when both ends are equally matched in speed, but it it
does make debug output cleaner by avoiding exceptions whenever
the receiver slows down.

  • ext/socket/ancdata.c (bsock_sendmsg_internal, bsock_recvmsg_internal): support "exception: false" kwarg
  • ext/socket/init.c (rsock_s_recvfrom_nonblock): ditto
  • ext/socket/init.c (rsock_s_recvfrom_nonblock): use rsock_opt_false_p
  • ext/socket/socket.c (sock_connect_nonblock): ditto
  • ext/socket/rubysocket.h (rsock_opt_false_p): new function
  • ext/socket/basicsocket.c (bsock_recv_nonblock): update rdoc
  • ext/socket/udpsocket.c (udp_recvfrom_nonblock): ditto
  • test/socket/test_nonblock.rb: new tests

[Feature #11229]

Revision 50910
Added by normal over 1 year ago

socket: allow exception-free nonblocking sendmsg/recvmsg

As documented before, exceptions are expensive and IO::Wait*able are too
common in socket applications to be the exceptional case. Datagram
sockets deserve the same API which stream sockets are allowed with
read_nonblock and write_nonblock.

Note: this does not offer a performance advantage under optimal
conditions when both ends are equally matched in speed, but it it
does make debug output cleaner by avoiding exceptions whenever
the receiver slows down.

  • ext/socket/ancdata.c (bsock_sendmsg_internal, bsock_recvmsg_internal): support "exception: false" kwarg
  • ext/socket/init.c (rsock_s_recvfrom_nonblock): ditto
  • ext/socket/init.c (rsock_s_recvfrom_nonblock): use rsock_opt_false_p
  • ext/socket/socket.c (sock_connect_nonblock): ditto
  • ext/socket/rubysocket.h (rsock_opt_false_p): new function
  • ext/socket/basicsocket.c (bsock_recv_nonblock): update rdoc
  • ext/socket/udpsocket.c (udp_recvfrom_nonblock): ditto
  • test/socket/test_nonblock.rb: new tests

[Feature #11229]

Revision 50913
Added by normal over 1 year ago

NEWS: update for socket API changes [ci skip]

[Feature #11242] [Feature #11229]

Revision 50913
Added by normal over 1 year ago

NEWS: update for socket API changes [ci skip]

[Feature #11242] [Feature #11229]

Revision 52608
Added by normal over 1 year ago

socket: update doc for recvfrom_nonblock [ci skip]

  • ext/socket/lib/socket.rb (Socket#recvfrom_nonblock): UDPSocket#recvfrom_nonblock): update doc for exception: false and destination buffer [Feature #11229] [Feature #11242]

Revision 52608
Added by normal over 1 year ago

socket: update doc for recvfrom_nonblock [ci skip]

  • ext/socket/lib/socket.rb (Socket#recvfrom_nonblock): UDPSocket#recvfrom_nonblock): update doc for exception: false and destination buffer [Feature #11229] [Feature #11242]

History

#1 [ruby-core:69542] Updated by Yukihiro Matsumoto over 1 year ago

Looks good to me. Go ahead.

Matz.

#2 Updated by Anonymous over 1 year ago

  • Status changed from Open to Closed

Applied in changeset r50910.


socket: allow exception-free nonblocking sendmsg/recvmsg

As documented before, exceptions are expensive and IO::Wait*able are too
common in socket applications to be the exceptional case. Datagram
sockets deserve the same API which stream sockets are allowed with
read_nonblock and write_nonblock.

Note: this does not offer a performance advantage under optimal
conditions when both ends are equally matched in speed, but it it
does make debug output cleaner by avoiding exceptions whenever
the receiver slows down.

  • ext/socket/ancdata.c (bsock_sendmsg_internal, bsock_recvmsg_internal): support "exception: false" kwarg
  • ext/socket/init.c (rsock_s_recvfrom_nonblock): ditto
  • ext/socket/init.c (rsock_s_recvfrom_nonblock): use rsock_opt_false_p
  • ext/socket/socket.c (sock_connect_nonblock): ditto
  • ext/socket/rubysocket.h (rsock_opt_false_p): new function
  • ext/socket/basicsocket.c (bsock_recv_nonblock): update rdoc
  • ext/socket/udpsocket.c (udp_recvfrom_nonblock): ditto
  • test/socket/test_nonblock.rb: new tests

[Feature #11229]

Also available in: Atom PDF