Patches: Browse | Submit New | Admin

[#21979] MiniGems - a lightweight drop-in-replacement for Gem loading

Date:
2008-09-16 10:01
Priority:
3
Submitted By:
Fabien Franzen (loobmedia)
Assigned To:
Eric Hodel (drbrain)
Category:
#gem and #require methods
State:
Closed
Summary:
MiniGems - a lightweight drop-in-replacement for Gem loading

Detailed description
The standard RubyGems loading mechanism keeps a cache (now called source_index) of all the gems and the files they include.
This not only takes quite some time when starting a ruby script or application, more importantly the memory consumption
grows with each gem that's installed on your system.

Minigems handles loading of required gems from your scripts. If however, other functionality is needed, the full rubygems
library will be loaded automatically to continue normal operation. In many respects it's similar to gem_prelude, but
it's more tightly integrated into Rubygems itself:

When installing a gem you can use the -m switch to create a minigems based wrapper, instead of the standard rubygems
based version. This is essential to work with minigems, as it makes sure that rubygems (full) hasn't been loaded at
all, making way for minigems to mimic the basic loading functionality: install gem foo -m

Additionally, a gem developer can enable the installation of a minigems wrapper by default by adding the line: s.minigems
= true to the gemspec definition. Should the end-user choose to use plain rubygems instead, the install option --no-minigems
can be used.

To remove any code duplication, common methods (for both the minigems as well as the rubygems version of the Gem module)
have been extracted into rubygems/core. It's shared between both implementations.

To fall back to a full rubygems system, method_missing will catch any method that's actually implemented by the full
rubygems. The same is true for any missing constants. At install time there's a list of Gem module methods that's get
pregenerated and added to minigems.rb, thus keeping current with the actual code itself.

Regarding unit tests, all tests pass when the 'require "rubygems"' line in gemutilities.rb is switched to
use 'minigems' instead. Off coarse, with plain 'rubygems' all tests are fine as well.


Add A Comment: Notepad

Please login


Followup

Message
Date: 2009-07-29 22:59
Sender: John Barnette

Closed based on Yehuda's comment.
Date: 2009-07-27 23:45
Sender: Yehuda Katz

This is obviated by a number of performance improving patches
that are on the way. It can be closed.
Date: 2009-05-22 21:22
Sender: Roger Pack

+1 or maybe gem_prelude is good enough :)
Date: 2008-12-20 14:48
Sender: Aslak Hellesøy

+1
Date: 2008-12-07 08:41
Sender: dkubb Kubb

+1
Date: 2008-11-29 21:46
Sender: Roman Semenenko

+1 for this
Date: 2008-11-06 21:31
Sender: Ryan Tomayko

+1
Date: 2008-11-04 17:33
Sender: Jack Dempsey

+1
Date: 2008-10-12 06:30
Sender: Alexey Kovyrin

+1 on this patch
Date: 2008-09-16 14:04
Sender: Emil Ivanov

+1 for inclusion.
Date: 2008-09-16 12:49
Sender: Abdul-Rahman Advany

+1 for including in rubygems :)
Date: 2008-09-16 10:04
Sender: Yehuda Katz

Eric: This is the patch I've been telling you about. I'd love
to get this in to the next release of Rubygems :)

Attached Files:

Name Description Download
minigems.diff Complete minigems diff Download
minigems-r1881.diff Patch against r1881 Download

Changes:

Field Old Value Date By
status_idOpen2009-07-29 22:59jbarnette
close_date2009-07-29 22:592009-07-29 22:59jbarnette
File Added4041: minigems-r1881.diff2008-09-19 13:55loobmedia
assigned_tonone2008-09-16 10:04loobmedia
File Added4037: minigems.diff2008-09-16 10:01loobmedia