Project

General

Profile

Actions

Feature #12639

open

Speed up require in RubyGems by 5x

Added by segiddins (Samuel Giddins) over 7 years ago. Updated over 5 years ago.

Status:
Assigned
Target version:
-
[ruby-core:76625]

Description

This patch makes requiring an already-loaded file approximated 5x faster when the RubyGems mixin for require is present.
Benchmarked via the following script:

require "rubygems"
require "benchmark/ips"

Benchmark.ips do |x|
	x.report("ruby") { gem_original_require "rubygems" }
	x.report("rubygems") { require "rubygems" }
	
	x.compare!
end

I understand that it's not ideal to add new global functions, and I'd appreciate guidance on where else I could expose this functionality to ruby code.

Thanks :)


Files

feature_loaded.patch (1.85 KB) feature_loaded.patch segiddins (Samuel Giddins), 07/31/2016 01:04 AM

Updated by nobu (Nobuyoshi Nakada) over 7 years ago

I'm not sure if it is acceptable for rubygems to skip loaded features.

+VALUE
+rb_f_loaded_feature(VALUE obj, VALUE fname)
+{
+  return rb_provided(RSTRING_PTR(rb_str_encode_ospath(fname))) ? Qtrue : Qfalse;
+}

Why is this function global?
And the argument of RSTRING_PTR should not have side effects.

Updated by hsbt (Hiroshi SHIBATA) over 5 years ago

  • Status changed from Open to Assigned
  • Assignee set to hsbt (Hiroshi SHIBATA)
Actions

Also available in: Atom PDF

Like0
Like0Like0