clogger RubyGem user+dev discussion/patches/pulls/bugs/help
 help / Atom feed
* [PATCH 1/2] README: indicate we support all versions of C Ruby
@ 2013-09-26 18:46 Eric Wong
  2013-09-26 18:46 ` [PATCH 2/2] ext: avoid RARRAY_PTR usage for RGenGC in Ruby 2.1.0 Eric Wong
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Wong @ 2013-09-26 18:46 UTC (permalink / raw)
  To: clogger

Because we do, and this is still what I end up using all of the
time (startup performance, and I understand C, not C++)
---
 README | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/README b/README
index 50e7e79..9964c28 100644
--- a/README
+++ b/README
@@ -24,7 +24,7 @@ is customizable so you can specify exactly which fields to log.
 
 * Pure Ruby version for non-MRI versions of Ruby (or via CLOGGER_PURE=1
   in the environment).  The optional C extension is loaded by default
-  and supported under MRI 1.8.7, 1.9, 2.0 and Rubinius.
+  under C Ruby and under Rubinius, too.
 
 == SYNOPSIS
 
@@ -131,8 +131,8 @@ on the Rubyforge project page:
 
 * http://rubyforge.org/frs/?group_id=8896
 
-There is an optional C extension that should be compatible with MRI
-1.8/1.9.  The extensions should automatically be disabled for users of
+There is an optional C extension that should be compatible with
+MatzRuby.  The extensions should automatically be disabled for users of
 other Ruby implementations, but be sure to let us know if that's not the
 case.  No pre-built binaries are currently distributed, let us know if
 you're interested in helping with the release/support effort.
-- 
1.8.4



^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH 2/2] ext: avoid RARRAY_PTR usage for RGenGC in Ruby 2.1.0
  2013-09-26 18:46 [PATCH 1/2] README: indicate we support all versions of C Ruby Eric Wong
@ 2013-09-26 18:46 ` Eric Wong
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Wong @ 2013-09-26 18:46 UTC (permalink / raw)
  To: clogger

I have not benchmarked this, but this is unlikely to be a bottleneck
at all in older Rubies.  It results in a smaller binary, too, which
will help with icache bloat.  This should also improve performance
under Rubinius, too.
---
 ext/clogger_ext/clogger.c | 72 +++++++++++++++++++++++++----------------------
 1 file changed, 38 insertions(+), 34 deletions(-)

diff --git a/ext/clogger_ext/clogger.c b/ext/clogger_ext/clogger.c
index 04359f9..8995932 100644
--- a/ext/clogger_ext/clogger.c
+++ b/ext/clogger_ext/clogger.c
@@ -365,12 +365,12 @@ static void append_body_bytes_sent(struct clogger *c)
 	rb_str_buf_cat(c->log_buf, buf, nr);
 }
 
-static void append_ts(struct clogger *c, const VALUE *op, struct timespec *ts)
+static void append_ts(struct clogger *c, VALUE op, struct timespec *ts)
 {
 	char buf[sizeof(".000000") + ((sizeof(ts->tv_sec) * 8) / 3)];
 	int nr;
-	char *fmt = RSTRING_PTR(op[1]);
-	int ndiv = NUM2INT(op[2]);
+	char *fmt = RSTRING_PTR(rb_ary_entry(op, 1));
+	int ndiv = NUM2INT(rb_ary_entry(op, 2));
 	int usec = ts->tv_nsec / 1000;
 
 	nr = snprintf(buf, sizeof(buf), fmt,
@@ -379,7 +379,7 @@ static void append_ts(struct clogger *c, const VALUE *op, struct timespec *ts)
 	rb_str_buf_cat(c->log_buf, buf, nr);
 }
 
-static void append_request_time_fmt(struct clogger *c, const VALUE *op)
+static void append_request_time_fmt(struct clogger *c, VALUE op)
 {
 	struct timespec now;
 
@@ -388,7 +388,7 @@ static void append_request_time_fmt(struct clogger *c, const VALUE *op)
 	append_ts(c, op, &now);
 }
 
-static void append_time_fmt(struct clogger *c, const VALUE *op)
+static void append_time_fmt(struct clogger *c, VALUE op)
 {
 	struct timespec now;
 	int r = clock_gettime(CLOCK_REALTIME, &now);
@@ -641,35 +641,38 @@ static void special_var(struct clogger *c, enum clogger_special var)
 static VALUE cwrite(struct clogger *c)
 {
 	const VALUE ops = c->fmt_ops;
-	const VALUE *ary = RARRAY_PTR(ops);
-	long i = RARRAY_LEN(ops);
+	long i;
+	long len = RARRAY_LEN(ops);
 	VALUE dst = c->log_buf;
 
 	rb_str_set_len(dst, 0);
 
-	for (; --i >= 0; ary++) {
-		const VALUE *op = RARRAY_PTR(*ary);
-		enum clogger_opcode opcode = FIX2INT(op[0]);
+	for (i = 0; i < len; i++) {
+		VALUE op = rb_ary_entry(ops, i);
+		enum clogger_opcode opcode = FIX2INT(rb_ary_entry(op, 0));
+		VALUE op1 = rb_ary_entry(op, 1);
 
 		switch (opcode) {
 		case CL_OP_LITERAL:
-			rb_str_buf_append(dst, op[1]);
+			rb_str_buf_append(dst, op1);
 			break;
 		case CL_OP_REQUEST:
-			append_request_env(c, op[1]);
+			append_request_env(c, op1);
 			break;
 		case CL_OP_RESPONSE:
-			append_response(c, op[1]);
+			append_response(c, op1);
 			break;
 		case CL_OP_SPECIAL:
-			special_var(c, FIX2INT(op[1]));
+			special_var(c, FIX2INT(op1));
 			break;
 		case CL_OP_EVAL:
-			append_eval(c, op[1]);
+			append_eval(c, op1);
 			break;
 		case CL_OP_TIME_LOCAL:
-		case CL_OP_TIME_UTC:
-			append_time(c, opcode, op[1], op[2]);
+		case CL_OP_TIME_UTC: {
+			VALUE arg2 = rb_ary_entry(op, 2);
+			append_time(c, opcode, op1, arg2);
+		}
 			break;
 		case CL_OP_REQUEST_TIME:
 			append_request_time_fmt(c, op);
@@ -678,7 +681,7 @@ static VALUE cwrite(struct clogger *c)
 			append_time_fmt(c, op);
 			break;
 		case CL_OP_COOKIE:
-			append_cookie(c, op[1]);
+			append_cookie(c, op1);
 			break;
 		}
 	}
@@ -852,16 +855,15 @@ static VALUE ccall(struct clogger *c, VALUE env)
 	c->cookies = Qfalse;
 	rv = rb_funcall(c->app, call_id, 1, env);
 	if (TYPE(rv) == T_ARRAY && RARRAY_LEN(rv) == 3) {
-		VALUE *tmp = RARRAY_PTR(rv);
-
-		c->status = tmp[0];
-		c->headers = tmp[1];
-		c->body = tmp[2];
+		c->status = rb_ary_entry(rv, 0);
+		c->headers = rb_ary_entry(rv, 1);
+		c->body = rb_ary_entry(rv, 2);
 
-		rv = rb_ary_new4(3, tmp);
+		rv = rb_ary_dup(rv);
 		if (c->need_resp &&
-                    ! rb_obj_is_kind_of(tmp[1], cHeaderHash)) {
-			c->headers = rb_funcall(cHeaderHash, new_id, 1, tmp[1]);
+                    ! rb_obj_is_kind_of(c->headers, cHeaderHash)) {
+			c->headers = rb_funcall(cHeaderHash, new_id, 1,
+			                        c->headers);
 			rb_ary_store(rv, 1, c->headers);
 		}
 	} else {
@@ -919,17 +921,19 @@ static VALUE clogger_call(VALUE self, VALUE env)
 
 static void duplicate_buffers(VALUE ops)
 {
-	long i = RARRAY_LEN(ops);
-	VALUE *ary = RARRAY_PTR(ops);
+	long i;
+	long len = RARRAY_LEN(ops);
 
-	for ( ; --i >= 0; ary++) {
-		VALUE *op = RARRAY_PTR(*ary);
-		enum clogger_opcode opcode = FIX2INT(op[0]);
+	for (i = 0; i < len; i++) {
+		VALUE op = rb_ary_entry(ops, i);
+		enum clogger_opcode opcode = FIX2INT(rb_ary_entry(op, 0));
 
 		if (opcode == CL_OP_TIME_LOCAL || opcode == CL_OP_TIME_UTC) {
-			Check_Type(op[2], T_STRING);
-			op[2] = rb_str_dup(op[2]);
-			rb_str_modify(op[2]); /* trigger copy-on-write */
+			VALUE buf = rb_ary_entry(op, 2);
+			Check_Type(buf, T_STRING);
+			buf = rb_str_dup(buf);
+			rb_str_modify(buf); /* trigger copy-on-write */
+			rb_ary_store(op, 2, buf);
 		}
 	}
 }
-- 
1.8.4



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-26 18:46 [PATCH 1/2] README: indicate we support all versions of C Ruby Eric Wong
2013-09-26 18:46 ` [PATCH 2/2] ext: avoid RARRAY_PTR usage for RGenGC in Ruby 2.1.0 Eric Wong

clogger RubyGem user+dev discussion/patches/pulls/bugs/help

Archives are clonable:
	git clone --mirror https://bogomips.org/clogger-public
	git clone --mirror http://ou63pmih66umazou.onion/clogger-public

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.lang.ruby.clogger
	nntp://ou63pmih66umazou.onion/inbox.comp.lang.ruby.clogger

 note: .onion URLs require Tor: https://www.torproject.org/
       or Tor2web: https://www.tor2web.org/

AGPL code for this site: git clone https://public-inbox.org/ public-inbox