Weekly notes #8

On MRI parallelism & GIL + how to run a meetup.

Ruby, systems, performance, and programming links from last week.

Ruby

I spent some time reading more about parallelism and concurrency in MRI Ruby to better understand the limitations.

Fibers - Slides explaining Ruby fibers on examples (control passing via resume and Fiber.yield) and some practical applications.

Parallelism is a Myth in Ruby - an introductory post explaining the issue with global interpreter lock in MRI Ruby, the situation in Ruby 1.8 and 1.9 (multiple ‘green threads’ + one vs. multiple OS level threads + GIL) and JRuby.

Does the GIL Make Your Ruby Code Thread-Safe? - No, except for native MRI methods implemented in C, which appear as atomic to the outside world. But that assumption does not hold across Ruby implementations, does not avoid other race conditions and is a bad design anyway.

Nobody understands the GIL - This post, linked from the one above, analyses the internal implementation of Thread.new. It describes how GIL is used to protect a single thread’s execution and how a timer thread - invisible from the Ruby runtime - ensures a single thread does not hog the GIL by setting an interrupt flag periodically. The flag is then checked after the current C method executes - which hints at the atomicity.

multithreading - Multiprocessing vs Threading Python - Stack Overflow - Nice summary of pros and cons of multiprocessing and multithreading.

Articles

A great three-part post on organising a meetup (Ruby User Group Berlin), from Tobias Pfeiffer. It covers all the important aspects, from managing the online presence, whether to allow recruiters, selecting the format/venue/time and what to do before/during and after the actual meetup,

Before you start to organize a meetup

Defining the 5 basics of your meetup

Running a meetup