Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
Release x.x.x - 2020/04/03
- jemalloc v5.2.1

Release x.x.x - 2016/08/18
- jemalloc v4.2.1

Release x.x.x - 2015/12/03
- jemalloc v4.0.4

Release 1.0.1 - 2015/01/15
- just exec without spawn

Expand Down
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
source 'https://rubygems.org'
gemspec

gemspec
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 GarazLab https://garazlab.com

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,24 @@

Instant [jemalloc](http://www.canonware.com/jemalloc/) injection into Ruby apps, for better performance and less memory.

# Example

[GarazLab](https://garazlab.com) uses this gem with its below rails applications for its internal memory allocation:
1. [Ruby on Rails Page Builder](https://garazlab.com/product/ruby-on-rails-page-builder)

# Why jemalloc?

Ruby relies on malloc(3) for its internal memory allocation. Using better malloc() implementation will boost your application performance, and supress the memory usage.
Ruby relies on malloc(3) for its internal memory allocation. Using a better malloc() implementation will boost your application's performance, and reduce it's memory usage.

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.
jemalloc is a malloc(3) implementation, originally developed by Jason Evans. jemalloc handles small objects better than other allocators, so it usually gives better performance and memory usage to Ruby programs.

# Why jemalloc?

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 `je` gem, and launch your app with `je` command.

# Install

Install `jemalloc` gem in your application. For [bundler](http://gembundler.com/) based application, please add the following line into your Gemfile, and and install `jemalloc` by `bundle install`.
Install `jemalloc` gem in your application. For [bundler](http://gembundler.com/) based applications, please add the following line into your Gemfile, and and install `jemalloc` by `bundle install`.

gem 'jemalloc'

Expand All @@ -31,6 +36,14 @@ Execute your application with `je` command, which is contained in `je` gem. Exam
=> Booting WEBrick
...

# Advanced: Valgrind

Jemalloc is built to use [Valgrind](http://valgrind.org/) by default. As Valgrind is not installed on Mac systems or on Heroku, this gem disables Valgrind by using `--disable-valgrind` during the configure process.

You can enable Valgrind by specifying: `bundle config build.jemalloc --with-valgrind` before installing jemalloc-rb using Bundler.

Please note, if you want to enable Valgrind for all projects which use Bundler, you need to use the `--global` flag, e.g. `bundle config --global build.jemalloc --with-valgrind`

# Limitation

Currently, this gem works only on Linux and Mac OS X.
Expand Down
16 changes: 13 additions & 3 deletions ext/jemalloc/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require 'rbconfig'

$stdout.sync = true
pkg = "jemalloc-3.4.0"
pkg = "jemalloc-5.2.1"

def sys(cmd)
puts "$ #{cmd}"
Expand All @@ -12,22 +12,32 @@ def sys(cmd)
ret
end

# grab config options
config_options = []
config_options << '--disable-valgrind' unless (with_config('valgrind') == false)

# monfigure and copy sources to cur_dir
src_dir = File.expand_path(File.dirname(__FILE__))
cur_dir = Dir.pwd
Dir.chdir File.dirname(__FILE__) do
# cleanup
FileUtils.remove_dir(pkg, force = true)
FileUtils.remove_dir(pkg, true)

# decompress and copy source files
sys "tar vjxf #{pkg}.tar.bz2"
Dir.chdir(pkg) do
# configure
sys "./configure"
sys "./configure #{ config_options.join(' ') }"
# zone.c is only for Mac OS X
if RbConfig::CONFIG['target_vendor'] != "apple"
sys "rm -fR src/zone.c"
end
# if we don't remove this explicitly, mkmf will try to include it
# and that causes issues when '--disable-valgrind' is used
# le sigh
unless with_config('valgrind') == false
sys "rm -fR src/valgrind.c"
end
# mkmf only allows *.c files on current dir
sys "cp src/*.c #{src_dir}"
end
Expand Down
Binary file removed ext/jemalloc/jemalloc-3.4.0.tar.bz2
Binary file not shown.
Binary file added ext/jemalloc/jemalloc-5.2.1.tar.bz2
Binary file not shown.
2 changes: 1 addition & 1 deletion lib/jemalloc/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module JEMalloc
VERSION = "1.0.1"
VERSION = "1.5.2"
end