Skip to content

Commit

Permalink
add jemalloc support (#65)
Browse files Browse the repository at this point in the history
jemalloc is often a more optimal memory allocator for Ruby workloads.
  • Loading branch information
bobvanderlinden authored Jan 18, 2024
2 parents 1a4b005 + d4ef930 commit 5c55e64
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 9 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,14 @@
ruby -e 'puts "ok"' > $out
'';
};
"${rubyName}-jemalloc" = {
nativeBuildInputs = [
(ruby.override { jemallocSupport = true; })
];
command = ''
ruby -e 'puts "ok"' > $out
'';
};
"${rubyName}-mkRuby" = {
nativeBuildInputs = [
(self.lib.mkRuby {
Expand Down Expand Up @@ -197,7 +205,7 @@
ruby -e 'puts RUBY_VERSION' > $out
'';
};
packageFromRubyVersionFileWithEngine =
packageFromRubyVersionFileWithEngine =
let
ruby = self.lib.packageFromRubyVersionFile {
file = ./tests/ruby-version-with-engine;
Expand Down
4 changes: 4 additions & 0 deletions ruby/package-fn.nix
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
, fiddleSupport ? true
, yjitSupport ? true
, rustc
, jemallocSupport ? false
, jemalloc
}:
let
op = lib.optional;
Expand Down Expand Up @@ -75,6 +77,7 @@ let
++ (op gdbmSupport gdbm)
++ (op yamlSupport libyaml)
++ (op yjitSupport rustc)
++ (op jemallocSupport jemalloc)
# Looks like ruby fails to build on darwin without readline even if curses
# support is not enabled, so add readline to the build inputs if curses
# support is disabled (if it's enabled, we already have it) and we're
Expand Down Expand Up @@ -109,6 +112,7 @@ let
configureFlags =
[ "--enable-shared" "--enable-pthread" ]
++ op (!docSupport) "--disable-install-doc"
++ op jemallocSupport "--with-jemalloc"
++ ops stdenv.isDarwin [
# on darwin, we have /usr/include/tk.h -- so the configure script detects
# that tk is installed
Expand Down

0 comments on commit 5c55e64

Please sign in to comment.