News for hackers. Stuff that matters.
Re:Proposal of a new concurrency model for Ruby 3 [pdf] by chrisseaton on Thursday September 08, 2016 @04:06AM (#12451132)
> The slides say that an exception is thrown if an object of a different guild is accessed, but doesn't that mean that Ruby needs to check the guild at every object access?

Ruby is already checking the class of the object on every access. You could combine the guild and the class into a tuple and compare against that instead, so it adds no extra overhead.

There is a paper at OOPSLA this year on doing just that http://2016.splashcon.org/event/splash-2016-oopsla-efficient...

Re:Proposal of a new concurrency model for Ruby 3 [pdf] by aardvark179 on Thursday September 08, 2016 @08:51AM (#12452454)
I can't comment on that paper since it doesn't appear to be available publicly yet, so I'm just going to talk about guilds as proposed.

Adding a guild word to each object header is certainly a way to check ownership, and should be a cheap check to perform in the interpreter, but will obviously add some extra overhead to standard program execution.

The thing that concerns me is that explicit ownership passing can introduce as many bugs as it solves. If I have two objects A and B, with A holding a reference to B, then I can freeze A and freely pass it between guilds, but if I try and touch B I'll get an error until that too has been frozen or its ownership transferred. The same problems occurs with explicit ownership transfer of a non-frozen A, which leaves you with the slower option of a deep-copy or a recursive ownership transfer which can have equally unexpected consequences.

The "Ruby global data" slide also gives me the scream heebie-jeebies, as did finding stack overflow answers on how to unfreeze objects in MRI. I'm sure nothing will go wrong. :-)

Having said all that, it probably can work nicely for the common use cases of balancing requests between a group of worker guilds where the request is a simple data structure whose ownership can be safely transferred, but it would be hard to do a general work stealing solution that was always safe.

Re:Proposal of a new concurrency model for Ruby 3 [pdf] by parenthephobia on Thursday September 08, 2016 @07:25PM (#12458361)
> Adding a guild word to each object header is certainly a way to check ownership, and should be a cheap check to perform in the interpreter, but will obviously add some extra overhead to standard program execution

It needn't be done this way. When an object is invalidated it could have its class pointer sneakily changed into a special "invalid object" class. Any attempt to do anything concrete with the object would be rebuffed, but normal object accesses wouldn't be changed.

> The thing that concerns me is that explicit ownership passing can introduce as many bugs as it solves. If I have two objects A and B, with A holding a reference to B, then I can freeze A and freely pass it between guilds, but if I try and touch B I'll get an error until that too has been frozen or its ownership transferred.

At least you get an error. Ultimately, the only alternative with comparable performance is sharing mutable references. That avoids this specific problem but is open to the full assortment of problems that can occur with concurrent mutable state, many of which aren't automatically detectable in principle.

> The "Ruby global data" slide also gives me the scream heebie-jeebies, as did finding stack overflow answers on how to unfreeze objects in MRI. I'm sure nothing will go wrong. :-)

If this proposal is adopted it's a simple matter to prohibit unfreezing objects that have been shared. :)

Not that it would really be necessarily. If you're reaching into MRI's internals to unfreeze an object, then it's up to you to make sure that things don't break.

Re:Proposal of a new concurrency model for Ruby 3 [pdf] by Roboprog on Thursday September 08, 2016 @12:03PM (#12454236)
Things might generate an error, but they shouldn't just quietly munge stuff. God knows how many times I've had to clean up Java servlet stuff that cross-talked between threads. Yuck.

I really hope they make this work in Ruby 3. If you program in a "functional" style anyway, this approach ("relaxed Erlang" style messaging) should fit nicely, as you would not be mutating things willy-nilly anyway. Of course, FP practices are a hard sell to the "OOP is the one true abstraction" (COBOL with encapsulated DATA DIVISIONSs) crowd.

Re:Proposal of a new concurrency model for Ruby 3 [pdf] by chrisseaton on Thursday September 08, 2016 @08:55AM (#12452484)
If you want to read the paper now I'm sure the authors will email you a draft.
Re:Proposal of a new concurrency model for Ruby 3 [pdf] by VeejayRampay on Thursday September 08, 2016 @05:47AM (#12451556)
Hi Chris, you've mentioned that you didn't like discussing design choices made or attempted to be made in Ruby in the past, preferring to focus on the technical side of implementing the language, so no worries if you don't want to weigh in on this, but how do you feel about this proposal in general, in terms of feasibility and upside/downside of the technique described?
Re:Proposal of a new concurrency model for Ruby 3 [pdf] by chrisseaton on Thursday September 08, 2016 @08:11AM (#12452221)
Yes I think it looks like a very sensible way forward. It will let the VM share and optimise a lot behind the scenes but provide the illusion of clean isolation between the parallel guilds.
Re:Proposal of a new concurrency model for Ruby 3 [pdf] by VeejayRampay on Thursday September 08, 2016 @09:46AM (#12452921)
Glad to hear it. And thanks for all the hard work on the language I use every day.
Re:Proposal of a new concurrency model for Ruby 3 [pdf] by Roboprog on Thursday September 08, 2016 @11:57AM (#12454190)
Hmm. I was under the impression that when you transferred the membership of an object, the "guild-local" or local lexical scope variable would be nulled out. Little to check if that's the case.