angussidney / mmtk-ruby

A Ruby binding for MMTk (the Memory Management Toolkit). This allows high-perfomance research garbage collectors to be used instead of the standard MRI GC.
Other
3 stars 0 forks source link
garbage-collection mmtk ruby

MMTk binding for Ruby

This repository hosts the binding code for MMTk Ruby.

In order for this binding to work, changes have been made to the Ruby core language to support generic third party heaps. Eventually, the aim is to upstream these changes. Until then, the modifications can be found under my fork here, on the branch third-party-heap-2-7-2. An overview of the changes can be viewed using this diff.

Installation/build instructions

To build a copy of MMTk Ruby:

# Clone sources
git clone https://github.com/angussidney/mmtk-ruby.git
cd mmtk-ruby
git checkout 88dd50bc # Latest stable version of the binding
mkdir repos && cd repos
git clone https://github.com/angussidney/ruby.git
cd ../mmtk

# Build MMTk. Optionally edit Cargo.toml to use a local working copy
# of mmtk-core rather than a fresh cloned copy
export RUSTUP_TOOLCHAIN=nightly-2020-07-08
# Add --release to include optimisations. Highly recommended when
# not debugging (yields a huge performance increase)
cargo build --features nogc
cp target/debug/libmmtk_ruby.* ../repos/ruby/

# Build Ruby with MMTk enabled
cd ../repos/ruby
export LD_LIBRARY_PATH=$PWD
autoconf
# -O0/-ggdb3 flags are used for debugging, remove for release
# Note: you will need to have a BASERUBY installed to run this command
CFLAGS="-O0 -ggdb3 -DUSE_THIRD_PARTY_HEAP -DUSE_TRANSIENT_HEAP=0" ./configure prefix="$PWD/build"
# Note: this option is currently broken and allows unbounded heap sizes (bug in mmtk-core, #214)
export THIRD_PARTY_HEAP_LIMIT=4000000
make install -j
export PATH=$PWD/build/bin:$PATH

# Time to test!
echo "puts 'Hello, World'" > test.rb
ruby test.rb

To test Ruby, it is recommended that you add the ADDITIONAL_EXCLUDES option to exclude tests which make assumptions based on Ruby's current GC implementation, or are extremely memory intensive.

make test-all ADDITIONAL_EXCLUDES="--excludes-dir=./test/excludes/_third_party_heap"

Build with Vagrant

A Vagrant config for building on platforms other than Linux can be found here: https://github.com/chrisseaton/mmtk-ruby-macos

Current status

Known working:

Known issues:

TODO

Licensing

This work is dual-licensed under the MIT and Apache licenses, to be compatible with the MMTk-Core project. See the license notices in the root of this repository for further details.