Changes Requested to Support Discourse on TruffleRuby

I would like to request the following 3 changes to help support running Discourse on TruffleRuby:

Change Requested
Update bin/rails to disable unicorn when fork is not supported.

Error

<internal:core> core/kernel.rb:764:in `fork': fork is not available (NotImplementedError)

Files
bin/rails

Why
TruffleRuby do not support forking.

Suggestion
Disable unicorn if !Process.respond_to?(:fork)

========================================================

Change Requested
Disable mini_profiler for TruffleRuby

Error

<internal:core> core/kernel.rb:236:in `gem_original_require': cannot load such file -- stackprof (LoadError)

Files
config/initializers/006-mini_profiler.rb

Why
Stackprof is not currently supported on TruffleRuby

Suggestion
Disable mini_profiler loading when RUBY_ENGINE is “TruffleRuby”

========================================================

Change Requested
Prevent rbtrace from loading

Similar usages already preventing rb_trace from loading:

Error
Failure/Error: require ‘rbtrace’

Suggestion
Use one of the methods in the above links to prevent loading rbtrace

Files
spec/rails_helper.rb

2 Likes

Those seem like reasonable requests.

BTW: Has anything changed about mini_racer not being supported on TruffleRuby? That’s a major blocker.

4 Likes

BTW: Has anything changed about mini_racer not being supported on TruffleRuby? That’s a major blocker.

I have a branch with most of the mini_racer functionality passing the test suite using using GraalJS for TruffleRuby. I believe it handles all of the functionality needed for Discourse. It just needs to be reviewed and I’ll then I’ll try to get it merged. This is how I’ve been running it locally: x.com

6 Likes

Correction:
Disable mini_profiler loading when RUBY_ENGINE is “truffleruby”

2 Likes

mini_profiler should still be fine, I would recommend just having us not load rbtrace / stackprof etc. There are loose dependencies.

mini_profiler can still provide plenty value in truffle world, nothing MRI specific about this.

4 Likes

Here’s a PR with the requested changes.

I still couldn’t get it to run successfully, there was a java.lang.NullPointerException, but that might be just me crudely disabling mini_racer. I’m really looking forward to seeing a fully functional Discourse running on TruffleRuby.

I didn’t look into this any further, but I noticed an error when I only disabled loading of stackprof and memory_profiler. So I completely disabled mini_profiler for now.

2022-05-04 21:48:13 +0200 Rack app ("POST /mini-profiler-resources/results" - (127.0.0.1)): #<SystemStackError: stack level too deep
        from StackOverflowCheckImpl.java:328:in `com.oracle.svm.core.graal.snippets.StackOverflowCheckImpl.newStackOverflowError0'>

It might have been a side effect of other problems. I guess we could investigate when other problems are solved.

5 Likes