News for hackers. Stuff that matters.
Re:Ruby 3, Concurrency and the Ecosystem by gameswithgo on Friday January 08, 2021 @09:08PM (#25695370)
I don't understand bolting concurrency onto something that is interpreted. A compiler would get you 10-100x speedup, without your users having to do the complex thing of writing safe parallel code.
Re:Ruby 3, Concurrency and the Ecosystem by ramchip on Saturday January 09, 2021 @05:17AM (#25699152)
A lot of web services do a little bit of work, wait on a DB query, do a little bit of work, wait on DB, etc. It’s even more true with websockets, which spend most of their time idle waiting for messages.

Good concurrency support lets you handle thousands (even millions) of these activities in a single process, which is massively more efficient than using a process each, and puts less load on other systems (DB, Splunk, Graphite, RabbitMQ…)

Green threads in particular make it possible to get these benefits without writing the code in async style. You just write regular, blocking code and the runtime / frameworks take care of yielding to the scheduler (event loop) when appropriate.

Re:Ruby 3, Concurrency and the Ecosystem by chubot on Friday January 08, 2021 @11:04PM (#25696736)
Ruby can’t be compiled easily due to the very dynamic semantics of the language. If you wanted to compile it, it would probably start behaving a lot more like Crystal, which looks similar but behaves completely differently.
Re:Ruby 3, Concurrency and the Ecosystem by pjmlp on Saturday January 09, 2021 @03:57AM (#25698759)
SELF, Smalltalk beg to differ in what concerns JIT compilation.
Re:Ruby 3, Concurrency and the Ecosystem by riffraff on Saturday January 09, 2021 @06:39AM (#25699566)
worth noting that there has been a ruby-on-smalltalk-vm-technology implementation for more than ten years, but it didn't catch on

http://maglev.github.io/

Re:Ruby 3, Concurrency and the Ecosystem by pjmlp on Saturday January 09, 2021 @08:47AM (#25700282)
Well, "To run MagLev you’ll also need a GemStone/S Server.".

So did it run Rails?

Re:Ruby 3, Concurrency and the Ecosystem by jashmatthews on Friday January 08, 2021 @11:33PM (#25697035)
If you're talking about just compilation then it's easy enough doing something like context-threading where you translate bytecode into a call instruction per operation to a function implementing the bytecode.

If you're talking about producing a static binary then both Rubymotion and TruffleRuby can do this.

Re:Ruby 3, Concurrency and the Ecosystem by FooBarWidget on Saturday January 09, 2021 @02:48AM (#25698465)
> If you're talking about just compilation then it's easy enough doing something like context-threading where you translate bytecode into a call instruction per operation to a function implementing the bytecode.

Ruby has already been doing threaded dispatch on bytecodes since 1.9.

Re:Ruby 3, Concurrency and the Ecosystem by jashmatthews on Saturday January 09, 2021 @04:01AM (#25698778)
Context-threading is a JIT technique. CRuby can optionally use call-threading where each op is a function and dispatch is an infinite loop of function calls. It's not the default since direct or token threading are faster but it's there.

Call-threading looks like this:

  while(1) { interpreter_state = *virtual_program_counter++(interpreter_state); }
There's an indirect jump here.

With context-threading you JIT very simple code which looks like this and has only direct calls:

  interpreter_state = put1(interpreter_state);
  interpreter_state = put1(interpreter_state);
  interpreter_state = plus(interpreter_state);
Re:Ruby 3, Concurrency and the Ecosystem by chubot on Saturday January 09, 2021 @12:03AM (#25697308)
I should have clarified that I meant "compiled easily for 10-100x speedup" (on representative workloads) as the OP was saying.

You can definitely compile anything... whether it's worthwhile is a totally different story. I learned this the hard way :)

As far as I remember the Ruby 3x3 effort yielded 3x on SOME workloads, with tremendous effort, which is about what I would have expected due to Ruby's very dynamic semantics.

Re:Ruby 3, Concurrency and the Ecosystem by jashmatthews on Saturday January 09, 2021 @01:46AM (#25698079)
TruffleRuby already has that kind of performance increase on microbenchmarks.

The CRuby JIT for 3x3 built by one person in their spare time.

Re:Ruby 3, Concurrency and the Ecosystem by gameswithgo on Friday January 08, 2021 @11:18PM (#25696881)
you could aot compile most of most programs and jit the rest. or just jit everything
Re:Ruby 3, Concurrency and the Ecosystem by jashmatthews on Friday January 08, 2021 @09:53PM (#25695814)
CRuby has had JIT for over 3 years now and I think JRuby must be over a decade?
Re:Ruby 3, Concurrency and the Ecosystem by gameswithgo on Friday January 08, 2021 @09:55PM (#25695836)
are those first class options now? or is it like python where you can kinda sorta sometimes use a jit?
Re:Ruby 3, Concurrency and the Ecosystem by jashmatthews on Friday January 08, 2021 @11:38PM (#25697081)
First class option in Ruby 2.6 onwards.
Re:Ruby 3, Concurrency and the Ecosystem by pjmlp on Saturday January 09, 2021 @04:00AM (#25698777)
Yeah, but not that impressive in capabilities, hence other projects.

https://developers.redhat.com/blog/2020/01/20/mir-a-lightwei...

Re:Ruby 3, Concurrency and the Ecosystem by jashmatthews on Saturday January 09, 2021 @04:18AM (#25698849)
While MIR could be an interesting alternative to CraneLift it doesn't really address the challenges faced by trying to improve performance via JIT compilation within CRuby.