* [PATCH 1/3] raindrops: favor configured processor count over online count @ 2013-04-11 23:28 Eric Wong 2013-04-11 23:28 ` [PATCH 2/3] watcher: set Content-Type via assignment Eric Wong ` (2 more replies) 0 siblings, 3 replies; 4+ messages in thread From: Eric Wong @ 2013-04-11 23:28 UTC (permalink / raw) To: raindrops The runnable CPUs of a process may change over the lifetime of the process. So favor the count of configured processor count since that is more likely to be stable. We do not currently do not have special handling for hot-plugging/removal of CPUs on systems that may load raindrops in a single CPU state. --- ext/raindrops/raindrops.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ext/raindrops/raindrops.c b/ext/raindrops/raindrops.c index 6cc0d12..65c16e7 100644 --- a/ext/raindrops/raindrops.c +++ b/ext/raindrops/raindrops.c @@ -326,11 +326,13 @@ void Init_raindrops_linux_inet_diag(void); void Init_raindrops_linux_tcp_info(void); #endif -#ifndef _SC_NPROCESSORS_ONLN -# ifdef _SC_NPROC_ONLN -# define _SC_NPROCESSORS_ONLN _SC_NPROC_ONLN +#ifndef _SC_NPROCESSORS_CONF +# if defined _SC_NPROCESSORS_ONLN +# define _SC_NPROCESSORS_CONF _SC_NPROCESSORS_ONLN +# elif defined _SC_NPROC_ONLN +# define _SC_NPROCESSORS_CONF _SC_NPROC_ONLN # elif defined _SC_CRAY_NCPU -# define _SC_NPROCESSORS_ONLN _SC_CRAY_NCPU +# define _SC_NPROCESSORS_CONF _SC_CRAY_NCPU # endif #endif @@ -359,8 +361,8 @@ void Init_raindrops_ext(void) VALUE cRaindrops = rb_define_class("Raindrops", rb_cObject); long tmp = 2; -#ifdef _SC_NPROCESSORS_ONLN - tmp = sysconf(_SC_NPROCESSORS_ONLN); +#ifdef _SC_NPROCESSORS_CONF + tmp = sysconf(_SC_NPROCESSORS_CONF); #endif /* no point in padding on single CPU machines */ if (tmp == 1) -- 1.8.2.279.g631bc94 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] watcher: set Content-Type via assignment 2013-04-11 23:28 [PATCH 1/3] raindrops: favor configured processor count over online count Eric Wong @ 2013-04-11 23:28 ` Eric Wong 2013-04-11 23:28 ` [PATCH 3/3] Linux::TCP_Info: implement #get! instance method Eric Wong 2013-04-11 23:30 ` [PATCH 1/3] raindrops: favor configured processor count over online count Eric Wong 2 siblings, 0 replies; 4+ messages in thread From: Eric Wong @ 2013-04-11 23:28 UTC (permalink / raw) To: raindrops Relying on String#replace to set Content-Type stopped working with rack commit 3623d04526b953a63bfb3e72de2d6920a042563f This fixes compatibility with the Rack 1.5.x series. --- lib/raindrops/watcher.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/raindrops/watcher.rb b/lib/raindrops/watcher.rb index b7199a1..fb2df5b 100644 --- a/lib/raindrops/watcher.rb +++ b/lib/raindrops/watcher.rb @@ -323,7 +323,7 @@ def reset!(env, addr) res = Rack::Response.new url = req.referer || "#{req.host_with_port}/" res.redirect(url) - res.content_type.replace "text/plain" + res["Content-Type"] = "text/plain" res.write "Redirecting to #{url}" res.finish end -- 1.8.2.279.g631bc94 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] Linux::TCP_Info: implement #get! instance method 2013-04-11 23:28 [PATCH 1/3] raindrops: favor configured processor count over online count Eric Wong 2013-04-11 23:28 ` [PATCH 2/3] watcher: set Content-Type via assignment Eric Wong @ 2013-04-11 23:28 ` Eric Wong 2013-04-11 23:30 ` [PATCH 1/3] raindrops: favor configured processor count over online count Eric Wong 2 siblings, 0 replies; 4+ messages in thread From: Eric Wong @ 2013-04-11 23:28 UTC (permalink / raw) To: raindrops This allows reusing existing Linux::TCP_Info objects to avoid generating garbage. --- ext/raindrops/linux_tcp_info.c | 1 + test/test_linux_tcp_info.rb | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/ext/raindrops/linux_tcp_info.c b/ext/raindrops/linux_tcp_info.c index ce1c2d3..dcdb153 100644 --- a/ext/raindrops/linux_tcp_info.c +++ b/ext/raindrops/linux_tcp_info.c @@ -131,6 +131,7 @@ void Init_raindrops_linux_tcp_info(void) cTCP_Info = rb_define_class_under(cRaindrops, "TCP_Info", rb_cObject); rb_define_alloc_func(cTCP_Info, alloc); rb_define_private_method(cTCP_Info, "initialize", init, 1); + rb_define_method(cTCP_Info, "get!", init, 1); #define TCPI_DEFINE_METHOD(x) \ rb_define_method(cTCP_Info, #x, tcp_info_##x, 0) diff --git a/test/test_linux_tcp_info.rb b/test/test_linux_tcp_info.rb index 3b4a245..c947211 100644 --- a/test/test_linux_tcp_info.rb +++ b/test/test_linux_tcp_info.rb @@ -12,6 +12,7 @@ class TestLinuxTCP_Info < Test::Unit::TestCase # Linux kernel commit 5ee3afba88f5a79d0bff07ddd87af45919259f91 TCP_INFO_useful_listenq = `uname -r`.strip >= '2.6.24' + def test_tcp_server s = TCPServer.new(TEST_ADDR, 0) rv = Raindrops::TCP_Info.new s @@ -23,6 +24,11 @@ def test_tcp_server a = s.accept tmp = Raindrops::TCP_Info.new s assert_equal 0, tmp.unacked + before = tmp.object_id + + tmp.get!(s) + assert_equal before, tmp.object_id + ensure c.close if c a.close if a @@ -35,6 +41,7 @@ def test_accessors tcp_info_methods = tmp.methods - Object.new.methods assert tcp_info_methods.size >= 32 tcp_info_methods.each do |m| + next if m.to_sym == :get! val = tmp.__send__ m assert_kind_of Integer, val assert val >= 0 -- 1.8.2.279.g631bc94 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/3] raindrops: favor configured processor count over online count 2013-04-11 23:28 [PATCH 1/3] raindrops: favor configured processor count over online count Eric Wong 2013-04-11 23:28 ` [PATCH 2/3] watcher: set Content-Type via assignment Eric Wong 2013-04-11 23:28 ` [PATCH 3/3] Linux::TCP_Info: implement #get! instance method Eric Wong @ 2013-04-11 23:30 ` Eric Wong 2 siblings, 0 replies; 4+ messages in thread From: Eric Wong @ 2013-04-11 23:30 UTC (permalink / raw) To: raindrops These are all unrelated changes, I'll push this latest series to "master" unless there are any objections in a few days. It looks like I forgot to release a new version for a while, so a new one will probably come very soon (poke me if I forget again :x). ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-04-11 23:31 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-04-11 23:28 [PATCH 1/3] raindrops: favor configured processor count over online count Eric Wong 2013-04-11 23:28 ` [PATCH 2/3] watcher: set Content-Type via assignment Eric Wong 2013-04-11 23:28 ` [PATCH 3/3] Linux::TCP_Info: implement #get! instance method Eric Wong 2013-04-11 23:30 ` [PATCH 1/3] raindrops: favor configured processor count over online count Eric Wong
Code repositories for project(s) associated with this public inbox http://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).