Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for TruffleRuby #29

Closed
ioquatix opened this issue Nov 6, 2018 · 24 comments
Closed

Support for TruffleRuby #29

ioquatix opened this issue Nov 6, 2018 · 24 comments

Comments

@ioquatix
Copy link
Member

ioquatix commented Nov 6, 2018

Following on from oracle/truffleruby#1436 ...

We've migrated timers to us Process.clock_gettime. There might be other issues too.

You can run a large suite of tests by checking out the async source code and running:

rake external.

It will run specs for the following code bases:

async/Rakefile

Lines 25 to 29 in de63b27

clone_and_test("async-io")
clone_and_test("async-websocket")
clone_and_test("async-dns")
clone_and_test("async-http")
clone_and_test("falcon")

cc @jjyr @eregon

@ioquatix
Copy link
Member Author

ioquatix commented Nov 6, 2018

Also, I'd like to add support for travis testing across the entire eco-system, but we are currently blocking on travis-ci/travis-ci#9803

@deepj
Copy link

deepj commented Nov 6, 2018

I've tried to run a simple rack app on Falcon, but it failed on

D, [2018-11-06T08:24:09.330000 #22009] DEBUG -- Async::IO::Socket: Binding to #<Addrinfo: 127.0.0.1:9292 TCP>
D, [2018-11-06T08:24:09.355000 #22009] DEBUG -- Async::IO::Socket: Binding to #<Addrinfo: [::1]:9292 TCP>
D, [2018-11-06T08:24:09.370000 #22009] DEBUG -- <Async::Reactor:0x6ee stopped=false>: Exiting run-loop because finished.
~/.rubies/truffleruby-1.0.0-rc9/lib/truffle/truffle/cext.rb:221:in `execute_without_conversion': Cannot convert LLVMTypedForeignObject+0x0 to LLVMNativePointer (IllegalStateException) (RuntimeError)
	from java.lang.Throwable.<init>(Throwable.java:287)
	from java.lang.Exception.<init>(Exception.java:84)
	from java.lang.RuntimeException.<init>(RuntimeException.java:80)
	from java.lang.IllegalStateException.<init>(IllegalStateException.java:75)
	from com.oracle.truffle.llvm.runtime.nodes.api.LLVMToNativeNode$LLVMObjectToNativeNode.transitionToNative(LLVMToNativeNode.java:117)
	from com.oracle.truffle.llvm.runtime.nodes.api.LLVMToNativeNodeGen$LLVMObjectToNativeNodeGen.executeAndSpecialize(LLVMToNativeNodeGen.java:301)
	from com.oracle.truffle.llvm.runtime.nodes.api.LLVMToNativeNodeGen$LLVMObjectToNativeNodeGen.executeWithTarget(LLVMToNativeNodeGen.java:201)
	from com.oracle.truffle.llvm.runtime.nodes.api.LLVMToNativeNode.doOther(LLVMToNativeNode.java:78)
	from com.oracle.truffle.llvm.runtime.nodes.api.LLVMToNativeNodeGen.executeAndSpecialize(LLVMToNativeNodeGen.java:129)
	from com.oracle.truffle.llvm.runtime.nodes.api.LLVMToNativeNodeGen.executeWithTarget(LLVMToNativeNodeGen.java:50)
Caused by:
Message not supported: TO_NATIVE (UnsupportedMessageException)
	from java.lang.Throwable.<init>(Throwable.java:265)
	from java.lang.Exception.<init>(Exception.java:66)
	from com.oracle.truffle.api.interop.InteropException.<init>(InteropException.java:52)
	from com.oracle.truffle.api.interop.UnsupportedMessageException.<init>(UnsupportedMessageException.java:57)
	from com.oracle.truffle.api.interop.UnsupportedMessageException.raise(UnsupportedMessageException.java:84)
	from org.truffleruby.interop.RubyMessageResolution$ForeignToNativeNode.access(RubyMessageResolution.java:190)
	from org.truffleruby.interop.RubyMessageResolutionForeign$ForeignToNativeSubNode.accessWithTarget(RubyMessageResolutionForeign.java:503)
	from org.truffleruby.interop.RubyMessageResolutionForeignFactory$ForeignToNativeSubNodeGen.executeAndSpecialize(RubyMessageResolutionForeignFactory.java:602)
	from org.truffleruby.interop.RubyMessageResolutionForeignFactory$ForeignToNativeSubNodeGen.executeWithTarget(RubyMessageResolutionForeignFactory.java:588)
	from org.truffleruby.interop.RubyMessageResolutionForeign$ForeignToNativeSubNode$TO_NATIVERootNode.execute(RubyMessageResolutionForeign.java:520)
Translated to internal error
	from ~/.rubies/truffleruby-1.0.0-rc9/lib/truffle/truffle/cext.rb:221:in `execute_with_mutex'
	from ~/.rubies/truffleruby-1.0.0-rc9/lib/truffle/truffle/cext_ruby.rb:36:in `close'
	from ~/.gem/truffleruby/2.4.4/gems/async-1.10.3/lib/async/reactor.rb:208:in `close'
	from ~/.gem/truffleruby/2.4.4/gems/async-1.10.3/lib/async/reactor.rb:56:in `run'
	from ~/.gem/truffleruby/2.4.4/gems/falcon-0.19.2/lib/falcon/command/serve.rb:97:in `run'
	from ~/.gem/truffleruby/2.4.4/gems/falcon-0.19.2/lib/falcon/command/serve.rb:124:in `invoke'
	from ~/.gem/truffleruby/2.4.4/gems/falcon-0.19.2/lib/falcon/command.rb:70:in `invoke'
	from ~/.gem/truffleruby/2.4.4/gems/falcon-0.19.2/bin/falcon:26:in `<top (required)>'
	from ~/.gem/truffleruby/2.4.4/bin/falcon:23:in `load'
	from ~/.gem/truffleruby/2.4.4/bin/falcon:23:in `load'
	from ~/.gem/truffleruby/2.4.4/bin/falcon:23:in `<main>'

To reproduce:

run lambda {|env| [200, {}, ["Hello World"]]}

Then run it:

falcon --verbose serve -c the-script-above.rb

@eregon it ended up with this issue oracle/truffleruby#1441

@ioquatix
Copy link
Member Author

ioquatix commented Nov 6, 2018

What can I do to help resolve this issue? @eregon

@jjyr
Copy link
Contributor

jjyr commented Nov 6, 2018

All specs run well on my machine after upgrade timers to 4.2.0, I'll make a PR after the Travis issue resolved.

@ioquatix
Copy link
Member Author

ioquatix commented Nov 6, 2018

I installed truffle ruby 1.0.0rc9 and tried to run specs for async on my laptop. Some pass, some fail, ran into the same Message not supported: TO_NATIVE (UnsupportedMessageException) error above.

@eregon
Copy link

eregon commented Nov 6, 2018

@deepj Could you report as a separate issue on the TruffleRuby bug tracker, to make it easier to track?

That TO_NATIVE error means a C extension is storing a Ruby object in native memory.
I guess that could be nio4r, which gets installed when installing falcon.
We'll need to dig deeper to see the actual place and see what can be done about it.
We're also currently investigating a general solution for this TO_NATIVE issues.

@eregon
Copy link

eregon commented Nov 6, 2018

nio4r seems to have a pure-Ruby backend https://github.com/socketry/nio4r#supported-backends
That should work out of the box.
It looks like it can be used by setting NIO4R_PURE=true: https://github.com/socketry/nio4r/blob/e84f25ede87dcba8c52c9b86aa9bfbfbff0d9a59/lib/nio.rb#L17

@ioquatix What's the trade-off of using the pure-Ruby backend instead of the C extension? Should TruffleRuby try to support the C extension or there is no much advantage and just using the pure-Ruby backend is fine?

@deepj
Copy link

deepj commented Nov 6, 2018

@ioquatix With NIO4R_PURE=true I can move futher. But falcon won't be working since it uses a forking model. So it stopped due this.

@ioquatix
Copy link
Member Author

ioquatix commented Nov 6, 2018

Can we make an extension to nio4r?

@ioquatix
Copy link
Member Author

ioquatix commented Nov 6, 2018

It already supports JRuby natively

@ioquatix
Copy link
Member Author

ioquatix commented Nov 6, 2018

You can start falcon using threaded model too.

@deepj
Copy link

deepj commented Nov 6, 2018

@ioquatix How? I couldn't find anything about like that option in Falcon's README.md

@ioquatix
Copy link
Member Author

ioquatix commented Nov 6, 2018

—help and —threaded

@deepj
Copy link

deepj commented Nov 6, 2018

I could move, it seems no issue from async gems perspective so far but I got this
socketry/falcon#33

@ioquatix
Copy link
Member Author

ioquatix commented Nov 6, 2018

screen shot 2018-11-07 at 10 13 35 am

Okay, it's working, I just release falcon v0.19.3

@eregon
Copy link

eregon commented Nov 9, 2018

@ioquatix Thank you for trying and filing the issues!
They seem relatively small problems, and so should be easy to fix :)

@ioquatix
Copy link
Member Author

ioquatix commented Nov 9, 2018

Please fix them and I will try again @eregon :)

@ioquatix
Copy link
Member Author

@eregon I was just following up on this and noticed travis is broken again.

https://travis-ci.org/socketry/async/jobs/473835428

Is this something we can fix?

@eregon
Copy link

eregon commented Dec 31, 2018

It's caused by https://travis-ci.community/t/new-gpg-key-for-rvm-releases/1521.
It's an issue between RVM and TravisCI, I cannot do much about it unfortunately.

@ioquatix
Copy link
Member Author

rvm/rvm#4561 is tracking the issue on RVM.

@ioquatix
Copy link
Member Author

Currently TruffleRuby is mostly failing because of #37

@ioquatix
Copy link
Member Author

ioquatix commented Jun 7, 2019

All tests are now passing with TruffleRuby.

@ioquatix ioquatix closed this as completed Jun 7, 2019
@picatz
Copy link
Contributor

picatz commented Jun 7, 2019

That's awesome @ioquatix 👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants