jemalloc_rb 1.0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 27b51252fb78a9f1ea8b24cba7825d695e968aeef30fce411af6a6b50795d510
4
+ data.tar.gz: 3084cb48d774b74091c47604f3d5d4544e589d6a1339d758f8e07e19d071395e
5
+ SHA512:
6
+ metadata.gz: 5cdfd6f78aa4cd5a990373d48a2aebd65cb6dd9525c392dfb71e2da670d467d33e9b525a05457e68a757af68afe228538b57b3dde7199aa1ac8a7079ad0e91df
7
+ data.tar.gz: 7a1816568683398614e3b0adce471bc7a5da96a00f4281bcb10df915ea9a0d9eaf5732bbea617530111fffd78bee5173499610b50d94652a57d0bc546456cb7e
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ *.o
2
+ *.so
3
+ *~
4
+ ext/jemalloc/*.c
5
+ ext/jemalloc/jemalloc-3.0.0/
6
+ ruby/Makefile
7
+ *.5
8
+ *.8
9
+ *.6
10
+ _obj
11
+ _test
data/ChangeLog ADDED
@@ -0,0 +1,2 @@
1
+ Release 1.0.0 - 2026/07/01
2
+ - Updated fork from https://github.com/kzk/jemalloc-rb
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,20 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ jemalloc (1.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ rake (0.9.2.2)
10
+ rake-compiler (0.7.9)
11
+ rake
12
+
13
+ PLATFORMS
14
+ ruby
15
+
16
+ DEPENDENCIES
17
+ bundler (>= 1.0.0)
18
+ jemalloc!
19
+ rake (>= 0.8.7)
20
+ rake-compiler (~> 0.7.1)
data/README.md ADDED
@@ -0,0 +1,42 @@
1
+ *This is a fork of https://github.com/kzk/jemalloc-rb (which appears to no longer be maintained). I created this repository to keep the jemalloc (now jemalloc_rb) gem active and open to pull requests.*
2
+
3
+ # jemalloc_rb
4
+
5
+ Instant [jemalloc](https://jemalloc.net/) injection into Ruby apps, for better performance and less memory.
6
+
7
+ # Why?
8
+
9
+ Ruby relies on malloc(3) for its internal memory allocation. Using better malloc() implementation will boost your application performance, and supress the memory usage.
10
+
11
+ 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.
12
+
13
+ # Why jemalloc_rb?
14
+
15
+ 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 injection in a really easy way: install `jemalloc_rb` gem, and launch your app with `je` command.
16
+
17
+ # Install
18
+
19
+ Install `jemalloc_rb` gem in your application. For [bundler](http://gembundler.com/) based application, please add the following line into your Gemfile, and and install `jemalloc_rb` by `bundle install`.
20
+
21
+ gem 'jemalloc_rb'
22
+
23
+ # Usage
24
+
25
+ Execute your application with `je` command, which is contained in `je` gem. Example command for Rails + bundler application is like follows.
26
+
27
+ $ bundle exec je s
28
+
29
+ `-v` option will let you confirm jemalloc is actually injected.
30
+
31
+ $ bundle exec je -v rails s
32
+ => Injecting jemalloc...
33
+ => Booting WEBrick
34
+ ...
35
+
36
+ # Limitation
37
+
38
+ Currently, this gem works only on Linux and Mac OS X.
39
+
40
+ # License
41
+
42
+ [BSD-derived License](http://www.canonware.com/jemalloc/license.html).
data/Rakefile ADDED
@@ -0,0 +1,17 @@
1
+ # -*- mode: ruby; coding: utf-8 -*-
2
+ require 'rubygems'
3
+ require 'bundler'
4
+
5
+ require 'rake'
6
+ require 'rake/clean'
7
+ require 'rake/testtask'
8
+ require 'rubygems/package_task'
9
+
10
+ Bundler::GemHelper.install_tasks
11
+
12
+ begin
13
+ require 'rake/extensiontask'
14
+ Rake::ExtensionTask.new('jemalloc')
15
+ rescue LoadError
16
+ abort "This Rakefile requires rake-compiler (gem install rake-compiler)"
17
+ end
data/bin/je ADDED
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env ruby
2
+ # Help
3
+ def usage
4
+ puts <<END
5
+ Usage: je [ARGS]...
6
+
7
+ Options:
8
+ -v verbose mode
9
+ --version show version
10
+ END
11
+ exit
12
+ end
13
+
14
+ # Option parsing
15
+ $verbose = false
16
+ argv = ARGV
17
+ usage() if argv.length == 0
18
+ if argv[0] == '-v'
19
+ $verbose = true
20
+ argv = argv[1..-1]
21
+ elsif argv[0] == '--version'
22
+ require 'jemalloc_rb/version'
23
+ puts "jemalloc_rb version #{JEMalloc::VERSION}"
24
+ exit
25
+ end
26
+ usage() if argv.length == 0
27
+
28
+ # Set ENV for preloading jemalloc
29
+ lib_dir = File.expand_path('../lib/', File.dirname(__FILE__))
30
+ if File.exist? (lib_dir + "/jemalloc.so")
31
+ puts "=> Injecting jemalloc..." if $verbose
32
+ ENV.store("LD_PRELOAD", lib_dir + "/jemalloc.so")
33
+ elsif File.exist? (lib_dir + "/jemalloc.bundle")
34
+ puts "=> Injecting jemalloc..." if $verbose
35
+ ENV.store("DYLD_INSERT_LIBRARIES", lib_dir + "/jemalloc.bundle")
36
+ else
37
+ puts "=> Skip injecting jemalloc. Your platform is not supported." if $verbose
38
+ end
39
+
40
+ Kernel.exec *argv
@@ -0,0 +1,61 @@
1
+ require 'mkmf'
2
+ require 'rbconfig'
3
+
4
+ $stdout.sync = true
5
+ pkg = "jemalloc-5.2.1"
6
+
7
+ def sys(cmd)
8
+ puts "$ #{cmd}"
9
+ unless ret = xsystem(cmd)
10
+ raise "system command `#{cmd}' failed, please report to https://github.com/ibc/em-udns/issues"
11
+ end
12
+ ret
13
+ end
14
+
15
+ # monfigure and copy sources to cur_dir
16
+ src_dir = File.expand_path(File.dirname(__FILE__))
17
+ cur_dir = Dir.pwd
18
+ Dir.chdir File.dirname(__FILE__) do
19
+ # cleanup
20
+ FileUtils.remove_dir(pkg, force = true)
21
+
22
+ # decompress and copy source files
23
+ sys "tar vjxf #{pkg}.tar.bz2"
24
+ Dir.chdir(pkg) do
25
+ # configure
26
+ sys "./configure"
27
+ # generates some .h files
28
+ sys "make include/jemalloc/internal/private_namespace.h"
29
+ # zone.c is only for Mac OS X
30
+ if RbConfig::CONFIG['target_vendor'] != "apple"
31
+ sys "rm -fR src/zone.c"
32
+ end
33
+ # mkmf only allows *.c files on current dir
34
+ sys "cp src/*.c #{src_dir}"
35
+ end
36
+ end
37
+ Dir.chdir cur_dir
38
+
39
+ include_dir= File.dirname(__FILE__) + "/#{pkg}/include/"
40
+ $CFLAGS << %[ -std=gnu99 -Wall -pipe -g3 -fvisibility=hidden -O3 -funroll-loops -D_GNU_SOURCE -D_REENTRANT -I.. -I#{include_dir}]
41
+
42
+ create_makefile('jemalloc')
43
+
44
+ # Modify Makefile to create .dylib, instead of .bundle. Because extconf.rb
45
+ # generates .bundle by default, but .bundle cannot be dynamically loaded by
46
+ # LD_PRELOAD.
47
+ # NOTICE: Mac OS X only
48
+ if RbConfig::CONFIG['target_vendor'] == "apple"
49
+ makefile = open('Makefile').read
50
+ # for 1.9.2 and 1.9.3
51
+ if makefile =~ /-dynamic\ -bundle/ && makefile =~ /-flat_namespace/
52
+ makefile.gsub!(/-dynamic\ -bundle/, '-shared')
53
+ makefile.gsub!(/-flat_namespace/, '-dylib_install_name')
54
+ # for 2.0.0
55
+ elsif makefile =~ /-dynamic\ -bundle/
56
+ makefile.gsub!(/-dynamic\ -bundle/, '-shared')
57
+ else
58
+ raise 'Your platform is not supported. Please report to http://github.com/treasure-data/jemalloc-rb'
59
+ end
60
+ open('Makefile', 'w'){ |f| f.write(makefile) }
61
+ end
Binary file
@@ -0,0 +1,23 @@
1
+ # -*- mode: ruby; coding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require 'jemalloc_rb/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "jemalloc_rb"
7
+ s.version = JemallocRb::VERSION
8
+ s.summary = "Use jemalloc as default allocator, everywhere!"
9
+ s.description = %q{Use jemalloc as default allocator, everywhere!}
10
+ s.author = "Henrique F. Teixeira"
11
+ s.email = "hrique.work@gmail.com"
12
+ s.homepage = "https://github.com/henrique-ft/jemalloc_rb"
13
+ s.extensions = ["ext/jemalloc/extconf.rb"]
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.require_paths = ["lib"]
19
+
20
+ s.add_development_dependency 'bundler', ['>= 1.0.0']
21
+ s.add_development_dependency 'rake', ['>= 0.8.7']
22
+ s.add_development_dependency 'rake-compiler', ['~> 0.7.1']
23
+ end
@@ -0,0 +1,3 @@
1
+ module JemallocRb
2
+ VERSION = "1.0.0"
3
+ end
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jemalloc_rb
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Henrique F. Teixeira
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: bundler
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: 1.0.0
19
+ type: :development
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: 1.0.0
26
+ - !ruby/object:Gem::Dependency
27
+ name: rake
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.8.7
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: 0.8.7
40
+ - !ruby/object:Gem::Dependency
41
+ name: rake-compiler
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: 0.7.1
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: 0.7.1
54
+ description: Use jemalloc as default allocator, everywhere!
55
+ email: hrique.work@gmail.com
56
+ executables:
57
+ - je
58
+ extensions:
59
+ - ext/jemalloc/extconf.rb
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ChangeLog
64
+ - Gemfile
65
+ - Gemfile.lock
66
+ - README.md
67
+ - Rakefile
68
+ - bin/je
69
+ - ext/jemalloc/extconf.rb
70
+ - ext/jemalloc/jemalloc-5.2.1.tar.bz2
71
+ - jemalloc_rb.gemspec
72
+ - lib/jemalloc_rb/version.rb
73
+ homepage: https://github.com/henrique-ft/jemalloc_rb
74
+ licenses: []
75
+ metadata: {}
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubygems_version: 4.0.6
91
+ specification_version: 4
92
+ summary: Use jemalloc as default allocator, everywhere!
93
+ test_files: []