* [ANN] kgio 2.10.0 - kinder, gentler I/O for Ruby + Unix
@ 2015-09-06 8:37 6% Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2015-09-06 8:37 UTC (permalink / raw)
To: kgio-public; +Cc: ruby-talk
kgio provides non-blocking I/O methods for Ruby without raising
exceptions on EAGAIN and EINPROGRESS. It is intended for use with the
unicorn Rack server, but may be used by other applications (that run on
Unix-like platforms).
Note: I do not recommend using kgio for future applications, Ruby 2.x
has a lot of the functionality of kgio and Ruby 2.3.0 (due in December)
will have even more (with more improvements planned).
Keep an eye on the NEWS file for Ruby 2.3+ releases.
However, I'll continue maintaining kgio for legacy purposes
indefinitely.
* homepage: http://bogomips.org/kgio/
* public mailing list: kgio-public@bogomips.org
* git clone git://bogomips.org/kgio.git
* Atom feed http://bogomips.org/kgio/NEWS.atom.xml
* mailing list archives: http://bogomips.org/kgio-public/
Changes: kgio 2.10.0 - slimming down...
The largely-unused autopush functionality is now a no-op.
Existing applications will probably not notice, and are
better off using MSG_MORE anyways if they're on Linux.
Our poll(2) wrapper now uses rb_hash_clear if available,
reducing global method cache dependence.
shortlog of changes since 2.9.3:
README: remove reference to Rainbows!
writev: update comment on preserving errno
poll: avoid rb_funcall for rb_hash_clear
minor doc updates
remove autopush support and make it a no-op
HACKING: update URL for Message-ID lookup
--
EW
^ permalink raw reply [relevance 6%]
* [PATCH] poll: avoid rb_funcall for rb_hash_clear
@ 2015-08-11 19:58 7% Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2015-08-11 19:58 UTC (permalink / raw)
To: kgio-public; +Cc: Eric Wong
rb_funcall will always be slower, and currently hits the
global method cache in MRI.
---
ext/kgio/extconf.rb | 1 +
ext/kgio/poll.c | 14 +++++++++++++-
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/ext/kgio/extconf.rb b/ext/kgio/extconf.rb
index 44888dd..5b0b74a 100644
--- a/ext/kgio/extconf.rb
+++ b/ext/kgio/extconf.rb
@@ -51,6 +51,7 @@
have_func('rb_thread_blocking_region')
have_func('rb_thread_io_blocking_region')
have_func('rb_str_set_len')
+have_func("rb_hash_clear", "ruby.h") # Ruby 2.0+
have_func('rb_time_interval')
have_func('rb_wait_for_single_fd')
have_func('rb_str_subseq')
diff --git a/ext/kgio/poll.c b/ext/kgio/poll.c
index 1f931e7..1d8ebd1 100644
--- a/ext/kgio/poll.c
+++ b/ext/kgio/poll.c
@@ -12,8 +12,18 @@
#endif
static VALUE sym_wait_readable, sym_wait_writable;
+
+#ifdef HAVE_RB_HASH_CLEAR /* Ruby >= 2.0 */
+# define my_hash_clear(h) (void)rb_hash_clear(h)
+#else /* !HAVE_RB_HASH_CLEAR - Ruby <= 1.9.3 */
static ID id_clear;
+static void my_hash_clear(VALUE h)
+{
+ rb_funcall(h, id_clear, 0);
+}
+#endif /* HAVE_RB_HASH_CLEAR */
+
struct poll_args {
struct pollfd *fds;
nfds_t nfds;
@@ -126,7 +136,7 @@ static VALUE poll_result(int nr, struct poll_args *a)
int rc;
if ((nfds_t)nr != a->nfds)
- rb_funcall(a->ios, id_clear, 0);
+ my_hash_clear(a->ios);
for (; nr > 0; fds++) {
if (fds->revents == 0)
continue;
@@ -218,7 +228,9 @@ void init_kgio_poll(void)
sym_wait_readable = ID2SYM(rb_intern("wait_readable"));
sym_wait_writable = ID2SYM(rb_intern("wait_writable"));
+#ifndef HAVE_RB_HASH_CLEAR
id_clear = rb_intern("clear");
+#endif
#define c(x) rb_define_const(mKgio,#x,INT2NUM((int)x))
--
EW
^ permalink raw reply related [relevance 7%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2015-08-11 19:58 7% [PATCH] poll: avoid rb_funcall for rb_hash_clear Eric Wong
2015-09-06 8:37 6% [ANN] kgio 2.10.0 - kinder, gentler I/O for Ruby + Unix Eric Wong
Code repositories for project(s) associated with this public inbox
https://yhbt.net/kgio.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).