* [ANN] raindrops 0.16.0 - real-time stats for preforking Rack servers
@ 2016-02-29 12:42 7% Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2016-02-29 12:42 UTC (permalink / raw)
To: ruby-talk, raindrops-public
raindrops is a real-time stats toolkit to show statistics for Rack HTTP
servers. It is designed for preforking servers such as unicorn, but
should support any Rack HTTP server on platforms supporting POSIX shared
memory. It may also be used as a generic scoreboard for sharing atomic
counters across multiple processes.
* http://raindrops.bogomips.org/
* No subscription necessary, no HTML mail:
raindrops-public@bogomips.org
* mail archives: http://bogomips.org/raindrops-public/
nntp://news.public-inbox.org/inbox.comp.lang.ruby.raindrops
* git clone git://bogomips.org/raindrops.git
* http://raindrops.bogomips.org/NEWS.atom.xml
* http://raindrops-demo.bogomips.org/
Changes:
raindrops 0.16.0 - minor fixes and workarounds
There's mainly a fix/workaround for Ruby 2.3 now returning
locale-aware strings for File.readlink and our test suite
using strange paths allowed by *nix.
https://bugs.ruby-lang.org/issues/12034
tcp_listener_stats won't return "true" object placeholders
if stats are configured for a non-existent listener.
There are also minor optimizations for Ruby 2.2+ (at the expense
of 2.1 and earlier).
And the usual round of minor tweaks and doc updates.
10 changes since v0.15.0:
gemspec: avoid circular dependency on unicorn
remove optimizations which made sense for older rubies
linux: workaround Ruby 2.3 change
linux: remove Pathname stdlib dependency
add .gitattributes for Ruby method detection
middleware: minor bytecode size reduction
doc: update URLs and references
README: remove indentation from URLs in RDoc
linux: tcp_listener_stats drops "true" placeholders
build: use '--local' domain for dev gem install
^ permalink raw reply [relevance 7%]
* Re: [PATCH 2/2] Return real stats instead of True
@ 2016-02-25 9:54 6% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2016-02-25 9:54 UTC (permalink / raw)
To: Hleb Valoshka; +Cc: raindrops-public
Eric Wong <normalperson@yhbt.net> wrote:
> Hleb Valoshka <375gnu@gmail.com> wrote:
>
> <no commit message body>
>
> This deserves an explanation (and ideally, a test case). I haven't
> looked at the code in a while and needed to think a bit about
> when the fix is relevant.
Resurrecting this from the old list 2.5 years ago:
http://bogomips.org/raindrops-public/20130909192020.GA18010@dcvr.yhbt.net/t/#u
I actually found a different reason for this problem. Normally,
I never change the set of listeners. But lately I've been
switching between backend HTTP servers that needed to run over TCP
(as opposed to Unix sockets) and dropping listeners occasionally
was causing "true" to show up in the results.
-----------8<------------
Subject: [PATCH] linux: tcp_listener_stats drops "true" placeholders
With invalid addresses specified which give no currently-bound
address, we must avoid leaving placeholders ('true' objects)
in our results.
Clean up some shadowing "cur" while we're at it.
---
ext/raindrops/linux_inet_diag.c | 15 ++++++++++++---
test/test_linux.rb | 7 +++++++
2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/ext/raindrops/linux_inet_diag.c b/ext/raindrops/linux_inet_diag.c
index 35bb127..58415c6 100644
--- a/ext/raindrops/linux_inet_diag.c
+++ b/ext/raindrops/linux_inet_diag.c
@@ -618,6 +618,13 @@ static VALUE tcp_stats(struct nogvl_args *args, VALUE addr)
return rb_listen_stats(&args->stats);
}
+static int drop_placeholders(st_data_t k, st_data_t v, st_data_t ign)
+{
+ if ((VALUE)v == Qtrue)
+ return ST_DELETE;
+ return ST_CONTINUE;
+}
+
/*
* call-seq:
* Raindrops::Linux.tcp_listener_stats([addrs[, sock]]) => hash
@@ -658,10 +665,9 @@ static VALUE tcp_listener_stats(int argc, VALUE *argv, VALUE self)
case T_ARRAY: {
long i;
long len = RARRAY_LEN(addrs);
- VALUE cur;
if (len == 1) {
- cur = rb_ary_entry(addrs, 0);
+ VALUE cur = rb_ary_entry(addrs, 0);
rb_hash_aset(rv, cur, tcp_stats(&args, cur));
return rv;
@@ -671,7 +677,7 @@ static VALUE tcp_listener_stats(int argc, VALUE *argv, VALUE self)
VALUE cur = rb_ary_entry(addrs, i);
parse_addr(&check, cur);
- rb_hash_aset(rv, cur, Qtrue);
+ rb_hash_aset(rv, cur, Qtrue /* placeholder */);
}
/* fall through */
}
@@ -689,6 +695,9 @@ static VALUE tcp_listener_stats(int argc, VALUE *argv, VALUE self)
st_foreach(args.table, NIL_P(addrs) ? st_to_hash : st_AND_hash, rv);
st_free_table(args.table);
+ if (RHASH_SIZE(rv) > 1)
+ rb_hash_foreach(rv, drop_placeholders, Qfalse);
+
/* let GC deal with corner cases */
if (argc < 2) rb_io_close(sock);
return rv;
diff --git a/test/test_linux.rb b/test/test_linux.rb
index 0e79a86..bfefcc4 100644
--- a/test/test_linux.rb
+++ b/test/test_linux.rb
@@ -214,6 +214,13 @@ def test_tcp_multi
assert_equal 0, stats[addr1].active
assert_equal 1, stats[addr2].queued
assert_equal 1, stats[addr2].active
+
+ # make sure we don't leave "true" placeholders in results if a
+ # listener becomes invalid (even momentarily).
+ s2.close
+ stats = tcp_listener_stats(addrs)
+ assert stats.values.all? { |x| x.instance_of?(Raindrops::ListenStats) },
+ "placeholders left: #{stats.inspect}"
end
# tries to overflow buffers
--
EW
^ permalink raw reply related [relevance 6%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2013-09-09 19:03 [PATCH 1/2] Add setup and teardown for ipv6 tests Hleb Valoshka
2013-09-09 19:03 ` [PATCH 2/2] Return real stats instead of True Hleb Valoshka
2013-09-09 19:20 ` Eric Wong
2016-02-25 9:54 6% ` Eric Wong
2016-02-29 12:42 7% [ANN] raindrops 0.16.0 - real-time stats for preforking Rack servers Eric Wong
Code repositories for project(s) associated with this public inbox
https://yhbt.net/raindrops.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).