From: Eric Wong <e@80x24.org>
To: spew@80x24.org
Subject: [PATCH] net/http: use require_relative to reduce syscalls
Date: Wed, 23 Nov 2016 22:45:31 +0000 [thread overview]
Message-ID: <20161123224531.6058-1-e@80x24.org> (raw)
require_relative speeds up loading of files by reducing path
lookups. On a clean install with RubyGems-enabled,
"ruby -rnet/http -e exit" shows a reduction in failed open(2)
syscalls from 410 to 350 (x86-64 GNU/Linux).
I could not measure a time difference on my Linux-based
machines, however this should be noticeable to users of other
kernels with worse syscall and VFS performance than Linux.
Further use of require_relative will reduce lookups in other
places.
---
lib/net/http.rb | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/lib/net/http.rb b/lib/net/http.rb
index 5a22fc0..55d9ba2 100644
--- a/lib/net/http.rb
+++ b/lib/net/http.rb
@@ -20,7 +20,7 @@
# See Net::HTTP for an overview and examples.
#
-require 'net/protocol'
+require_relative 'protocol'
require 'uri'
module Net #:nodoc:
@@ -1580,17 +1580,17 @@ def D(msg)
end
-require 'net/http/exceptions'
+require_relative 'http/exceptions'
-require 'net/http/header'
+require_relative 'http/header'
-require 'net/http/generic_request'
-require 'net/http/request'
-require 'net/http/requests'
+require_relative 'http/generic_request'
+require_relative 'http/request'
+require_relative 'http/requests'
-require 'net/http/response'
-require 'net/http/responses'
+require_relative 'http/response'
+require_relative 'http/responses'
-require 'net/http/proxy_delta'
+require_relative 'http/proxy_delta'
-require 'net/http/backward'
+require_relative 'http/backward'
--
EW
reply other threads:[~2016-11-23 22:45 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:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161123224531.6058-1-e@80x24.org \
--to=e@80x24.org \
--cc=spew@80x24.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* 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.
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).