Get the latest tech news

Unlocking Ractors: Object_id


In a previous post about ractors, I explained why I think it’s really unlikely you’d ever be able to run an entire application inside a ractor, but that they could still be situationally very useful to move CPU-bound work out of the main thread, and to unlock some parallel algorithm.

This still isn’t perfect though, as the benchmark uses 5 ractors, hence in an ideal world should be almost 5 times faster then the single-threaded example, so we still have a lot of work to do to eliminate or reduce the remaining contention points. In addition, accessing the object_id now requires doing a hash lookup, when before it was a simple division, and whenever the GC frees or moves an object that has an ID, it needs to update these two hash-tables. Well first, given that ObjectSpace._id2ref is very rarely used, and will likely be marked as deprecated soon, we can start by optimistically not creating nor updating the id -> object table until someone needs it, which hopefully won’t be the case in the vast majority of programs:

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Unlocking Ractors

Unlocking Ractors