sstephenson/rbenv — pull request #528 by mislav (2014-01-06 02:45:26+00:00)
Title: Speed up rbenv by dynamically loading compiled command

The most time spent in rbenv execution is resolving paths to their absolute representations without symlinks. Manually doing this in bash is slow.

# rbenv overhead of running `ruby -e0`:
[system]
mean: 0.120
stdev: 0.008
[1.9.3-p194]
mean: 0.092
stdev: 0.003

By dynamically loading a compiled bash builtin, we can access the `realpath` POSIX C function which does exactly what we need and is fast.

# rbenv overhead with speed improvement:
[system]
mean: 0.086
stdev: 0.004
[1.9.3-p194]
mean: 0.057
stdev: 0.003

If dynamic loading fails, rbenv will still continue working as before (will fall back to shell implementation).

If RBENV_NATIVE_EXT environment variable is set, rbenv will abort if it didn't manage to load the builtin. This is primarily useful for testing.

Tested on OS X 10.9 and Ubuntu 12.

/cc @sstephenson