summaryrefslogtreecommitdiff
path: root/ext/socket/rubysocket.h
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-17 01:05:30 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-17 01:05:30 +0000
commiteda2441b5354829bea9225a99e0b96f0ba40b7ab (patch)
tree6eca4779f256042dab98c3f20b28597be448cc27 /ext/socket/rubysocket.h
parent416c50f574fe9d13357b184c415c1bcda7c9e1eb (diff)
socket: avoid arg parsing in bsock_sendmsg_internal
* ext/socket/ancdata.c (bsock_sendmsg_internal): avoid arg parsing [ruby-core:71439] [Feature #11339] (rsock_bsock_sendmsg): make private, adjust for above (rsock_bsock_sendmsg_nonblock): ditto * ext/socket/rubysocket.h: adjust prototypes (rsock_opt_false_p): remove * ext/socket/basicsocket.c (rsock_init_basicsocket): define private methods * ext/socket/lib/socket.rb (BasicSocket#sendmsg): new wrapper (BasicSocket#sendmsg_nonblock): ditto target 0: a (ruby 2.3.0dev (2015-11-12 trunk 52550) [x86_64-linux]) target 1: b (ruby 2.3.0dev (2015-11-12 avoid-kwarg-capi 52550) [x86_64-linux] ----------------------------------------------------------- sendmsg_nonblock require 'socket' nr = 1_000_000 i = 0 msg = '.' buf = '.' begin r, w = UNIXSocket.pair(:SEQPACKET) while i < nr i += 1 w.sendmsg_nonblock(msg, exception: false) r.recv(1, 0, buf) end ensure r.close w.close end ----------------------------------------------------------- raw data: [["sendmsg_nonblock", [[1.875997293740511, 1.8452614955604076, 1.8449317328631878, 1.8418389447033405, 1.869386937469244], [1.5175109766423702, 1.4987873211503029, 1.4989623799920082, 1.47918451577425, 1.5017359890043736]]]] Elapsed time: 16.775453245 (sec) ----------------------------------------------------------- benchmark results: minimum results in each 5 measurements. Execution time (sec) name a b sendmsg_nonblock 1.842 1.479 Speedup ratio: compare with the result of `a' (greater is better) name b sendmsg_nonblock 1.245 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket/rubysocket.h')
-rw-r--r--ext/socket/rubysocket.h14
1 files changed, 4 insertions, 10 deletions
diff --git a/ext/socket/rubysocket.h b/ext/socket/rubysocket.h
index 652876c..2135ea4 100644
--- a/ext/socket/rubysocket.h
+++ b/ext/socket/rubysocket.h
@@ -361,8 +361,10 @@ VALUE rsock_sock_listen(VALUE sock, VALUE log);
VALUE rsock_sockopt_new(int family, int level, int optname, VALUE data);
#if defined(HAVE_SENDMSG)
-VALUE rsock_bsock_sendmsg(int argc, VALUE *argv, VALUE sock);
-VALUE rsock_bsock_sendmsg_nonblock(int argc, VALUE *argv, VALUE sock);
+VALUE rsock_bsock_sendmsg(VALUE sock, VALUE data, VALUE flags,
+ VALUE dest_sockaddr, VALUE controls);
+VALUE rsock_bsock_sendmsg_nonblock(VALUE sock, VALUE data, VALUE flags,
+ VALUE dest_sockaddr, VALUE controls, VALUE ex);
#else
#define rsock_bsock_sendmsg rb_f_notimplement
#define rsock_bsock_sendmsg_nonblock rb_f_notimplement
@@ -437,12 +439,4 @@ static inline void rsock_maybe_wait_fd(int fd) { }
# define MSG_DONTWAIT_RELIABLE 0
#endif
-static inline int
-rsock_opt_false_p(VALUE opt, VALUE sym)
-{
- if (!NIL_P(opt) && Qfalse == rb_hash_lookup2(opt, sym, Qundef))
- return 1;
- return 0;
-}
-
#endif