r/ruby • • 2d ago

Question GVL and concurrent programming

Ruby cannot perform real concurrent processing on multicore microprocessors without using ractors because of the GVL. It will only simulate multiple simultaneous processes with threads, queues, mutexes, etc. in a single processor core, no true parallel processing. How does this limitation affect true parallel programming in Ruby, that is, how much more complicated is it in producing true multicore parallel programming? I am still working on learning Ruby and this is part of my self-inflicted learning process in parallel with Huw Collingworth Book of Ruby.

10 Upvotes

27 comments sorted by

View all comments

Show parent comment

3

u/azimux 2d ago

Hi! I was trying to answer this question in your post:

How does this limitation affect true parallel programming in Ruby, that is, how much more complicated is it in producing true multicore parallel programming?

I suppose there might be confusion in the intent behind my answer or your intent posing the question. To recap my answer to my porentially wrong understanding of your question: it's not that complex for me. It is rare that it comes up but when it does I use separate processes, JRuby, or preemptively compute the data if I can instead of on-demand. I'd also be fine using Ractors for this purpose personally, though they are experimental.

But yeah whoops if we're talking past each other. Hope you're having fun learning concurrency/Ruby!

1

u/Edthal01 2d ago

Ah, clarity. Intellectual curiosity on my part, pragmatic experience on yours.