clogger RubyGem user+dev discussion/patches/pulls/bugs/help
 help / color / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
						download: 
* [PATCH 0/2] fixes for pure-Ruby users
@ 2015-02-27 22:45 Eric Wong
  2015-02-27 22:45 ` [PATCH 2/2] pure: use monotonic clock if possible Eric Wong
  0 siblings, 1 reply; 3+ results
From: Eric Wong @ 2015-02-27 22:45 UTC (permalink / raw)
  To: clogger-public

These bugs were discovered by some folks who forgot to upgrade from
clogger 1.0.1 when when upgrading from MRI 1.9.3 to 2.1 and were
inadvertently using the pure Ruby version instead of the C extension.

New release coming, but does not affect users of the C extension.

Eric Wong (2):
      pure: fix reentrancy of request_time
      pure: use monotonic clock if possible


^ permalink raw reply	[relevance 4%]

* [PATCH 2/2] pure: use monotonic clock if possible
  2015-02-27 22:45 [PATCH 0/2] fixes for pure-Ruby users Eric Wong
@ 2015-02-27 22:45 ` Eric Wong
  0 siblings, 0 replies; 3+ results
From: Eric Wong @ 2015-02-27 22:45 UTC (permalink / raw)
  To: clogger-public

Ruby 2.1.0 and later exposes Process.clock_gettime, resulting
in less garbage and access to the monotonic clock if it is
available.  Try to use it to achieve feature parity with the
C extension (which has always used the monotonic clock if possible).
---
 lib/clogger/pure.rb | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/lib/clogger/pure.rb b/lib/clogger/pure.rb
index 9efb00c..5e7ccfe 100644
--- a/lib/clogger/pure.rb
+++ b/lib/clogger/pure.rb
@@ -28,7 +28,7 @@ def initialize(app, opts = {})
   end
 
   def call(env)
-    start = Time.now
+    start = mono_now
     resp = @app.call(env)
     unless resp.instance_of?(Array) && resp.size == 3
       log(env, 500, {}, start)
@@ -165,7 +165,7 @@ def log(env, status, headers, start = @start)
       when OP_TIME_LOCAL; Time.now.strftime(op[1])
       when OP_TIME_UTC; Time.now.utc.strftime(op[1])
       when OP_REQUEST_TIME
-        t = Time.now - start
+        t = mono_now - start
         time_format(t.to_i, (t - t.to_i) * 1000000, op[1], op[2])
       when OP_TIME
         t = Time.now
@@ -185,4 +185,14 @@ def log(env, status, headers, start = @start)
     end
     nil
   end
+
+  # favor monotonic clock if possible, and try to use clock_gettime in
+  # more recent Rubies since it generates less garbage
+  if defined?(Process::CLOCK_MONOTONIC)
+    def mono_now; Process.clock_gettime(Process::CLOCK_MONOTONIC); end
+  elsif defined?(Process::CLOCK_REALTIME)
+    def mono_now; Process.clock_gettime(Process::CLOCK_REALTIME); end
+  else
+    def mono_now; Time.now.to_f; end
+  end
 end
-- 
EW


^ permalink raw reply	[relevance 7%]

* [ANN] clogger 2.0.2 - bugfixes for pure Ruby users
@ 2015-02-27 22:57 Eric Wong
  0 siblings, 0 replies; 3+ results
From: Eric Wong @ 2015-02-27 22:57 UTC (permalink / raw)
  To: clogger-public

This release fixes a bug discovered in the rarely-used pure Ruby
version in multithreaded Rack servers.

Some folks reported privately that they forgot to upgrade from
clogger 1.0.1 when when upgrading from MRI 1.9.3 to 2.1, so they
were inadvertently using the pure Ruby version instead of the
less-buggy C extension.  This also adds support for using the
monotonic clock under Ruby 2.1+ for request timing, matching
what the C extension used all along.

Users of the C extension are unaffected by bugs this release fixes
and do not need to upgrade.

* pure: fix reentrancy of request_time
* pure: use monotonic clock if possible

^ permalink raw reply	[relevance 5%]

Results 1-3 of 3 | reverse results
2015-02-27 22:45 [PATCH 0/2] fixes for pure-Ruby users Eric Wong
2015-02-27 22:45 ` [PATCH 2/2] pure: use monotonic clock if possible Eric Wong
2015-02-27 22:57 [ANN] clogger 2.0.2 - bugfixes for pure Ruby users 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

Example config snippet for mirrors

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/

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