Skip to content

Instantly share code, notes, and snippets.

@xaviershay
Created May 1, 2011 01:00
Show Gist options
  • Save xaviershay/950154 to your computer and use it in GitHub Desktop.
Save xaviershay/950154 to your computer and use it in GitHub Desktop.
This drastically speeds up require time on ruby 1.9 (17s down to 10s in our production rails app) , at the expense of disabling some edge case handling around autoloading. YMMV but it works for our rails app.
From 2fb8432982b7e8ffc4c05f912f47cd9ca7261427 Mon Sep 17 00:00:00 2001
From: Xavier Shay <[email protected]>
Date: Sun, 1 May 2011 10:25:18 +1000
Subject: [PATCH] Disable some edge cases in requiring to speed it up.
---
load.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/load.c b/load.c
index f8f0551..a14cc93 100644
--- a/load.c
+++ b/load.c
@@ -152,6 +152,7 @@ rb_feature_p(const char *feature, const char *ext, int rb, int expanded, const c
f = StringValuePtr(v);
if ((n = RSTRING_LEN(v)) < len) continue;
if (strncmp(f, feature, len) != 0) {
+ continue; // Pretty sure we don't need the behaviour below this line
if (expanded) continue;
if (!load_path) load_path = rb_get_expanded_load_path();
if (!(p = loaded_feature_path(f, n, feature, len, type, load_path)))
--
1.7.3.1
@fcheung
Copy link

fcheung commented May 13, 2011

I get similar sorts of performance gains too. Awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment