unicorn Ruby/Rack server 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] unicorn 5.5.0.pre1 - Rack HTTP server for fast clients and Unix
@ 2018-12-20 22:28  5% Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2018-12-20 22:28 UTC (permalink / raw)
  To: ruby-talk, unicorn-public; +Cc: Jeremy Evans

unicorn is an HTTP server for Rack applications designed to only serve
fast clients on low-latency, high-bandwidth connections and take
advantage of features in Unix/Unix-like kernels.  Slow clients should
only be served by placing a reverse proxy capable of fully buffering
both the the request and response in between unicorn and slow clients.

Disclaimer:

Due to its ability to tolerate crashes and isolate clients, unicorn
is unfortunately known to prolong the existence of bugs in applications
and libraries which run on top of it.

* https://bogomips.org/unicorn/
* public list: unicorn-public@bogomips.org
* mail archives: https://bogomips.org/unicorn-public/
* git clone https://bogomips.org/unicorn.git
* https://bogomips.org/unicorn/NEWS.atom.xml
* nntp://news.public-inbox.org/inbox.comp.lang.ruby.unicorn

This is a pre-release RubyGem intended for testing.

Changes:

unicorn 5.5.0.pre1

Jeremy Evans contributed the "default_middleware" configuration option:

  https://bogomips.org/unicorn-public/20180913192055.GD48926@jeremyevans.local/

Jeremy also contributed the ability to use separate groups for the process
and log files:

  https://bogomips.org/unicorn-public/20180913192449.GE48926@jeremyevans.local/

There's also a couple of uninteresting minor optimizations and
documentation additions.

Eric Wong (10):
      remove random seed reset atfork
      use IO#wait instead of kgio_wait_readable
      Merge branch '5.4-stable'
      shrink pipes under Linux
      socket_helper: add hint for FreeBSD users for accf_http(9)
      tests: ensure -N/--no-default-middleware not supported in config.ru
      doc: update more URLs to use HTTPS and avoid redirects
      deduplicate strings VM-wide in Ruby 2.5+
      doc/ISSUES: add links to git clone-able mail archives of our dependencies
      README: minor updates and additional disclaimer

Jeremy Evans (2):
      Make Worker#user support different process primary group and log file group
      Support default_middleware configuration option
-- 

^ permalink raw reply	[relevance 5%]

* [PATCH] shrink pipes under Linux
@ 2018-08-20 20:30  7% Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2018-08-20 20:30 UTC (permalink / raw)
  To: unicorn-public; +Cc: Eric Wong

We have never had any need for pipes with the default 64K
capacity on Linux.  Our pipes are only used for tiny writes
in signal handlers and to perform parent shutdown detection.

With the current /proc/sys/fs/pipe-user-pages-soft
default, only 1024 pipes can be created by an unprivileged
user before Linux clamps down the pipe size to 4K (a single page)
for newly-created pipes[1].

So avoid penalizing OTHER pipe users who could benefit from the
increased capacity and use only a single page for ourselves.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/pipe.c?h=v4.18#n642
---
 lib/unicorn.rb              | 18 ++++++++++++++++--
 lib/unicorn/http_request.rb |  1 -
 lib/unicorn/launcher.rb     |  2 +-
 test/unit/test_util.rb      | 23 +++++++++++++++++++++++
 4 files changed, 40 insertions(+), 4 deletions(-)

diff --git a/lib/unicorn.rb b/lib/unicorn.rb
index 85e4df1..b6dae36 100644
--- a/lib/unicorn.rb
+++ b/lib/unicorn.rb
@@ -2,6 +2,7 @@
 require 'etc'
 require 'stringio'
 require 'kgio'
+require 'raindrops'
 require 'io/wait'
 
 begin
@@ -113,9 +114,22 @@ def self.log_error(logger, prefix, exc)
     exc.backtrace.each { |line| logger.error(line) }
   end
 
-  # remove this when we only support Ruby >= 2.0
+  F_SETPIPE_SZ = 1031 if RUBY_PLATFORM =~ /linux/
+
   def self.pipe # :nodoc:
-    Kgio::Pipe.new.each { |io| io.close_on_exec = true }
+    Kgio::Pipe.new.each do |io|
+      io.close_on_exec = true  # remove this when we only support Ruby >= 2.0
+
+      # shrink pipes to minimize impact on /proc/sys/fs/pipe-user-pages-soft
+      # limits.
+      if defined?(F_SETPIPE_SZ)
+        begin
+          io.fcntl(F_SETPIPE_SZ, Raindrops::PAGE_SIZE)
+        rescue Errno::EINVAL
+          # old kernel
+        end
+      end
+    end
   end
   # :startdoc:
 end
diff --git a/lib/unicorn/http_request.rb b/lib/unicorn/http_request.rb
index d713b19..8bb884b 100644
--- a/lib/unicorn/http_request.rb
+++ b/lib/unicorn/http_request.rb
@@ -2,7 +2,6 @@
 # :enddoc:
 # no stable API here
 require 'unicorn_http'
-require 'raindrops'
 
 # TODO: remove redundant names
 Unicorn.const_set(:HttpRequest, Unicorn::HttpParser)
diff --git a/lib/unicorn/launcher.rb b/lib/unicorn/launcher.rb
index 5eafe5b..78e8f39 100644
--- a/lib/unicorn/launcher.rb
+++ b/lib/unicorn/launcher.rb
@@ -31,7 +31,7 @@ def self.daemonize!(options)
       #  \_ parent  - exits immediately ASAP
       #      \_ unicorn master - writes to pipe when ready
 
-      rd, wr = IO.pipe
+      rd, wr = Unicorn.pipe
       grandparent = $$
       if fork
         wr.close # grandparent does not write
diff --git a/test/unit/test_util.rb b/test/unit/test_util.rb
index dc6302e..586fc6c 100644
--- a/test/unit/test_util.rb
+++ b/test/unit/test_util.rb
@@ -102,4 +102,27 @@ def test_reopen_logs_renamed_with_internal_encoding
     }
     tmp.close!
   end
+
+  def test_pipe
+    r, w = Unicorn.pipe
+    assert r
+    assert w
+
+    return if RUBY_PLATFORM =~ /linux/
+
+    f_getpipe_sz = 1032
+    IO.pipe do |a, b|
+      a_sz = a.fcntl(f_getpipe_sz)
+      b_sz = b.fcntl(f_getpipe_sz)
+      assert_kind_of Integer, a_sz
+      r_sz = r.fcntl(f_getpipe_sz)
+      assert_equal Raindrops::PAGE_SIZE, r_sz
+      assert_operator a_sz, :>=, r_sz
+    end
+  rescue Errno::EINVAL
+    # Linux <= 2.6.34
+  ensure
+    w.close
+    r.close
+  end
 end
-- 
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 --
2018-08-20 20:30  7% [PATCH] shrink pipes under Linux Eric Wong
2018-12-20 22:28  5% [ANN] unicorn 5.5.0.pre1 - Rack HTTP server for fast clients and Unix Eric Wong

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

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