From: Eric Wong <normalperson@yhbt.net>
To: ruby.io.splice@librelist.org
Subject: [PATCH] avoid RARRAY_PTR usage for vmsplice
Date: Thu, 26 Sep 2013 19:15:18 +0000 [thread overview]
Message-ID: <20130926191518.GA880@dcvr.yhbt.net> (raw)
In-Reply-To: <20130926191518.GA880@dcvr.yhbt.net>
In case somebody finds vmsplice useful in Ruby, we avoid incurring
the performance loss from RARRAY_PTR under Ruby 2.1.0 and Rubinius.
However, I still haven't found a useful use of vmsplice under
Ruby (or any high-level languages).
---
ext/io_splice/io_splice_ext.c | 23 +++++++++--------------
1 file changed, 9 insertions(+), 14 deletions(-)
diff --git a/ext/io_splice/io_splice_ext.c b/ext/io_splice/io_splice_ext.c
index 1c938c3..9a838df 100644
--- a/ext/io_splice/io_splice_ext.c
+++ b/ext/io_splice/io_splice_ext.c
@@ -108,9 +108,6 @@ rb_thread_blocking_region(
#ifndef RSTRING_LEN
# define RSTRING_LEN(s) (RSTRING(s)->len)
#endif
-#ifndef RARRAY_PTR
-# define RARRAY_PTR(s) (RARRAY(s)->ptr)
-#endif
#ifndef RARRAY_LEN
# define RARRAY_LEN(s) (RARRAY(s)->len)
#endif
@@ -416,20 +413,18 @@ static VALUE nogvl_vmsplice(void *ptr)
/* this can't be a function since we use alloca() */
#define ARY2IOVEC(iov,iovcnt,expect,ary) \
do { \
- VALUE *cur; \
struct iovec *tmp; \
- long n; \
- cur = RARRAY_PTR(ary); \
- n = RARRAY_LEN(ary); \
- if (n > IOV_MAX) \
+ unsigned long i; \
+ iovcnt = (unsigned long)RARRAY_LEN(ary); \
+ if (iovcnt > IOV_MAX) \
rb_raise(rb_eArgError, "array is larger than IOV_MAX"); \
- iov = tmp = alloca(sizeof(struct iovec) * n); \
+ iov = tmp = alloca(sizeof(struct iovec) * iovcnt); \
expect = 0; \
- iovcnt = n; \
- for (; --n >= 0; tmp++, cur++) { \
- Check_Type(*cur, T_STRING); \
- tmp->iov_base = RSTRING_PTR(*cur); \
- tmp->iov_len = RSTRING_LEN(*cur); \
+ for (i = 0; i < iovcnt; tmp++, i++) { \
+ VALUE cur = rb_ary_entry(ary, (long)i); \
+ Check_Type(cur, T_STRING); \
+ tmp->iov_base = RSTRING_PTR(cur); \
+ tmp->iov_len = RSTRING_LEN(cur); \
expect += tmp->iov_len; \
} \
} while (0)
--
Eric Wong
parent reply other threads:[~2013-09-26 19:15 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <20130926191518.GA880@dcvr.yhbt.net>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://yhbt.net/ruby_io_splice/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130926191518.GA880@dcvr.yhbt.net \
--to=normalperson@yhbt.net \
--cc=ruby.io.splice@librelist.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhbt.net/ruby_io_splice.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).