dumping ground for random patches and texts
 help / color / mirror / Atom feed
* [PATCH] net/http: use require_relative to reduce syscalls
@ 2016-11-23 22:45 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2016-11-23 22:45 UTC (permalink / raw)
  To: spew

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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-11-23 22:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-23 22:45 [PATCH] net/http: use require_relative to reduce syscalls Eric Wong

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