je 0.0.6 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +1 -1
- data/README.md +15 -6
- data/bin/je +19 -4
- data/ext/jemalloc/extconf.rb +6 -3
- data/lib/je/version.rb +1 -1
- metadata +9 -4
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,16 @@
|
|
1
|
-
# je
|
1
|
+
# je
|
2
2
|
|
3
|
-
jemalloc
|
3
|
+
Instant [jemalloc](http://www.canonware.com/jemalloc/) injection into Ruby apps, for better performance and less memory.
|
4
|
+
|
5
|
+
# Why jemalloc?
|
6
|
+
|
7
|
+
Ruby relies on malloc(3) for its internal memory allocation. Using better malloc() implementation will boost your application performance, and supress the memory usage.
|
8
|
+
|
9
|
+
jemalloc is a malloc(3) implementation, originally developed by Jason Evans. jemalloc handles small object better than other allocators so usually gives better performance and memory usage to Ruby programs.
|
10
|
+
|
11
|
+
# Why je?
|
12
|
+
|
13
|
+
Installing jemalloc separately from Ruby is pain in some cases (e.g. Heroku, EngineYard, etc). `je` gem contains jemalloc itself within a gem, and enables instant jemalloc ingection in a really easy way: install `je` gem, and launch your app with `je` command.
|
4
14
|
|
5
15
|
# Install
|
6
16
|
|
@@ -12,13 +22,12 @@ Install `je` gem in your application. For [bundler](http://gembundler.com/) base
|
|
12
22
|
|
13
23
|
Execute your application with `je` command, which is contained in `je` gem. Example command for Rails + bundler application is like follows.
|
14
24
|
|
15
|
-
|
16
25
|
$ bundle exec je ./script/rails s
|
17
26
|
|
18
|
-
#
|
27
|
+
# Limitation
|
19
28
|
|
20
|
-
Currently, this gem works only on Linux
|
29
|
+
Currently, this gem works only on Linux and Mac OS X.
|
21
30
|
|
22
31
|
# License
|
23
32
|
|
24
|
-
[BSD-derived License](http://www.canonware.com/jemalloc/license.html).
|
33
|
+
[BSD-derived License](http://www.canonware.com/jemalloc/license.html).
|
data/bin/je
CHANGED
@@ -1,16 +1,31 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
require 'optparse'
|
2
3
|
require 'timeout'
|
3
4
|
|
5
|
+
$verbose = false
|
6
|
+
opt = OptionParser.new
|
7
|
+
opt.on('-v') { |v| $verbose = true }
|
8
|
+
argv = opt.parse(ARGV)
|
9
|
+
if argv.length == 0
|
10
|
+
puts <<END
|
11
|
+
Usage: je [ARGS]...
|
12
|
+
|
13
|
+
Options:
|
14
|
+
-v verbose
|
15
|
+
END
|
16
|
+
exit
|
17
|
+
end
|
18
|
+
|
4
19
|
# Set ENV for preloading jemalloc
|
5
20
|
lib_dir = File.expand_path('../lib/', File.dirname(__FILE__))
|
6
21
|
if File.exists? (lib_dir + "/jemalloc.so")
|
7
|
-
puts "=> Injecting jemalloc..."
|
22
|
+
puts "=> Injecting jemalloc..." if $verbose
|
8
23
|
ENV.store("LD_PRELOAD", lib_dir + "/jemalloc.so")
|
9
24
|
elsif File.exists? (lib_dir + "/jemalloc.bundle")
|
10
|
-
puts "=> Injecting jemalloc..."
|
25
|
+
puts "=> Injecting jemalloc..." if $verbose
|
11
26
|
ENV.store("DYLD_INSERT_LIBRARIES", lib_dir + "/jemalloc.bundle")
|
12
27
|
else
|
13
|
-
puts "=> Skip injecting jemalloc. Your platform is not supported."
|
28
|
+
puts "=> Skip injecting jemalloc. Your platform is not supported." if $verbose
|
14
29
|
end
|
15
30
|
|
16
31
|
# fork(2)
|
@@ -33,7 +48,7 @@ trap("TERM") { puts "SIGTERM received"; terminate_gracefully pid }
|
|
33
48
|
|
34
49
|
# exec(2)
|
35
50
|
if pid.nil? then
|
36
|
-
Kernel.exec *
|
51
|
+
Kernel.exec *argv
|
37
52
|
else
|
38
53
|
pid, status = Process.wait2
|
39
54
|
Kernel.exit (status.exitstatus || 0)
|
data/ext/jemalloc/extconf.rb
CHANGED
@@ -32,8 +32,11 @@ create_makefile('jemalloc')
|
|
32
32
|
# NOTICE: Mac OS X only
|
33
33
|
if RbConfig::CONFIG['target_vendor'] == "apple"
|
34
34
|
makefile = open('Makefile').read
|
35
|
-
makefile
|
36
|
-
|
37
|
-
|
35
|
+
if makefile =~ /-dynamic\ -bundle/ && makefile =~ /-flat_namespace/
|
36
|
+
makefile.gsub!(/-dynamic\ -bundle/, '-shared')
|
37
|
+
makefile.gsub!(/-flat_namespace/, '-dylib_install_name')
|
38
|
+
else
|
39
|
+
raise 'Your platform is not supported. Please report to http://github.com/treasure-data/je'
|
40
|
+
end
|
38
41
|
open('Makefile', 'w'){ |f| f.write(makefile) }
|
39
42
|
end
|
data/lib/je/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: je
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-09-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -89,17 +89,22 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
89
89
|
- - ! '>='
|
90
90
|
- !ruby/object:Gem::Version
|
91
91
|
version: '0'
|
92
|
+
segments:
|
93
|
+
- 0
|
94
|
+
hash: -3111438065534866000
|
92
95
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
96
|
none: false
|
94
97
|
requirements:
|
95
98
|
- - ! '>='
|
96
99
|
- !ruby/object:Gem::Version
|
97
100
|
version: '0'
|
101
|
+
segments:
|
102
|
+
- 0
|
103
|
+
hash: -3111438065534866000
|
98
104
|
requirements: []
|
99
105
|
rubyforge_project:
|
100
|
-
rubygems_version: 1.8.
|
106
|
+
rubygems_version: 1.8.24
|
101
107
|
signing_key:
|
102
108
|
specification_version: 3
|
103
109
|
summary: use jemalloc as default allocator, everywhere!
|
104
110
|
test_files: []
|
105
|
-
has_rdoc:
|