unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: unicorn-public@bogomips.org
Subject: [PATCH] use require_relative to reduce syscalls at startup
Date: Thu,  5 Feb 2015 18:01:24 +0000	[thread overview]
Message-ID: <1423159284-31112-3-git-send-email-e@80x24.org> (raw)

require_relative appeared in Ruby 1.9.2 to speed up load times by
avoiding needless open() syscalls.  This has no effect if you're using
RUBYLIB or the '-I' option when running ruby(1), but avoids searching
paths in other gems.

This does not affect unicorn greatly as unicorn does not activate many
gems, but still leads to reducing ~45 syscalls during startup.
 lib/unicorn.rb       | 16 +++++-----------
 lib/unicorn/const.rb |  2 +-
 2 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/lib/unicorn.rb b/lib/unicorn.rb
index cfa1656..dd02761 100644
--- a/lib/unicorn.rb
+++ b/lib/unicorn.rb
@@ -104,14 +104,8 @@ module Unicorn
   # :startdoc:
 # :enddoc:
-require 'unicorn/const'
-require 'unicorn/socket_helper'
-require 'unicorn/stream_input'
-require 'unicorn/tee_input'
-require 'unicorn/http_request'
-require 'unicorn/configurator'
-require 'unicorn/tmpio'
-require 'unicorn/util'
-require 'unicorn/http_response'
-require 'unicorn/worker'
-require 'unicorn/http_server'
+%w(const socket_helper stream_input tee_input http_request configurator
+   tmpio util http_response worker http_server).each do |s|
+  require_relative "unicorn/#{s}"
diff --git a/lib/unicorn/const.rb b/lib/unicorn/const.rb
index 51d7394..26fa62b 100644
--- a/lib/unicorn/const.rb
+++ b/lib/unicorn/const.rb
@@ -41,4 +41,4 @@ module Unicorn::Const
   # :startdoc:
-require 'unicorn/version'
+require_relative 'version'

                 reply	other threads:[~2015-02-05 18:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: https://yhbt.net/unicorn/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1423159284-31112-3-git-send-email-e@80x24.org \
    --to=e@80x24.org \
    --cc=unicorn-public@bogomips.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox


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).