clogger RubyGem user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [ANN] clogger 2.2.0 - configurable request logging for Rack
@ 2017-05-23  8:46  5% Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2017-05-23  8:46 UTC (permalink / raw)
  To: clogger-public, ruby-talk; +Cc: Pat Allan

Clogger is Rack middleware for logging HTTP requests.  The log format
is customizable so you can specify exactly which fields to log.

* https://bogomips.org/clogger/
* mail archives: https://bogomips.org/clogger-public/
* email us: clogger-public@bogomips.org (publically archived)
* git clone https://bogomips.org/clogger.git
* git clone git://bogomips.org/clogger
* https://bogomips.org/clogger/NEWS.atom.xml

Changes:

    clogger v2.2.0 - Rack 2.x compatibility fix
    
    This release fixes a Rack compatibility problem when
    Rack::BodyProxy wraps the Clogger object and calls
    "respond_to?" with two arguments.  This affects folks
    who put Clogger at lower levels of the middleware stack
    (below middlewares which use Rack::BodyProxy)
    
    A huge thanks to Pat Allan for coming up with this fix.
    
    Note, the recommended usage of clogger middleware is to have
    it at the outermost layer of the Rack middleware stack where
    it can give the most accurate $request_time measurement.
    
    There's also a couple of tiny internal improvements
    around the build and miniscule GC overhead reduction.
    
    Pat Allan (1):
          Update respond_to? calls for second argument.
    
    Eric Wong (3):
          clogger.c: comment to explain the lack of GC guard
          ext: reduce frozen string marking overhead
          build: remove build-time olddoc dependency
-- 
clogger v2.2.0

^ permalink raw reply	[relevance 5%]

* [PATCH] ext: reduce frozen string marking overhead
@ 2017-02-15 22:32  7% Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2017-02-15 22:32 UTC (permalink / raw)
  To: clogger-public

Using rb_global_variable excessively can be expensive since it
uses a singly-linked list to track addresses.  Since these
strings are all frozen and constant, put them into an array
instead and only mark the array as a global to improve locality.

Ruby 1.9+ has rb_gc_register_mark_object but it is
not part of the documented, public API, so we're not
using it, yet.
---
 ext/clogger_ext/clogger.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/ext/clogger_ext/clogger.c b/ext/clogger_ext/clogger.c
index 83ce76a..481dd61 100644
--- a/ext/clogger_ext/clogger.c
+++ b/ext/clogger_ext/clogger.c
@@ -29,6 +29,7 @@
  * under.
  */
 static clockid_t hopefully_CLOCK_MONOTONIC;
+static VALUE mark_ary;
 
 static void check_clock(void)
 {
@@ -949,7 +950,7 @@ static VALUE clogger_init_copy(VALUE clone, VALUE orig)
 
 #define CONST_GLOBAL_STR2(var, val) do { \
 	g_##var = rb_obj_freeze(rb_str_new(val, sizeof(val) - 1)); \
-	rb_global_variable(&g_##var); \
+	rb_ary_push(mark_ary, g_##var); \
 } while (0)
 
 #define CONST_GLOBAL_STR(val) CONST_GLOBAL_STR2(val, #val)
@@ -1015,6 +1016,9 @@ void Init_clogger_ext(void)
 {
 	VALUE tmp;
 
+	mark_ary = rb_ary_new();
+	rb_global_variable(&mark_ary);
+
 	check_clock();
 
 	write_id = rb_intern("write");
@@ -1060,4 +1064,6 @@ void Init_clogger_ext(void)
 	tmp = rb_const_get(rb_cObject, rb_intern("Rack"));
 	tmp = rb_const_get(tmp, rb_intern("Utils"));
 	cHeaderHash = rb_const_get(tmp, rb_intern("HeaderHash"));
+
+	rb_obj_freeze(mark_ary);
 }
-- 
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 --
2017-02-15 22:32  7% [PATCH] ext: reduce frozen string marking overhead Eric Wong
2017-05-23  8:46  5% [ANN] clogger 2.2.0 - configurable request logging for Rack Eric Wong

Code repositories for project(s) associated with this public inbox

	https://yhbt.net/clogger.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).