diff --git a/ChangeLog b/ChangeLog index 7768913..78ec5ea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/Gemfile b/Gemfile index 851fabc..cd8aa9e 100644 --- a/Gemfile +++ b/Gemfile @@ -1,2 +1,3 @@ source 'https://rubygems.org' -gemspec + +gemspec \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..6e2729b --- /dev/null +++ b/LICENSE @@ -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. diff --git a/README.md b/README.md index 156c6f9..71b98ad 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,16 @@ 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? @@ -14,7 +19,7 @@ Installing jemalloc separately from Ruby is pain in some cases (e.g. Heroku, Eng # 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' @@ -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. diff --git a/ext/jemalloc/extconf.rb b/ext/jemalloc/extconf.rb index 010da49..6a04e11 100644 --- a/ext/jemalloc/extconf.rb +++ b/ext/jemalloc/extconf.rb @@ -2,7 +2,7 @@ require 'rbconfig' $stdout.sync = true -pkg = "jemalloc-3.4.0" +pkg = "jemalloc-5.2.1" def sys(cmd) puts "$ #{cmd}" @@ -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 diff --git a/ext/jemalloc/jemalloc-3.4.0.tar.bz2 b/ext/jemalloc/jemalloc-3.4.0.tar.bz2 deleted file mode 100644 index 7ee12e7..0000000 Binary files a/ext/jemalloc/jemalloc-3.4.0.tar.bz2 and /dev/null differ diff --git a/ext/jemalloc/jemalloc-5.2.1.tar.bz2 b/ext/jemalloc/jemalloc-5.2.1.tar.bz2 new file mode 100644 index 0000000..75baa3f Binary files /dev/null and b/ext/jemalloc/jemalloc-5.2.1.tar.bz2 differ diff --git a/lib/jemalloc/version.rb b/lib/jemalloc/version.rb index 0a33c05..69a53e7 100644 --- a/lib/jemalloc/version.rb +++ b/lib/jemalloc/version.rb @@ -1,3 +1,3 @@ module JEMalloc - VERSION = "1.0.1" + VERSION = "1.5.2" end