Giter Site home page Giter Site logo

oracle / truffleruby Goto Github PK

View Code? Open in Web Editor NEW
3.0K 76.0 178.0 291.39 MB

A high performance implementation of the Ruby programming language, built on GraalVM.

Home Page: https://www.graalvm.org/ruby/

License: Other

Ruby 62.87% Java 13.11% Yacc 1.67% C 20.18% Shell 0.07% Jsonnet 0.12% Makefile 0.02% C++ 0.13% Liquid 0.15% HTML 1.33% CSS 0.04% JavaScript 0.03% Batchfile 0.01% Roff 0.26% Rust 0.01%
graalvm ruby truffle hacktoberfest

truffleruby's Introduction

TruffleRuby logo

TruffleRuby is the GraalVM high-performance implementation of the Ruby programming language.

Getting Started

TruffleRuby comes in two distributions:

  • Native Standalone: This only contains TruffleRuby in the Native configuration.
  • JVM Standalone: This only contains TruffleRuby in the JVM configuration. This includes support for other languages such as Java, JavaScript, Python and WebAssembly.

You can install either of those:

  • Via your Ruby manager/installer (RVM, rbenv, chruby, asdf, ruby-build, ruby-install).
    We recommend trying TruffleRuby dev builds which contain the latest fixes and improvements (replace VERSION by dev).

Native Standalone:

RVM:    $ rvm install truffleruby # or truffleruby-head
rbenv:  $ rbenv install truffleruby-VERSION
asdf:   $ asdf install ruby truffleruby-VERSION
chruby: $ ruby-install truffleruby
        $ ruby-build truffleruby-VERSION ~/.rubies/truffleruby-VERSION

JVM Standalone:

rbenv:  $ rbenv install truffleruby+graalvm-VERSION
asdf:   $ asdf install ruby truffleruby+graalvm-VERSION
chruby: $ ruby-install truffleruby-graalvm
        $ ruby-build truffleruby+graalvm-VERSION ~/.rubies/truffleruby+graalvm-VERSION
- uses: ruby/setup-ruby@v1
  with:
    ruby-version: truffleruby # or truffleruby-head or truffleruby+graalvm or truffleruby+graalvm-head

You can use gem and bundle to install gems, as usual.

Please report any issues you might find on GitHub.

Aim

TruffleRuby aims to:

  • Run idiomatic Ruby code faster.
  • Run Ruby code in parallel.
    • TruffleRuby does not have a global interpreter lock and runs Ruby code in parallel.
  • Support C extensions.
    • Many C extensions work out of the box, including database drivers.
  • Add fast and low-overhead interoperability with languages like Java, JavaScript, Python and WebAssembly.
  • Provide new tooling, such as debuggers and monitoring, that works across languages.
  • Provide all of the above while maintaining very high compatibility with the standard implementation of Ruby.

TruffleRuby Runtime Configurations

There are two main runtime configurations of TruffleRuby, Native and JVM, which have different trade-offs.

Configuration: Native (--native, default) JVM (--jvm)
Time to start TruffleRuby about as fast as MRI startup slower
Time to reach peak performance faster slower
Peak performance (also considering GC) good best
Java host interoperability needs reflection configuration just works

To find out which runtime configuration is being used, run ruby --version on the command line, or check the value of RUBY_DESCRIPTION or TruffleRuby.native? in Ruby code. Runtime configurations are further detailed in Deploying TruffleRuby.

System Compatibility

TruffleRuby is actively tested on the following systems:

  • Oracle Linux 7, 8, 9
  • Ubuntu 18.04, 20.04, 22.04 (all LTS)
  • Fedora 37, 38
  • Debian 10, 11, 12
  • macOS 11 (Big Sur)

Architectures:

  • AMD64 (aka x86_64): Supported
  • AArch64 (aka arm64): Supported on Linux (from 21.2) and on macOS (from 22.2)

You may find that TruffleRuby will not work if you severely restrict the environment, for example, by unmounting system filesystems such as /dev/shm.

Dependencies

Without these dependencies, many libraries including RubyGems will not work. TruffleRuby will try to print a nice error message if a dependency is missing, but this can only be done on a best effort basis.

You also need to set up a UTF-8 locale if not already done.

See the contributor workflow document if you wish to build TruffleRuby from source.

Current Status

We recommend that people trying TruffleRuby on their gems and applications get in touch with us for any help they might need.

TruffleRuby runs Rails and is compatible with many gems, including C extensions. TruffleRuby is not 100% compatible with MRI 3.2 yet. Please report any compatibility issues you might find. TruffleRuby passes around 97% of ruby/spec, more than any other alternative Ruby implementation.

Regarding performance, TruffleRuby is by far the fastest Ruby implementation on the yjit-bench benchmark suite which includes railsbench, etc. To achieve this performance TruffleRuby needs a fair amount of warmup, as other advanced JIT compilers do. If you find any performance issue, please see this guide.

Releases

TruffleRuby is released at the same time as GraalVM. TruffleRuby continues to use the release numbering based on the calendar year, for example, 21.x, and 22.x., same as GraalVM prior to 2023. See the release roadmap and the upcoming releases list for the release dates and information about how long releases are supported. GraalVM Community Edition releases are supported at most one year. Longer support is available for Oracle GraalVM.

Migration from MRI

TruffleRuby should in most cases work as a drop-in replacement for MRI, but you should read about our compatibility.

Migration from JRuby

For many use cases TruffleRuby should work as a drop-in replacement for JRuby. However, our approach to integration with Java is different to JRuby so you should read our migration guide.

Documentation

Extensive user documentation is available in doc/user.

See our source code repository and contributor documentation to contribute to TruffleRuby. In particular, see the contributor workflow document for how to build and run TruffleRuby.

Contact

The best way to get in touch with us is to join the #truffleruby channel on GraalVM Slack. You can also Tweet to @TruffleRuby, or email [email protected].

Please report security vulnerabilities via the process outlined in the reporting vulnerabilities guide, rather than by something public such as a GitHub issue or a Gitter conversation.

Mailing List

Announcements about GraalVM, including TruffleRuby, are made on the graal-dev mailing list.

Authors

The main authors of TruffleRuby ordered by first contribution are: Chris Seaton, Benoit Daloze, Kevin Menard, Petr Chalupa, Brandon Fish, Duncan MacGregor, Christian Wirth, Rafael França, Alan Wu, Nicolas Laurent, Carol Chen, Nikolay Sverchkov, Lillian Zhang, Tom Stuart, and Maple Ong.

Security

See SECURITY for how to report security vulnerabilities to Oracle. For known vulnerabilities in Ruby, please refer to the known-cves file.

Licence

TruffleRuby is copyright (c) 2013-2024 Oracle and/or its affiliates, and is made available to you under the terms of any one of the following three licenses:

  • Eclipse Public License version 2.0, or
  • GNU General Public License version 2, or
  • GNU Lesser General Public License version 2.1.

For further licensing information, see LICENCE, 3rd_party_licenses, and doc/legal/legal.

Attribution

TruffleRuby includes infrastructure code from JRuby (e.g. parser, JCodings, Joni), core library code from the Rubinius project, as well as code from the standard implementation of Ruby, MRI.

truffleruby's People

Contributors

aardvark179 avatar andrykonchin avatar atambo avatar banzaiman avatar bjfish avatar calavera avatar cheald avatar chrisseaton avatar donv avatar enebo avatar eregon avatar etehtsea avatar ghostganz avatar headius avatar horakivo avatar kares avatar lopex avatar lucasallan avatar mkristian avatar nicksieger avatar nirvdrum avatar olabini avatar oraclelabsautomation avatar pitr-ch avatar qmx avatar subbuss avatar timfel avatar vp-of-awesome avatar vvs avatar yokolet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

truffleruby's Issues

Can't install modern gems via Bundler

source "https://rubygems.org"
gem 'rack', '>= 2'

bundle fails with this Gemfile due to Bundler thinking the runtime is 2.0.0p648. I have no idea why it thinks that.

$ bundle -v
Bundler version 1.14.4

Ruby on WASM

With WASM having been deemed stable, are there any thoughts on TruffleRuby also going into the browser?

Opal clearly is and has been the de facto standard of this (we're using it with great results for quite some time now), and I'm sure it will remain such for some time to come, but I was curious if there were any thoughts floating around in this regard from you guys. Or, perhaps even, if Oracle has considered throwing a dev or two behind Opal to push it forward in this cutting edge (and what will be the future) area...

Can't run rails tests

$ jt test ecosystem activemodel
jtt: $ GEM_HOME="~/opensource/truffleruby-ws/truffleruby/truffleruby-gem-test-pack-1/gems" GEM_PATH="~/opensource/truffleruby-ws/truffleruby/truffleruby-gem-test-pack-1/gems" ~/opensource/truffleruby-ws/truffleruby/bin/truffleruby ~/opensource/truffleruby-ws/truffleruby/truffleruby-gem-test-pack-1/gems/bin/bundle install --local --no-prune --without db\ job
Resolving dependencies....................
Could not find rake-10.4.2 in any of the sources
jtt: RuntimeError: command failed\n~/opensource/truffleruby-ws/truffleruby/lib/truffleruby-tool/lib/truffle_tool.rb:57:in `execute_cmd'
~/opensource/truffleruby-ws/truffleruby/lib/truffleruby-tool/lib/truffle_tool.rb:764:in `execute_cmd'
~/opensource/truffleruby-ws/truffleruby/lib/truffleruby-tool/lib/truffle_tool.rb:614:in `subcommand_setup'
~/opensource/truffleruby-ws/truffleruby/lib/truffleruby-tool/lib/truffle_tool.rb:449:in `send'
~/opensource/truffleruby-ws/truffleruby/lib/truffleruby-tool/lib/truffle_tool.rb:449:in `block in run'
~/opensource/truffleruby-ws/truffleruby/src/main/ruby/core/dir.rb:207:in `chdir'
~/opensource/truffleruby-ws/truffleruby/lib/truffleruby-tool/lib/truffle_tool.rb:447:in `run'
~/opensource/truffleruby-ws/truffleruby/lib/truffleruby-tool/lib/truffle_tool.rb:911:in `block in setup'
~/opensource/truffleruby-ws/truffleruby/src/main/ruby/core/dir.rb:207:in `chdir'
~/opensource/truffleruby-ws/truffleruby/lib/truffleruby-tool/lib/truffle_tool.rb:910:in `setup'
~/opensource/truffleruby-ws/truffleruby/lib/truffleruby-tool/lib/config.rb:237:in `rails_ci_setup'
~/opensource/truffleruby-ws/truffleruby/lib/truffleruby-tool/lib/config.rb:221:in `rails_ci'
~/opensource/truffleruby-ws/truffleruby/lib/truffleruby-tool/lib/config.rb:275:in `block in <top (required)>'
~/opensource/truffleruby-ws/truffleruby/lib/truffleruby-tool/lib/truffle_tool.rb:843:in `instance_eval'
~/opensource/truffleruby-ws/truffleruby/lib/truffleruby-tool/lib/truffle_tool.rb:843:in `block in do_definition'
~/opensource/truffleruby-ws/truffleruby/src/main/ruby/core/throw_catch.rb:34:in `catch'
~/opensource/truffleruby-ws/truffleruby/lib/truffleruby-tool/lib/truffle_tool.rb:841:in `do_definition'
~/opensource/truffleruby-ws/truffleruby/lib/truffleruby-tool/lib/truffle_tool.rb:832:in `initialize'
~/opensource/truffleruby-ws/truffleruby/lib/truffleruby-tool/lib/truffle_tool.rb:748:in `new'
~/opensource/truffleruby-ws/truffleruby/lib/truffleruby-tool/lib/truffle_tool.rb:748:in `subcommand_ci'
~/opensource/truffleruby-ws/truffleruby/lib/truffleruby-tool/lib/truffle_tool.rb:449:in `send'
~/opensource/truffleruby-ws/truffleruby/lib/truffleruby-tool/lib/truffle_tool.rb:449:in `block in run'
~/opensource/truffleruby-ws/truffleruby/src/main/ruby/core/dir.rb:207:in `chdir'
~/opensource/truffleruby-ws/truffleruby/lib/truffleruby-tool/lib/truffle_tool.rb:447:in `run'
lib/truffleruby-tool/bin/truffleruby-tool:6:in `<main>'

This is somewhat weird because rake-10.4.2 is present in truffleruby-gem-test-pack-1.

Setting `--native` in `TRUFFLERUBYOPT` gives error

Trying to use truffleruby in native mode by setting the TRUFFLERUBYOPT environment variable:

$ export TRUFFLERUBYOPT="--native"
$ ruby -v
ERROR: native options are not supported on the JVM
$ ruby -v --native
truffleruby 0.30, like ruby 2.3.5 <native build with Graal> [darwin-x86_64]

Performance issue with Contracts gem

Contracts is a gem that allows runtime type checks.
It also allows overloading methods, which I think is its most interesting feature. The performance of overloaded methods is pretty bad (and worsens the more overloads a method has) so it was at the top of the list of things I wanted to see TruffleRuby deal with.
It turns out the performance is much worse than it is on MRI:

require 'contracts'

class Foo
  include Contracts

  def initialize
    @val = 0
  end

  Contract Integer => Any
  def val=(val)
    @val = val
  end

  Contract String => Any
  def val=(val)
    @val = val.to_i
  end
end

FOO = Foo.new

Benchmark.ips do |i|
  i.iterations = 5

  i.report('Integer') do
    FOO.val = 1
  end

  i.report('String') do
    FOO.val = '1'
  end

  i.compare!
end

MRI 2.4.2 results:

Warming up --------------------------------------
             Integer    13.470k i/100ms
              String     2.283k i/100ms
             Integer    13.456k i/100ms
              String     2.239k i/100ms
             Integer    13.464k i/100ms
              String     2.284k i/100ms
             Integer    13.485k i/100ms
              String     2.283k i/100ms
             Integer    13.097k i/100ms
              String     1.961k i/100ms
Calculating -------------------------------------
             Integer    130.694k (±22.6%) i/s -    589.365k in   5.051671s
              String     20.677k (±18.3%) i/s -     98.050k in   5.044643s
             Integer    137.315k (±14.8%) i/s -    667.947k in   5.027312s
              String     21.228k (±11.2%) i/s -    105.894k in   5.075358s
             Integer    144.753k (± 6.8%) i/s -    733.432k in   5.092164s
              String     21.664k (± 9.5%) i/s -    107.855k in   5.034083s
             Integer    153.898k (± 3.9%) i/s -    772.723k in   5.028786s
              String     23.450k (± 3.5%) i/s -    117.660k in   5.023831s
             Integer    154.630k (± 3.0%) i/s -    785.820k in   5.086608s
              String     23.195k (± 3.6%) i/s -    117.660k in   5.079173s

Comparison:
             Integer:   154630.2 i/s
              String:    23195.3 i/s - 6.67x  slower

TruffleRuby 0.28.2 results:

Warming up --------------------------------------
             Integer   672.000  i/100ms
              String    12.000  i/100ms
             Integer   593.000  i/100ms
              String    18.000  i/100ms
             Integer    60.576k i/100ms
              String    23.000  i/100ms
             Integer    67.753k i/100ms
              String    24.000  i/100ms
             Integer   256.228k i/100ms
              String    30.000  i/100ms
Calculating -------------------------------------
             Integer      3.422M (±34.1%) i/s -     10.762M in   5.045545s
              String    431.767  (±30.1%) i/s -      1.920k in   5.014015s
             Integer      3.792M (± 8.3%) i/s -     18.961M in   5.041862s
              String    560.532  (±10.2%) i/s -      2.790k in   5.047494s
             Integer      3.851M (± 6.4%) i/s -     19.217M in   5.011099s
              String    580.852  (± 8.3%) i/s -      2.880k in   5.001838s
             Integer      3.821M (± 7.4%) i/s -     19.217M in   5.059620s
              String    565.077  (±10.4%) i/s -      2.790k in   5.016192s
             Integer      3.900M (± 8.8%) i/s -     19.473M in   5.042999s
              String    570.693  (± 9.5%) i/s -      2.850k in   5.051512s
Comparison:
             Integer:  3899698.2 i/s
              String:      570.7 i/s - 6833.27x  slower

The way Contracts handles all this is a bit difficult to figure out at first glance so here's where the magic happens.

TruffleFatalException: couldn't load the post-boot code

Hey guys, I've followed all of your instructions, installed truffleruby, compiled sulong add added it to support C extensions, but I can't get pass that problem :(

/home/mencio/.rvm/rubies/ruby-2.4.1/bin/ruby ../truffleruby/tool/jt.rb test test :capi

$ EXCLUDES=test/mri/excludes RUBYOPT=--disable-gems /home/mencio/.graalvm/truffleruby/bin/truffleruby -Xcore.load_path=/home/mencio/.graalvm/truffleruby/src/main/ruby -Xgraal.warn_unless=false -Xexceptions.print_uncaught_java=true -J-Xmx2G -J-ea -J-esa test/mri/tests/runner.rb -v --color=never --tty=no -q test :capi
/home/mencio/.graalvm/truffleruby/src/main/ruby/post-boot/post-boot.rb:17:in `method_missing': undefined method `print_time_metric' for Truffle::Boot:Module (NoMethodError)
	from /home/mencio/.graalvm/truffleruby/src/main/ruby/post-boot/post-boot.rb:17:in `<top (required)>'
java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.oracle.graalvm.launcher.LegacyLauncher.main(stripped:20)
Caused by: org.graalvm.polyglot.PolyglotException: org.truffleruby.language.control.TruffleFatalException: couldn't load the post-boot code
FAILED (pid 23582 exit 1): EXCLUDES=test/mri/excludes RUBYOPT=--disable-gems /home/mencio/.graalvm/truffleruby/bin/truffleruby -Xcore.load_path=/home/mencio/.graalvm/truffleruby/src/main/ruby -Xgraal.warn_unless=false -Xexceptions.print_uncaught_java=true -J-Xmx2G -J-ea -J-esa test/mri/tests/runner.rb -v --color=never --tty=no -q test :capi

cannot load such file -- openssl.so

macOS 10.12.2
graalvm-0.19-macosx-amd64-dk.tar.gz

/tmp/graalvm-0.19-dk/bin/ruby -S gem install bundler
ERROR:  While executing gem ... (Gem::Exception)
    Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources
/tmp/graalvm-0.19-dk/bin/ruby -ropenssl -e 'true'
/private/tmp/graalvm-0.19-dk/jre/language/ruby/lib/ruby/truffle/mri/rubygems/core_ext/kernel_require.rb:55:in `gem_original_require': cannot load such file -- openssl.so (LoadError)
	from /private/tmp/graalvm-0.19-dk/jre/language/ruby/lib/ruby/truffle/mri/rubygems/core_ext/kernel_require.rb:55:in `require'
	from /private/tmp/graalvm-0.19-dk/jre/language/ruby/lib/ruby/truffle/openssl/openssl.rb:13:in `<main>'
	from /private/tmp/graalvm-0.19-dk/jre/language/ruby/lib/ruby/truffle/mri/rubygems/core_ext/kernel_require.rb:55:in `gem_original_require'
	from /private/tmp/graalvm-0.19-dk/jre/language/ruby/lib/ruby/truffle/mri/rubygems/core_ext/kernel_require.rb:55:in `require'
	from -e:1:in `<main>'

alias with special character symbols fails

Passing symbols with special characters appears to not work. However, it appears to only be a problem when defining a symbol with something like :'props=' vs. :props=. Note that this only affects alias --
it doesn't affect alias_method.

For example:

ext-truffleruby :001 > class Foo1
ext-truffleruby :002?>     def props=(value)
ext-truffleruby :003?>       end
ext-truffleruby :004?>     alias :'properties=' :'props='
ext-truffleruby :005?>   end
RubyTruffleError: org.truffleruby.parser.ast.SymbolParseNode cannot be cast to org.truffleruby.parser.ast.LiteralParseNode
	ClassCastException org.truffleruby.parser.BodyTranslator.translateNameNodeToSymbol(BodyTranslator.java:306)
	from /home/aaron/Projects/truffle/truffleruby/lib/mri/irb/workspace.rb:87:in `eval'
	from /home/aaron/Projects/truffle/truffleruby/lib/mri/irb/workspace.rb:87:in `evaluate'
	from /home/aaron/Projects/truffle/truffleruby/lib/mri/irb/context.rb:380:in `evaluate'
	from /home/aaron/Projects/truffle/truffleruby/lib/mri/irb.rb:489:in `block (2 levels) in eval_input'
	from /home/aaron/Projects/truffle/truffleruby/lib/mri/irb.rb:623:in `signal_status'
	from /home/aaron/Projects/truffle/truffleruby/lib/mri/irb.rb:486:in `block in eval_input'
	from /home/aaron/Projects/truffle/truffleruby/lib/mri/irb/ruby-lex.rb:246:in `block (2 levels) in each_top_level_statement'
	from /home/aaron/Projects/truffle/truffleruby/lib/mri/irb/ruby-lex.rb:232:in `loop'
	from /home/aaron/Projects/truffle/truffleruby/lib/mri/irb/ruby-lex.rb:232:in `block in each_top_level_statement'
	from /home/aaron/Projects/truffle/truffleruby/lib/mri/irb/ruby-lex.rb:231:in `catch'
	from /home/aaron/Projects/truffle/truffleruby/lib/mri/irb/ruby-lex.rb:231:in `catch'
	from /home/aaron/Projects/truffle/truffleruby/lib/mri/irb/ruby-lex.rb:231:in `register'
	from /home/aaron/Projects/truffle/truffleruby/lib/mri/irb/ruby-lex.rb:231:in `catch'
	from /home/aaron/Projects/truffle/truffleruby/lib/mri/irb/ruby-lex.rb:231:in `each_top_level_statement'
	from /home/aaron/Projects/truffle/truffleruby/lib/mri/irb.rb:485:in `eval_input'
	from /home/aaron/Projects/truffle/truffleruby/lib/mri/irb.rb:395:in `block in start'
	from /home/aaron/Projects/truffle/truffleruby/lib/mri/irb.rb:394:in `catch'
	from /home/aaron/Projects/truffle/truffleruby/lib/mri/irb.rb:394:in `catch'
	from /home/aaron/Projects/truffle/truffleruby/lib/mri/irb.rb:394:in `register'
	from /home/aaron/Projects/truffle/truffleruby/lib/mri/irb.rb:394:in `catch'
	from /home/aaron/Projects/truffle/truffleruby/lib/mri/irb.rb:394:in `start'
	from /home/aaron/.rvm/rubies/ext-truffleruby/bin/irb:15:in `<main>'
Maybe IRB bug!
ext-truffleruby :006 > 
ext-truffleruby :007 >   class Foo2
ext-truffleruby :008?>     def props=(value)
ext-truffleruby :009?>       end
ext-truffleruby :010?>     alias :properties= :props=
ext-truffleruby :011 >     end
 => Foo2 
ext-truffleruby :012 > 
ext-truffleruby :013 >   class Foo3
ext-truffleruby :014?>     def props=(value)
ext-truffleruby :015?>       end
ext-truffleruby :016?>     alias_method :'properties=', :'props='
ext-truffleruby :017?>   end
 => Foo3 
ext-truffleruby :018 > 
ext-truffleruby :019 >   class Foo4
ext-truffleruby :020?>     def props=(value)
ext-truffleruby :021?>       end
ext-truffleruby :022?>     alias_method :properties=, :props=
ext-truffleruby :023?>   end
 => Foo4 

This was tested with the following version of truffleruby: 3896217

Startup....

While I've been talking with many people about Truffle, one issue keeps popping up immediately when the discussion is brought around to using the JVM: What about startup speed?

Beyond simple general execution speeds, the #1 concern that Crystal has brought to the very front of the line is that of how fast do we get to actually execute our code. Are there some things, beyond just leaving a hot JVM active in the background, that can be done to make Truffle pop on startup speeds?

Bad Performance with bigdecimal

Hello,
I'm really interested in truffleruby and started to benchmark a simple use-case.
The performance of the script below (just counting the Time.now - t1) is around 25 times worse than CRuby.

require 'bigdecimal'

cnt = 0

puts "start"
t1 = Time.now

while true do
  cc = BigDecimal(cnt)
  cnt += 1
  break if cnt > 100000
end

puts (Time.now - t1) * 1000

rvm integration?

I am assuming eventually that truffleRuby will be available via RVM. Any rough timeframe for when that might happen?

Also, will it be possible to run bundler in truffleRuby? I run the Roda web micro framework for a JSON API (thus I don't need the full Rails support), but would love to be able to play around with it once RVM has a version of truffleRuby to download

syslog doesn't exist

Looks like syslog doesn't exist:

ext-truffleruby :001 > require 'syslog'
LoadError: cannot load such file -- syslog
	from /home/aaron/Projects/truffle/truffleruby/lib/mri/rubygems/core_ext/kernel_require.rb:55:in `gem_original_require'
	from /home/aaron/Projects/truffle/truffleruby/lib/mri/rubygems/core_ext/kernel_require.rb:55:in `require'
	from (irb):1:in `<main>'
	from /home/aaron/.rvm/rubies/ext-truffleruby/bin/irb:15:in `<main>'

slow json encoding

Hello

I tested with v0.21 (0.22 gives some gem trouble) this small example as a starter code to integrate with benchmark/ips
Problem is that even the code above takes around 21 minutes (Time.now - t1) to run, where MRI takes only 50 seconds.

require 'json'

cnt = 0

while true
  JSON.dump({ :test => 1 })
  cnt = cnt + 1
  break if cnt > 1000000
end

cnt = 0

t1 = Time.now
while true
  JSON.dump({ :test => 1 })
  cnt = cnt + 1
  break if cnt > 10000000
end

puts (Time.now - t1) * 1000

Anything you need to optimise still?

Thanks for all your effort

Is there a TruffleRuby logo?

Hello!

I know it's probably not very high on the priority list, but it would be great if truffleruby had a logo that could be used in presentations and on apps supporting it.

A followup question is: would you be interested in a community contribution for a logo? I'm not a designer but I believe I can convince one to help me 😄

Known bugs in Ruby included with graalvm-0.22?

I previously installed graalvm-0.21, following your guides, and did some experiments with it. I installed bundler and some other gems and things ran fine. Everything expected to work works, speed amazing!

Now I just downloaded graalvm-0.22, but I can't get bundler, or any other gem, to install. And I can't make sense of the reason: installing fails with

ERROR:  While executing gem ... (NoMethodError)
    undefined method `<<' for nil:NilClass
undefined method `<<' for nil:NilClass
/home/wever/bin/graalvm-0.22/language/ruby/lib/mri/rubygems/request_set.rb:344:in `method_missing'
/home/wever/bin/graalvm-0.22/language/ruby/lib/mri/rubygems/request_set.rb:344:in `resolve'
/home/wever/bin/graalvm-0.22/language/ruby/lib/mri/rubygems/dependency_installer.rb:487:in `resolve_dependencies'
/home/wever/bin/graalvm-0.22/language/ruby/lib/mri/rubygems/commands/install_command.rb:239:in `install_gem'
/home/wever/bin/graalvm-0.22/language/ruby/lib/mri/rubygems/commands/install_command.rb:300:in `block in install_gems'
/home/wever/bin/graalvm-0.22/language/ruby/lib/mri/rubygems/commands/install_command.rb:296:in `each'
/home/wever/bin/graalvm-0.22/language/ruby/lib/mri/rubygems/commands/install_command.rb:296:in `install_gems'
/home/wever/bin/graalvm-0.22/language/ruby/lib/mri/rubygems/commands/install_command.rb:203:in `execute'
/home/wever/bin/graalvm-0.22/language/ruby/lib/mri/rubygems/command.rb:308:in `invoke_with_build_args'
/home/wever/bin/graalvm-0.22/language/ruby/lib/mri/rubygems/command_manager.rb:171:in `process_args'
/home/wever/bin/graalvm-0.22/language/ruby/lib/mri/rubygems/command_manager.rb:139:in `run'
/home/wever/bin/graalvm-0.22/language/ruby/lib/mri/rubygems/gem_runner.rb:55:in `run'
/home/wever/bin/graalvm-0.22/language/ruby/lib/bin/gem:21:in `<main>'
(core):1:in `load'

I did some debugging and at the start of the resolve_dependencies method, before the call to request_set on line /lib/mri/rubygems/dependency_installer.rb:487, the following happens:

    request_set = Gem::RequestSet.new
    puts "Initally request_set has @sets = #{request_set.sets}"
    request_set.development         = @development
    puts "After setting development, @sets = #{request_set.sets}"
    request_set.development_shallow = @dev_shallow
    puts "After setting development_shallow, @sets = #{request_set.sets}"

where the puts calls are mine. This outputs

Initally request_set has @sets = []
After setting development, @sets = false
After setting development_shallow, @sets = 

even though e.g. the request_set.development= method is, as far as I can tell, just the plain setter method generated by an attr_accessor declaration. I can see no reason why setting development should change the contents of the @setsinstance variable of the RequestSet instance.

So I have to ask: are there perhaps known bugs in the Ruby implementation included with graalvm-0.22? Or am I doing something wrong?

Improve user experience

  • Supply a curl-able download that doesn't need an account or a click-through to use. moved to #118

  • #83 Document how to add Ruby from GraalVM to a Ruby manager.

  • After untaring GraalVM, truffleruby has to work including other executable like irb, rake (they have to run on truffleruby). Solved with a helper directory lib/bin. Gem install uses absolute path in the executable wrappers installed to bindir, therefore they will run correctly on truffleruby.

  • GraalVM language/ruby directory has to have regular ruby layout so it can be added to ruby managers. Only know problem is that language/ruby/bin directory is missing. It should be a copy of truffleruby/bin directory. Two launchers in graalvm/bin and truffleruby/bin has to be sorted out. Ideally merged.

  • #60 Gem executable should be installed in truffleruby/bin next to the launcher as in other Rubies.

  • #60 When truffleruby is executed from GraalVM directly without a ruby manager and a ruby manager is in use configuring wrong GEM_HOME for a different ruby implementation a warning should be printed.

  • #46 Run bundler and gem without manually requiring bundler-workarounds

Can't add to RVM

Following your instructions to add to RVM I get this error:

Empty path passed to certificates update, functions stack: requirements_osx_update_openssl_cert_run rvm_requiremnts_fail_or_run_action __rvm_osx_ssl_certs_ensure_for_ruby __rvm_osx_ssl_certs_ensure_for_ruby_except_jruby external_mount external_mount_uniq main

Looking for guidance.

Warnings on gem install

With the setup explained in #491 a vanilla gem install jekyll -N issues a bunch of warnings:

$ gem install jekyll -N
[ruby] WARN A nonstandard GEM_HOME is set /Users/fxn/.gem/truffleruby/2.3.3
[ruby] WARN The bad GEM_HOME may come from a ruby manager, make sure you've called one of: `rvm use system`, `rbenv system`, or `chruby system` to clear the environment.
[ruby] WARNING rb_tr_handle_for_managed without matching rb_tr_release_handle; handles will be leaking
[ruby] WARNING rb_tr_handle_for_managed without matching rb_tr_release_handle; handles will be leaking
[ruby] WARNING rb_tr_handle_for_managed without matching rb_tr_release_handle; handles will be leaking
[ruby] WARNING rb_tr_handle_for_managed without matching rb_tr_release_handle; handles will be leaking
[ruby] WARNING rb_tr_handle_for_managed without matching rb_tr_release_handle; handles will be leaking

with groups of three

[ruby] WARNING rb_tr_handle_for_managed without matching rb_tr_release_handle; handles will be leaking
[ruby] WARNING rb_tr_handle_for_managed without matching rb_tr_release_handle; handles will be leaking
[ruby] WARNING rb_tr_handle_for_managed without matching rb_tr_release_handle; handles will be leaking

repeated after some "successfully installed" messages but not others, complete trace below.

$ gem install jekyll -N
[ruby] WARN A nonstandard GEM_HOME is set /Users/fxn/.gem/truffleruby/2.3.3
[ruby] WARN The bad GEM_HOME may come from a ruby manager, make sure you've called one of: `rvm use system`, `rbenv system`, or `chruby system` to clear the environment.
[ruby] WARNING rb_tr_handle_for_managed without matching rb_tr_release_handle; handles will be leaking
[ruby] WARNING rb_tr_handle_for_managed without matching rb_tr_release_handle; handles will be leaking
[ruby] WARNING rb_tr_handle_for_managed without matching rb_tr_release_handle; handles will be leaking
[ruby] WARNING rb_tr_handle_for_managed without matching rb_tr_release_handle; handles will be leaking
[ruby] WARNING rb_tr_handle_for_managed without matching rb_tr_release_handle; handles will be leaking
Fetching: public_suffix-3.0.0.gem (100%)
Successfully installed public_suffix-3.0.0
[ruby] WARNING rb_tr_handle_for_managed without matching rb_tr_release_handle; handles will be leaking
[ruby] WARNING rb_tr_handle_for_managed without matching rb_tr_release_handle; handles will be leaking
[ruby] WARNING rb_tr_handle_for_managed without matching rb_tr_release_handle; handles will be leaking
Fetching: addressable-2.5.2.gem (100%)
Successfully installed addressable-2.5.2
[ruby] WARNING rb_tr_handle_for_managed without matching rb_tr_release_handle; handles will be leaking
[ruby] WARNING rb_tr_handle_for_managed without matching rb_tr_release_handle; handles will be leaking
[ruby] WARNING rb_tr_handle_for_managed without matching rb_tr_release_handle; handles will be leaking
Fetching: colorator-1.1.0.gem (100%)
Successfully installed colorator-1.1.0
Fetching: rb-fsevent-0.10.2.gem (100%)
Successfully installed rb-fsevent-0.10.2
[ruby] WARNING rb_tr_handle_for_managed without matching rb_tr_release_handle; handles will be leaking
[ruby] WARNING rb_tr_handle_for_managed without matching rb_tr_release_handle; handles will be leaking
[ruby] WARNING rb_tr_handle_for_managed without matching rb_tr_release_handle; handles will be leaking
Fetching: ffi-1.9.18.gem (100%)
WORKAROUND: Not building native extensions for ffi.
Support of C extensions is in development, set TRUFFLERUBY_CEXT_ENABLED=true to experiment.
Successfully installed ffi-1.9.18
[ruby] WARNING rb_tr_handle_for_managed without matching rb_tr_release_handle; handles will be leaking
[ruby] WARNING rb_tr_handle_for_managed without matching rb_tr_release_handle; handles will be leaking
[ruby] WARNING rb_tr_handle_for_managed without matching rb_tr_release_handle; handles will be leaking
Fetching: rb-inotify-0.9.10.gem (100%)
Successfully installed rb-inotify-0.9.10
Fetching: sass-listen-4.0.0.gem (100%)
Successfully installed sass-listen-4.0.0
Fetching: sass-3.5.1.gem (100%)
Successfully installed sass-3.5.1
[ruby] WARNING rb_tr_handle_for_managed without matching rb_tr_release_handle; handles will be leaking
[ruby] WARNING rb_tr_handle_for_managed without matching rb_tr_release_handle; handles will be leaking
[ruby] WARNING rb_tr_handle_for_managed without matching rb_tr_release_handle; handles will be leaking
Fetching: jekyll-sass-converter-1.5.0.gem (100%)
Successfully installed jekyll-sass-converter-1.5.0
Fetching: listen-3.0.8.gem (100%)
Successfully installed listen-3.0.8
Fetching: jekyll-watch-1.5.0.gem (100%)
Successfully installed jekyll-watch-1.5.0
Fetching: kramdown-1.14.0.gem (100%)
Successfully installed kramdown-1.14.0
[ruby] WARNING rb_tr_handle_for_managed without matching rb_tr_release_handle; handles will be leaking
[ruby] WARNING rb_tr_handle_for_managed without matching rb_tr_release_handle; handles will be leaking
[ruby] WARNING rb_tr_handle_for_managed without matching rb_tr_release_handle; handles will be leaking
Fetching: liquid-4.0.0.gem (100%)
Successfully installed liquid-4.0.0
Fetching: mercenary-0.3.6.gem (100%)
Successfully installed mercenary-0.3.6
Fetching: forwardable-extended-2.6.0.gem (100%)
Successfully installed forwardable-extended-2.6.0
Fetching: pathutil-0.14.0.gem (100%)
Successfully installed pathutil-0.14.0
Fetching: rouge-1.11.1.gem (100%)
Successfully installed rouge-1.11.1
[ruby] WARNING rb_tr_handle_for_managed without matching rb_tr_release_handle; handles will be leaking
[ruby] WARNING rb_tr_handle_for_managed without matching rb_tr_release_handle; handles will be leaking
[ruby] WARNING rb_tr_handle_for_managed without matching rb_tr_release_handle; handles will be leaking
Fetching: safe_yaml-1.0.4.gem (100%)
Successfully installed safe_yaml-1.0.4
Fetching: jekyll-3.5.2.gem (100%)
Successfully installed jekyll-3.5.2
19 gems installed

Do not use JRUBY_OPTS

As shown in #30 this can cause problems.
Since we already support both RUBYOPT and TRUFFLERUBYOPT, it's a matter of removing our own usage of JRUBY_OPTS.

Documentation

Hi.

In the State of the Union™ letter you mentioned that:

We are using the SubstrateVM, an ahead of time compiler for Java programs, to compile JRuby+Truffle to a single statically-linked binary, that doesn’t even have a dependency on a JVM

Could you please update README with system requirements, installation instructions and some kind of short progress report? As far I understand, it's still on the Oracle Labs under OTN license.

Also, it will be awesome to see answers to other obvious questions:

  1. What's about TruffleRuby license?
  2. Do you have a roadmap? What is the current state? Short/mid/long term goals? How far away it is from begin "production-ready"?
  3. Who are the "core team"? Where we can find them?
  4. How development process will look like? Is there contribution guidelines? How it's build, tested and distributed?

This is just from the top of my head. I bet others will have way more questions.

Thanks and congratulations!

Chruby

I use chruby so I thought I would try it with Graalvm. I went to the oracle site and downloaded the tar file. I untarred it and put it in the ~/.rubies directory. Since there is a bin/ruby in the graalvm directory I thought it might "just work".

When I attempt to chruby graalvm I get an error

Exception in thread "main" org.jruby.truffle.language.control.RaiseException: internal implementation error -
IOException Can't read file - org.jruby.truffle.language.loader.SourceLoader.ensureReadable(SourceLoader.java:106)

I wasn't really thinking it would work but it almost did so I thought I'd tell you guys about it.

Leap seconds not supported

It looks like when we moved from joda-time to the JDK 8 date/time APIs, we lost support for leap seconds. As far as I can tell the JDK doesn't support them, so supporting them in TruffleRuby is going to be tricky.

Running rails server

Hi,

I have a project in rails and I want to test how it run in graalvm.

  • MACOS 10.12.2
  • java version "1.8.0_111"
    Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
    Java HotSpot(TM) 64-Bit Server VM (build 25.71-b01-internal-jvmci-0.23, mixed mode)
  • truffleruby SNAPSHOT, like ruby 2.3.1 <Java HotSpot(TM) 64-Bit Server VM 1.8.0_111-b14 with Graal> [darwin-x86_64]

I already install bundle and gems follow:
https://github.com/graalvm/truffleruby/blob/master/doc/user/installing-gems.md
But when I try to exec rails server thats no works.
I tried:

  • ruby -S bundle exec bin/rails server
Ignoring bcrypt-3.1.11 because its extensions are not built.  Try: gem pristine bcrypt --version 3.1.11
Ignoring bson-4.2.1 because its extensions are not built.  Try: gem pristine bson --version 4.2.1
Ignoring byebug-9.0.6 because its extensions are not built.  Try: gem pristine byebug --version 9.0.6
Ignoring json-2.0.3 because its extensions are not built.  Try: gem pristine json --version 2.0.3
Ignoring nio4r-1.2.1 because its extensions are not built.  Try: gem pristine nio4r --version 1.2.1
Ignoring nokogiri-1.7.0.1 because its extensions are not built.  Try: gem pristine nokogiri --version 1.7.0.1
Ignoring plivo-0.3.11 because its extensions are not built.  Try: gem pristine plivo --version 0.3.11
Ignoring unf_ext-0.0.7.2 because its extensions are not built.  Try: gem pristine unf_ext --version 0.0.7.2
Ignoring websocket-driver-0.6.5 because its extensions are not built.  Try: gem pristine websocket-driver --version 0.6.5
bundler: command not found: bin/rails
Install missing gem executables with `bundle install`
  • ruby -S bundle exec rails server
Ignoring bcrypt-3.1.11 because its extensions are not built.  Try: gem pristine bcrypt --version 3.1.11
Ignoring bson-4.2.1 because its extensions are not built.  Try: gem pristine bson --version 4.2.1
Ignoring byebug-9.0.6 because its extensions are not built.  Try: gem pristine byebug --version 9.0.6
Ignoring json-2.0.3 because its extensions are not built.  Try: gem pristine json --version 2.0.3
Ignoring nio4r-1.2.1 because its extensions are not built.  Try: gem pristine nio4r --version 1.2.1
Ignoring nokogiri-1.7.0.1 because its extensions are not built.  Try: gem pristine nokogiri --version 1.7.0.1
Ignoring plivo-0.3.11 because its extensions are not built.  Try: gem pristine plivo --version 0.3.11
Ignoring unf_ext-0.0.7.2 because its extensions are not built.  Try: gem pristine unf_ext --version 0.0.7.2
Ignoring websocket-driver-0.6.5 because its extensions are not built.  Try: gem pristine websocket-driver --version 0.6.5
spawn_setup: close_others not yet implemented
Your bundle is locked to rake (12.0.0), but that version could not be found in any of the sources listed in your Gemfile. If you haven't changed sources, that means the author of rake (12.0.0) has removed it. You'll need to update your bundle to a different version of rake (12.0.0) that hasn't been removed in order to install.
Run `bundle install` to install missing gems.

I hope to receive your reply soon,
Regards.

Support the Nokogiri gem

We need to support Nokogiri, particular as it's used so much in testing gems. As with openssl (#61) we are using Sulong as described in our RubyConf talk Ruby's C Extension Problem and How We're Fixing It.

Current status:
It should just work, TruffleRuby passes all Nokogiri tests, and by default TruffleRuby installs nokogiri with the packaged libxml2/libxslt like on CRuby. The only difference is that prebuilt binary gems are not available for TruffleRuby currently. One can also use --use-system-libraries if they like, but it's not faster, especially if those system libraries need to be installed.

Older status:
We now support Nokogiri, but it always uses a shared installation of libxml2, and so you need the libxml2 headers (and libraries) on the system (e.g., apt-get install libxml2-dev libxslt-dev on Debian-based).

On GitHub Actions, that means you need:

    - run: sudo apt-get -yqq install libxml2-dev libxslt-dev
      if: startsWith(matrix.ruby, 'truffleruby')
# before
    - uses: ruby/setup-ruby@v1

If you use ruby/setup-ruby with bundler-cache: true, then that is automatically done by setup-ruby:

    - uses: ruby/setup-ruby@v1
      with:
        ruby-version: truffleruby
        bundler-cache: true # automatically installs libxml2-dev libxslt-dev if nokogiri is in the lockfile

At some point we hope to be able to support building the in-tree libxml2 library like is done on MRI.

SortedSet not using bintree (rbtree)

Hello,

I'm keep testing truffleruby advances and it's amazing the progress you make every month.
I'm playing with SortedSet but (apologies if I'm wrong) to use the mri ruby implementation, that is quite slow.
Do you have plans to integreate a java based rbtree?
Or it will work out of the box as soon as truffleruby will support C gems?

Thanks

$stderr should be flushed before exec

$ ruby -e '$stderr.puts "a"; exec "echo done"' |& cat   
a
done

$ jt ruby -e '$stderr.puts "a"; exec "echo done"' |& cat
done

Note that this only works for $stderr on MRI, not $stdout:

$ ruby -e '$stdout.puts "a"; exec "echo done"' |& cat
done

$stderr.sync is already true, so I am not sure what goes wrong.

Dependency on C extensions, contact channel?

Hi folks :) first of all, compliments on an amazing project, 2nd, a question. Where to ask questions? :) I opened up 2 SO tags for truffleruby and graalvm that you can use if you wish and to channel common Q&A regarding these projects:

  1. https://stackoverflow.com/questions/tagged/truffleruby
  2. https://stackoverflow.com/questions/tagged/graalvm

to ask the real question I was about to ask :) Why do you need libraries depending on C extensions, can't you use the JRuby world gems?

https://stackoverflow.com/questions/41779349/why-does-truffleruby-need-c-extensions

Kind regards

Truffle slower than MRI in standard lib Queue

Hello everyone,

I'm really pleased with the progress this project is doing so far, unbelievable.
I had a bit of time to test some other use cases and I found that the standard lib Queue is ~30% faster in MRI than in Truffle (0.28.2).

A small example to replicate it.

require 'thread'

queue = Queue.new

producer = Thread.new do
  while true do
    next if queue.size > 250000
    queue << 'hello'
  end
end

consumer = Thread.new do
  d1 = Time.now
  cnt = 0
  while true do
    value = queue.pop
    cnt += 1
    if cnt % 1000000 == 0
      now = Time.now
      puts "took #{(now - d1) * 1000}"
      d1 = now
    end
  end
end

consumer.join

Is this something that will be improved over time?

Thanks

Running the Optcarrot benchmark iteratively in the same VM results in a core dump

Outline

  • Ubuntu Mate 16.04
  • Intel i7 870 - 4x 2.93GHz - 3.60 GHz
  • 16GB RAM

Reproduction

Error description

After ~ the 7th run, the JVM tries to dump its core. Exact message:

# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007fea720e3ea6, pid=20200, tid=0x00007fea8b568700
#
# JRE version: Java(TM) SE Runtime Environment (8.0_151-b12) (build 1.8.0_151-b12)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.71-b01-internal-jvmci-0.38 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# J 15644 JVMCI org.graalvm.compiler.truffle.OptimizedCallTarget.callRoot([Ljava/lang/Object;)Ljava/lang/Object; (53 bytes) @ 0x00007fea720e3ea6 [0x00007fea720e0c20+0x3286] (#run /home/michael/Projects/RubyCompare/RubySuite/optcarrot/lib/optcarrot/nes.rb:74)
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /home/michael/Projects/RubyCompare/RubySuite/optcarrot/hs_err_pid20200.log
Loaded disassembler from /home/michael/.rbenv/graalvm-0.30.2/jre/lib/amd64/hsdis-amd64.so
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
#
Aborted (core dumped)

The referenced log file can be found here. Version 0.29 does not seem to be affected of this issue.

Announce list?

jruby had a great announce email list in the early days. I'd love to keep up to date with TruffleRuby in the same kinda way.

RUBY_ENGINE should be "truffleruby"

  • The current value means that. for instace, RUBY_ENGINE =~ /truffle/ returns false
  • concurrent-ruby might as well recognizes truffleruby wrong.
  • RUBY_ENGINE is the one true way to check which runtime we are on and we should honor it.

Crash when running fannkuch redux from CLBG

Using the graal-vm-0.22 tag, with a hand built graal/truffle. The fannkuch redux benchmark crashes as follows:

$ PATH=/home/vext01/warmup_experiment/work/mx:${PATH} JAVA_HOME=/home/vext01/warmup_experiment/work/graal-jvmci-8/jdk1.8.0_121/product GRAAL_HOME=~/warmup_experiment/work/graal /home/vext01/warmup_experiment/work/truffleruby/tool/jt.rb run --graal bench.rb                                                                    
$ JAVACMD=/home/vext01/warmup_experiment/work/graal-jvmci-8/jdk1.8.0_121/product/bin/java /home/vext01/warmup_experiment/work/truffleruby/bin/truffleruby -Xcore.load_path=/home/vext01/warmup_experiment/work/truffleruby/truffleruby/src/main/ruby -J-server -J-XX:+UnlockExperimentalVMOptions -J-XX:+EnableJVMCI -J-d64 -J-Djvmci.class.path.append=/home/vext01/warmup_experiment/work/graal/mxbuild/dists/graal.jar -J-Xbootclasspath/a:/home/vext01/warmup_experiment/work/truffle/mxbuild/dists/truffle-api.jar bench.rb
bench.rb:14:in `inner_iter': internal implementation error - 
NoSuchMethodError com.oracle.truffle.api.nodes.RootNode.<init>(Lcom/oracle/truffle/api/TruffleLanguage;Lcom/oracle/truffle/api/frame/FrameDescriptor;)V org.graalvm.compiler.truffle.OptimizedOSRLoopNode$OSRRootNode.<init>(OptimizedOSRLoopNode.java:407) (RubyTruffleError)
        from bench.rb:10:in `block in run_iter'
        from bench.rb:9:in `each'
        from bench.rb:9:in `run_iter'
        from bench.rb:78:in `<main>'
FAILED (pid 27122 exit 1): JAVACMD=/home/vext01/warmup_experiment/work/graal-jvmci-8/jdk1.8.0_121/product/bin/java /home/vext01/warmup_experiment/work/truffleruby/bin/truffleruby -Xcore.load_path=/home/vext01/warmup_experiment/work/truffleruby/truffleruby/src/main/ruby -J-server -J-XX:+UnlockExperimentalVMOptions -J-XX:+EnableJVMCI -J-d64 -J-Djvmci.class.path.append=/home/vext01/warmup_experiment/work/graal/mxbuild/dists/graal.jar -J-Xbootclasspath/a:/home/vext01/warmup_experiment/work/truffle/mxbuild/dists/truffle-api.jar bench.rb

The benchmark is here:
https://github.com/softdevteam/warmup_experiment/blob/master/benchmarks/fannkuch_redux/ruby/bench.rb

Add to the bottom of the file run_iter 200 to make the benchmark executable.

Hoping we can find a patch.

Thanks

No backtrace with two nested rescue

def raiser
  raise "foo"
end

def intermediate
  begin
    raiser
  rescue => e
    p e.backtrace
  end
end

def catcher
  begin
    intermediate
  rescue
    nil
  end
end

catcher

gives

["(omitted as the rescue expression was pure; use -Xbacktraces.omit_unused=false to disable)"]

Probably the nested rescue should re-enable backtraces in such a case.

Donate?

Is there a way to donate or support this project somehow? I am worried that this project will die because of not enough financial support.

Fiber / green threads / coroutines?

What is the plan for supporting Fibers? Right now JRuby backs each Fiber with a thread which is rather heavy on resources. Will TruffleRuby support anything lighter like green threads or coroutines to support the Fiber?

Usage with self-build graal-core

(this is sort of a continuation of the issues in jruby/jruby#4400 - I couldn't find a mailing list right away, if there is a more appropriate place, please let me know)

It's me again!

So I built graal-core with mx locally etc. now I can't manage to get truffle/jt.rb to run with this.

I.e.:

tobi@speedy ~/github/rubykon $ GRAAL_HOME=~/github/graal-core/ ../truffleruby/tool/jt.rb run  --graal -e 'puts Truffle::Graal.graal?'
$ JAVACMD=/usr/lib/jvm/java-9-oracle/bin/java /home/tobi/github/truffleruby/bin/jruby -X+T -Xtruffle.core.load_path=/home/tobi/github/truffleruby/truffle/src/main/ruby -J-server -J-XX:+UnlockExperimentalVMOptions -J-XX:+EnableJVMCI -J-d64 -J--add-exports=java.base/jdk.internal.module=org.graalvm.compiler.graal_core -J--module-path=/home/tobi/github/truffle/mxbuild/modules/com.oracle.truffle.truffle_api.jar:/home/tobi/github/graal-core/mxbuild/modules/org.graalvm.compiler.graal_core.jar -e 'puts Truffle::Graal.graal?'
Exception in thread "main" java.util.ServiceConfigurationError: com.oracle.truffle.api.TruffleRuntimeAccess: org.graalvm.compiler.truffle.hotspot.HotSpotTruffleRuntimeAccess not a subtype
	at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:536)
	at java.base/java.util.ServiceLoader.access$000(ServiceLoader.java:340)
	at java.base/java.util.ServiceLoader$ProviderImpl.<init>(ServiceLoader.java:630)
	at java.base/java.util.ServiceLoader$ModuleServicesLookupIterator.next(ServiceLoader.java:987)
	at java.base/java.util.ServiceLoader$ModuleServicesLookupIterator.next(ServiceLoader.java:895)
	at java.base/java.util.ServiceLoader$1.next(ServiceLoader.java:1160)
	at java.base/java.util.ServiceLoader$1.next(ServiceLoader.java:1152)
	at java.base/java.util.ServiceLoader$2.next(ServiceLoader.java:1257)
	at com.oracle.truffle.api.Truffle$1.run(Truffle.java:84)
	at com.oracle.truffle.api.Truffle$1.run(Truffle.java:61)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at com.oracle.truffle.api.Truffle.initRuntime(Truffle.java:61)
	at com.oracle.truffle.api.Truffle.<clinit>(Truffle.java:49)
	at com.oracle.truffle.api.impl.Accessor.<clinit>(Accessor.java:313)
	at com.oracle.truffle.api.vm.PolyglotEngine.<clinit>(PolyglotEngine.java:117)
	at org.jruby.truffle.Main.main(Main.java:102)
FAILED (pid 17122 exit 1): JAVACMD=/usr/lib/jvm/java-9-oracle/bin/java /home/tobi/github/truffleruby/bin/jruby -X+T -Xtruffle.core.load_path=/home/tobi/github/truffleruby/truffle/src/main/ruby -J-server -J-XX:+UnlockExperimentalVMOptions -J-XX:+EnableJVMCI -J-d64 -J--add-exports=java.base/jdk.internal.module=org.graalvm.compiler.graal_core -J--module-path=/home/tobi/github/truffle/mxbuild/modules/com.oracle.truffle.truffle_api.jar:/home/tobi/github/graal-core/mxbuild/modules/org.graalvm.compiler.graal_core.jar -e 'puts Truffle::Graal.graal?'
tobi@speedy ~/github/rubykon $ java -version
openjdk version "1.8.0_111"
OpenJDK Runtime Environment (build 1.8.0_111-8u111-b14-2ubuntu0.16.04.2-b14)
OpenJDK 64-Bit Server VM (build 25.111-b14, mixed mode)

After trying a bunch of things I get the sinking feeling that it tries to run everything with my Java 9 EA (see the JAVACMD line it generates) although my default version is set to 8 and it seems that truffleruby doesn't work with Java 8 (well I thought it'd use Graal and it wouldn't matter, but I dunno how it all ties together).

I tried forcing it to JDK 8 by setting JAVACMD/JAVA_HOME but it didn't quite work.

I get the sinking feeling that it might be because I built graal-core with Java 9 (to have that JVMCI enabled something version) and that this then forces JDK9 on execution but truffleruby doesn't work with that yet. Anyone to encourage/confirm/deny that working theory would be highly appreciated :)

truffleruby is at: 0dd1c17
graal-core is at: 3c054a0 (I went back a couple of commits as the newest version requires a Java 9 EA version that isn't yet in the PPA I use)

Anyhow, any help would be appreciated as usual. :)

TruffleRuby is installing Sinatra 1.4.8 instead of 2.0.0

ruby -S gem install sinatra without a version tries and fails to install 1.4.8 instead of 2.0.0. Interestingly, ruby -S gem install sinatra -v 2.0.0 works.

$ ruby -v
truffleruby 0.26, like ruby 2.3.3 <Java HotSpot(TM) 64-Bit Graal VM 1.8.0_121-b13 with Graal> [darwin-x86_64]

$ ruby -S gem install sinatra
Successfully installed tool-0.2.3
Successfully installed mustermann-0.4.0
Successfully installed rack-protection-2.0.0
Successfully installed tilt-2.0.8
ERROR:  Error installing sinatra:
	invalid gem: package metadata is missing in /Users/crigor/projects/truffleruby/graalvm-0.26/jre/languages/ruby/lib/ruby/gems/2.3.0/cache/sinatra-1.4.8.gem

$ ruby -S gem install sinatra -v 2.0.0
Successfully installed mustermann-1.0.0
Successfully installed sinatra-2.0.0
2 gems installed

Performance optimizations for my Array#to_proc

I wrote the following Array#to_proc. It makes Ruby more concise and pleasant to me.

Unfortunately, it leads to a performance hit on MRI(at the moment). I wonder if it can be optimized on TruffleRuby. Could it possibly become a zero-cost abstraction?

Here is an example:

require 'to_proc/all'

array_of_numbers = [0,1,2,3,4,5]
range = 1..2

array_of_numbers.map { |number| range.include? number }
array_of_numbers.map &[range, :include?]
#=> [false, true, true, false, false, false]


array_of_arrays = [[:a],[:b],[:c],[:d]]
array_to_append = [1,2]

array_of_arrays.map { |array| array + array_to_append }
array_of_arrays.map &[:+, array_to_append]
#=> [[:a, 1, 2], [:b, 1, 2], [:c, 1, 2], [:d, 1, 2]]

I am looking for the ways to contribute to TruffleRuby(probably after JVM 9 released). Performance optimizations for my Array#to_proc use case is one of the topics that interest me the most, at the moment.

I would be grateful if you could point me to the relevant parts of the codebase and relevant materials.

Cannot run `ruby` with chruby

I have GraalVM uncompressed under ~/graalvm-0.27 and ~/.rubies/truffleruby symlinked as documented in https://github.com/graalvm/truffleruby/blob/master/doc/user/ruby-managers.md#chruby and get this error:

$ ruby
realpath: No such file or directory
argv[0]=ruby

chruby is 0.3.9.

Note that there is no intermediate shell script, ruby is resolved by Bash directly as

$ which ruby
/Users/fxn/.rubies/truffleruby/bin/ruby

and that file is a binary executable

$ file /Users/fxn/.rubies/truffleruby/bin/ruby
/Users/fxn/.rubies/truffleruby/bin/ruby: Mach-O 64-bit executable x86_64

Let me also add that invoking said binary using a full path works

$ ~/.rubies/truffleruby/bin/ruby -v
truffleruby 0.27, like ruby 2.3.3 <Java HotSpot(TM) 64-Bit Graal VM 1.8.0_121-b13 with Graal> [darwin-x86_64]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.