Friday, January 9, 2009

Reia and object-aware concurrency

Concurrency is perhaps the foremost issue today's programmers must learn to cope with. CPU designers have exhausted the level of optimization they can provide to programmers working with a single thread of execution, and more modern designs take transistors which would've ordinarily gone to improve sequential performance and have instead thrown it at more cores. Intel demoed a CPU with 80 cores, yet one third of the transistors seen in a Core 2 Duo. This is the future of processors: more cores that do less. CPU designers are going to devote fewer transistors to each individual core while trying to pack more and more cores onto a single chip. Some crazy people are predicting that the number of CPU cores we see on a single chip is going to grow exponentially. I don't know about that, but it's a reasonable enough guess as any at this point, and it seems like it's where the trends are going.

This is posing a big problem for programmers. Now that all of these cores are available, how do you write programs that can make use of them all? The typical way most programmers are used to dealing with this problem is with threads. Threads let you spread your program's execution across multiple CPU cores, which is great! But threads are error-prone. The synchronization is as hard to get right as manual memory management. Pay attention and use good strategies and it's manageable. Put it in the hands of mediocre programmers and things can quickly fall apart. And once they do it can be incredibly hard to debug.

But it gets worse. Let's assume you've managed to use threads correctly in your program. Great! How well can it scale across an increasing number of CPU cores? The synchronization model employed by most programs uses a locking mechanism to synchronize state. To get a threaded program to scale well, locks must be scrutinized, benchmarked, and made increasingly granular in order for threaded programs to scale well. While this is all well and doable, granular locking is complicated, and the reality is most programs trying to pull it off aren't going to do it right, and for that reason many programmers may avoid it entirely.

So how well will programmers be able to leverage these new multicore CPUs? That question remains up in the air. Threaded approaches are difficult at best, and often hard to scale across an increasing number of CPU cores, especially when complex data structures are involved. For that reason some perceive that programmers are in a sort of crisis in regard to how they will leverage an increasing number of CPU cores.

Some solutions to this problem have emerged. One that gets a lot of attention is software transactional memory. This is a model which looks at memory in a manner similar to a database, using transactions to control concurrent access to shared state. Unfortunately this model has failed to achieve widespread popularity. Theories abound as to what exactly the problem is, generally surrounding its difficulty to apply to real-world problems. So far, this approach to concurrency remains in the collective unconscious as a theoretical one which is rarely applied.

Another approach which has received a considerable amount of hype in certain communities is "Erlang style-concurrency." Erlang is a programming language originally developed for telephony applications which uses lots of small processes that each do one thing and do it well, and talk to each other over message queues. Some liken this to the Unix philosophy: "Write programs that do one thing and do it well. Write programs to work together." However the actual approach of using processes which communicate with messages is known as the Actor model which grew out of Smalltalk.

Erlang processes have lots of nice properties which make concurrency easy. Like OS processes they run simultaneously and the Erlang runtime can distribute them across all available CPU cores with no additional work on the programmer's part. They are pre-emptable: if a process is doing something computationally intensive then after a certain number of "reductions" (e.g. function calls) the Erlang scheduler will pre-empt it and let another process to run. Erlang processes don't share state and can be garbage collected independent of one another. This means there's no "stop the world" condition with the garbage collector. But also, by not sharing state synchronization gets much easier. Now you don't have to synchronize access to shared state, instead you need to synchronize the way your program behaves, which is a far easier problem.

Last year I began working on an Actor model implementation for Ruby called Revactor. It had many of the features seen in Erlang: concurrent "processes" with message boxes and the ability to selectively receive messages from them. However, two things deferred me from continuing to work on Revactor: first, it was slow. Its messaging speed between two processes was nearly two orders of magnitude slower than Erlang, as was the process creation speed. Second, and probably the larger issue, was how much overlap I felt existed between Actors and objects. Actors did many of the same things objects did, but actors and objects did not play well together.

After seeing how much slower Actors in Ruby worked compared to Erlang, I decided to try a different approach entirely. If Actors couldn't come to Ruby, perhaps I could try bringing Ruby to Erlang. In early 2008 I started tinkering with a Ruby-like language on top of Erlang called Reia. Reia brings with it an object model which works on top of the Erlang process and messaging model. Like other object models objects in Reia communicate with messages, but rather than being some metaphorical construct, Reia objects quite literally communicate with messages.

This approach marks a rapid departure from most other object oriented languages. Most object oriented languages have a concurrency primitive like threads which are completely divorced from objects. Threads give you no guarantees about how state is managed or synchronized, and threads have no knowledge of method invocation. In Reia, all objects are concurrent and synchronize around the method dispatch protocol. You can think of each object as being its own thread, except each object's state is independent of all of the others, so there's no need for semaphores or mutexes or critical sections. All synchronization is handled through message dispatch itself, and thanks to the shared-nothing process architecture you only need to worry about synchronizing behavior, not state.

Furthermore, Reia gives you deep hooks into the method dispatch process, allowing objects to asynchronously respond to method calls, to invoke methods asynchronously, or to asynchronously get the response of a method call. This small grab bag of asynchronous tricks allows you to quickly and easily begin adding concurrency into your programs while still preserving the traditional method dispatch approach seen in object oriented languages.

Will this object-aware approach to concurrency and synchronization actually gain traction with programmers? It's hard to say, however it's clear that the other approaches aren't doing so well either. With the number of cores available to programmers skyrocketing, I think it's clear solutions are needed. Only time will tell which ones are actually successful.

146 comments:

Pichi said...

I don't understand one thing. When you use processes for objects implementation, how you garbage collect those. When one object can have some another object as attribute there are two processes, thus when I send inner object reference as PID to somewhere, store in ets or whatever. Then destroy outer object. How you make decide to destroy inner object? Or you don't garbage collect at all or what you decide to do?

Mark Lee Smith said...

You might want to check where the actor model came from; it certainly didn't grow out of Smalltalk as there's evidence for it's existence well before Smalltalk :).

Prateek Barn said...

avriq
avriq India

mariablack said...

Pc Optimization
Windows Installation
Data Recovery

shabnam praveen said...

Call girls in Kolkata
Call girls in Chandigarh
Call girls in Chandigarh
Call girls in Gurgaon
Call girls in Chandigarh
Call girls in Chandigarh

shabnam praveen said...

Call girls in Lucknow
Call girls in Guwahati
Call girls in Mumbai
Call girls in Jaipur
Call girls in Jaipur
Call girls in Jaipur
Call girls in Bangalore

Anonymous said...

voice changer apps for android

Cityexplore said...

Nice This Article is very Good and helpful to everypeople

simpleshopping said...

Great Information about Reia and object-aware concurrency.This Post is very useful to every people

windowspcsecrets said...

Your Post is very helpful to every people and great information

Unknown said...

very nice information about this article ,Also Read ,Here

kawinha said...

goldenslot
โกลเด้นสล็อต
สล็อตออนไลน์

Infocampus said...

selenium training in Bangalore
selenium courses in Bangalore
selenium training in Marathahalli
selenium training institute in bangalore


best web development training in Bangalore
web development course in bangalore
best web development training in Bangalore
web development training in Marathahalli

techbindhu

Unknown said...

Quite an informative blog. Best Download Obb data for free now to get an application running in your android phone, Now it's easy to download and also secure for your no crack and spam. Just try downloading it and running it to your android phone and play whatever games you like free without any hassle.

unknown said...

90minup ข่าวกีฬา ฟุตบอล ผลบอล วิเคราะห์บอล พรีเมียร์ลีก ฟุตบอลไทย
ข่าวกีฬา
ข่าวฟุตบอล
ฟุตบอลไทย
ฟุตบอล
วิเคราะห์บอล
ผลบอล

IPL Score said...

Best informative blog.Read

iploverview said...

if you know about getmyoffer capitalone and best deals

Cellularnetin said...

Very helpfull blog.Here

iploverview said...

Nice This post is very useful to every person,Thank You

iplfixtures said...

Thank You For Sharing your article .This post is really amazing and helpful my Team

ipl said...

Great informative idea about this post.ipl Live streaming

FoxX Project Copr said...

คลิก>>> gclub
คลิก>>> จีคลับ
คลิก>>> gclub casino
คลิก>>> คาสิโนออนไลน์
คลิก>>> สล็อตออนไลน์

blog said...

ที่พักเกาะล้าน ที่พักเกาะล้าน เกาะสวยน้ำใสใกล้กรุงเทพแห่งนี้ คือ ที่เที่ยวยอดฮิตของนักท่องเที่ยวจากทั่วทุกสารทิศ
และแน่นอนว่าบนเกาะล้านแห่งนี้นั้นยังมี ที่พักเกาะล้าน สวยๆ ไว้ให้บริการอีกมากมาย treetep.com


สมัครใช้งาน Gmail
บ้านโมเดิร์น
บ้านและการตกแต่ง
เครื่องชงกาแฟสด

Pankaj Singh said...

Much thanks to you so much imparting this useful blog to us. Get Website Dresigning and Development Services by the best Website Designing Company in Delhi, ogen infosystem.
SEO Service in Delhi

Mutual Fundwala said...

Nice blog, visit for the best Mutual Fund advice about the best mutual fund companies in delhi, India by Mutual Fund Wala.
Mutual Fund Agent

for ict 99 said...

Great Article
Cyber Security Projects for CSE Students


JavaScript Training in Chennai



Project Centers in Chennai




JavaScript Training in Chennai

John smith said...

norton.com/setup - If you are not using an antivirus on your system, then you are undoubtedly more prone to get malicious programs infected on your PC. Norton provides world’s best antivirus programs that can prevent harmful malware and viruses from infecting your system. Majority of the virus a user receives is from careless online activities. Browsing online and going through social media without any protection is a sure way to get malware on your system. With features like real-time protection, online web security, and email blocking Norton provides the ultimate protection to your system. You can avail the esteemed protection of Norton antivirus on norton.com/setup. Visit the site to download, install, and activate your Norton setup.Readers Bay

Just Info said...

Amazing blog, thanks for sharing with us. Get the best Food Truck Branding and Vinyl Signage Printing Services in Delhi, India at Kalakutir Pvt Ltd.
Vinyl Signage Printing Services

salma said...

نقل عفش من الدمام الى جدة نقل عفش من الدمام الى جدة
شحن عفش من جدة الى الاردن شحن عفش من جدة الى الاردن
نقل عفش من الدمام الى الاحساء نقل عفش من الدمام الى الاحساء


شحن عفش من الدمام لمصر شحن عفش من الدمام لمصر

myslot said...

เล่นจริงแจกจริงต้องสล็อต xo เท่านั้น สนุกได้ทุกวันกับสล็อตออนไลน์ ลองเลย

https://www.slot4u.com/slotxo

Lili Jonath said...
This comment has been removed by the author.
Lili Jonath said...

Permainan slot yang paling banyak diminati oleh semua orang, tentunya disitus kami dengan permainan slot terlengkap, pastinya akan membuat kalian betah permainan slot apa yang kalian dulu mainkan tentunya akan ada disini. silahkan kunjungi situs kami


download vivo apk

aplikasi slot vivo

download aplikasi vivo

download aplikasi slot vivo

aplikasi vivo android

aplikasi vivo ios

apk slot vivo

Sachin Yadav said...

You can find the latest stuff Fake Indian Mobile Number

Fun said...

Call girl in saket
call girls in saket
call girl saket
call girls saket
escort in saket
escorts in saket
escort saket
escorts saket
saket call girl
saket call girls
saket escort
saket escorts

BestTrainingMumbai said...

Your article is amazingly richly made. This is unprecedented edifying substance from my viewpoint. You in like manner offer various honorable expressions with persuading, one regarding a caring substance.
SAP training in Kolkata
Best SAP training in Kolkata
SAP training institute in Kolkata

Anirban Ghosh said...

Your article is incredibly lavishly made. This is uncommon enlightening substance from my perspective.
SAP training in Mumbai
Best SAP training in Mumbai
SAP training institute Mumbai

Anirban Ghosh said...

You in like way offer different fair articulations with convincing, one in regards to a mindful substance.
SAP training in Mumbai
Data Science training in Mumbai
Best data science training in Mumbai

Caleb said...

Top 10 Lists – One Place To Find Best Information In Form Of Top 10, It Also Includes Good Knowledge Information And You Can Download Pc Games Too.
Top 10 Lists
Social Bookmarking Sites List
Rabbit Alternatives
Image Submission Sites
Video Submission Sites

https://top10listss.com/
https://top10listss.com/social-bookmarking-sites-list/
https://top10listss.com/rabbit-alternatives/
https://top10listss.com/image-submission-sites/
https://top10listss.com/video-submission-sites/

Social Bookmarking Sites List
Rabbit Alternatives
Image Submission Sites
Video Submission Sites

cncoboy said...

I really love your article and thanks for sharing these resources.
Best 27 Inch PC Monitor

Field engineer said...

Hi,

Freelance IP Network Engineer
IP networks must function in a stable and reliable manner, and that is where IP network engineers intervene. They can maintain the network, as well as supervise the work, such as updating and modifying the IP network, since it needs to grow and expand over time. They can help with problem solving and handle changes in the network as new services and additional tasks are required.The global reach offered by FieldEngineer.com allows you to find the right engineers and professionals where you need them. We know that companies often need to perform work in different locations and that is possible thanks to our platform.

Freelance Marketplace said...

Network Security Assessment and its Benefits

A security risk assessment should be part of your standard cybersecurity practice. An assessment will detect all of the potential risks that threaten your business, outline how to protect your company, and the implementation to keep your business secure.

CloudLearn ERP said...

I would like to thank you for getting my neurons conspicuous with this brilliant article that you have written which contains every potential points which needs to considered on the given topic. Thanks for chipping in such a brilliant writing!
Data Science training in Mumbai
Data Science course in Mumbai
SAP training in Mumbai

fitndiets said...

height increase exercise at any age by doing these simple exercises and workout. Become taller in 1 week. Jumping jack exercise at home to increase height.

Unknown said...

pg slot true wallet

Unknown said...

slotxo true wallet

Unknown said...

slotxo true wallet

slot said...

this game is good สมัครpg
this game is good joker123
this game is good pg slot ทดลองเล่น
this game is good pg auto
this game is good joker gaming
this game is good pgslot

Unknown said...

Very Goog Game Pgslotแจกเครดิตฟรี

Very Goog Game Pgslotแตกง่าย

Very Goog Game Pgslotแตกดี

Very Goog Game Pgslotแตกโหด

Unknown said...

สล็อตjoker สล็อตxo lucky panda แพนด้าทองมาเต็มจอ แตก!! 16,000+

Unknown said...

Very Good Game Pgslotแจกเครดิตฟรี

Very Good Game Pgslotแจกสูตรสล็อต

Very Good Game Pgslotแจกสูตรทำเงิน

Very Good Game Pgslotแจกสูตรเข้าโบนัส

Very Good Game Pgslotแจกสูตรแตกดี

Unknown said...

สล็อตPG PGSLOT Secrets of Cleopatra ซื้อฟีเจอร์ 150 เบทต่ำสุดใน PG ได้ตัวคูณถึง 77 เท่า!!

Unknown said...

สล็อตPG PGSLOT เกม Secret of Cleopatra ซื้อฟีเจอร์300 ได้มา20ฟรีสปิน!!! เห้ยยยยย

Unknown said...

Very Good Game Pgslotแจกเครดิตฟรี

Very Good Game Pgslotแจกสูตรสล็อต

Very Good Game Pgslotแจกเทคนิคทำกำไร

Very Good Game Pgslotสูตรทุนน้อย

Very Good Game Pgslotแจกสูตรแตกยับ

Unknown said...

สล็อตPG PGSLOT treasure of aztec แตกเยอะจนนึกว่าแจกฟรี

Unknown said...

สล็อตPG PGSLOT Dreams of macau กดเองไม่ซื้อฟีเจอร์ เกมฮิต เกมยอดนิยมในPG แตกยับๆ

Unknown said...

Dafabet : Safari Gold ซื้อโบนัสเกม 1000บาท แตกโคตรโหด เกมโคตรมันส์ กำไรโคตรดี!!!

Unknown said...

Very Good Game แจกเครดิตสล็อตpg

Very Good Game แจกเครดิตสล็อตpg

Very Good Game แจกเครดิตสล็อตpg

Very Good Game สูตรPgslot

Very Good Game สูตรPgslot

Unknown said...

Good Game ufabetแจกเครดิต

Good Game ufabetสล็อตทำเงิน

Good Game ufabetแจกเครดิต

Good Game ufabetสล็อตทำเงิน

Good Game ufabetแจกเครดิต

Unknown said...

Goog Game สล็อตufa

Goog Game สล็อตufa

Goog Game สล็อตufa

Goog Game สล็อตufabet

Goog Game สล็อตufabet

Unknown said...

Good game pg slot game

Good game pg slot game

Good game pg slot auto

Good game pg slot auto

Unknown said...

Slot Game SUPERSLOT

Slot Game SLOT

Slot Game SLOTPG

Unknown said...

superslot
pg auto
joker
sexygame
jokergames
สล็อต ทุกค่ายเกม

Unknown said...

Funny Game SUPERSLOT

Slot Game SLOT

Good Game SLOTPG

Unknown said...

Very Good Game superslot

Very Good Game สล็อตpg

Unknown said...

I think it is very helpful. And thought that it could be applied as well pgslot
I think it is very helpful. And thought that it could be applied as well joker gameing
I think it is very helpful. And thought that it could be applied as well pgslot
I think it is very helpful. And thought that it could be applied as well sexygame
I think it is very helpful. And thought that it could be applied as well amp poker

tiger said...

good game superslot

Unknown said...


Get free bonus 100%.New online slots game Online slot betting

this game is good SUPER SLOT

this game is good PGSLOT

Difuku sola said...

JOKER GAMING
PGSLOT
JOKER SLOT
SLOT1234

Unknown said...

Slot Game SLOT

Unknown said...

Good game ซุปเปอร์สล็อต

Unknown said...

Funny Game Click Here! SUPERSLOT

Unknown said...

good game สล็อต PG แจกสูตรฟรีสปิน รับรองว่าเด็ด

Unknown said...

Slot Game SLOTPG

Unknown said...

Slot Game Click Here! SLOT

Unknown said...

Funny Game Click Here! SUPERSLOT

Unknown said...

Good game SUPER SLOT สูตรแตกง่าย เพิ่มเติม

Unknown said...

Get free bonus 100%
New online slots game Online slot betting
This game is very good pg game slot ดูเพิ่มเติม

Unknown said...

good game สล็อตxo สล็อตแจกเครดิตฟรี

tiger said...

Great blog content good game ซื้อฟรีสปินpg

Unknown said...

slothttps://pgslot-game.com

Unknown said...

สล็อตhttps://superslot.game/

Unknown said...

slotwww.slotxocasino.net

Unknown said...

sexygame1688https://www.sexygame.game/

Unknown said...

แจกเครดิตฟรีhttp://superslot.games

Unknown said...

good job superslot สล็อตออนไลน์ที่ดีที่สุด

Unknown said...

good job superslot เกมสล็อตยอดฮิต

Unknown said...


slothttps://pgslot-game.com

Unknown said...

สล็อตhttps://superslot.game/

Unknown said...

slotwww.slotxocasino.net

Unknown said...

sexygame1688https://www.sexygame.game/

Unknown said...

แจกเครดิตฟรีhttp://superslot.games

Unknown said...

good game ซุปเปอร์สล็อต สล็อตทุนน้อยแตกโหด สนใจคลิ๊ก

Unknown said...

Funny Game Click Here! SUPERSLOT

Unknown said...

Slot Game CLICK HERE!

Unknown said...

good job สล็อตPG เกมสล็อตฟรีสปินโหด เพิ่มเติมคลิ๊ก

Unknown said...

Very Good Job pg slot ฟรีเครดิต 50 ดูเพิ่มเติม

Unknown said...

good job สล็อตjoker เกมใหม่แตกดี สนใจคลิ๊ก

Unknown said...

Funny Game Click Here! SUPERSLOT

Unknown said...

Slot Game สล็อตPG

Unknown said...

Very Good Job สูตรสล็อตฟรี2020 ดูเพิ่มเติม

Unknown said...

Slot Game CLICK HERE!

Unknown said...

Funny Game Click Here! SUPERSLOT

Unknown said...

good job สล็อตjoker สล็อตยอดฮิต เพิ่มเติม

Unknown said...

Very Good Job superslot ฟรี50 ดูเพิ่มเติม

Unknown said...

good job ซุปเปอร์สล็อต รีวิวเกมใหม่โคตรดี เล่นเกมคลิ๊ก

Unknown said...

good job สล็อตPG เกมใหม่แตกดี ดูเพิ่มเติมคลิ๊ก

Unknown said...

Very Good Job SLOT ฟรีเครดิต ไม่ต้องฝาก ดูเพิ่มเติม

Unknown said...

very good superslot รีวิวสล็อตเกมดัง เล่นเกมคลิ๊ก

Unknown said...

Very Good Job super slot เครดิตฟรี 50 ดูเพิ่มเติม

Unknown said...

good job PGสล็อต สล็อตซื้อฟรีสปิน ดูเพิ่มเติม

Unknown said...

Very Good Job สล็อตpg เครดิตฟรี ดูเพิ่มเติม

Unknown said...

good game ซุปเปอร์สล็อต เเกมสล็อตแตกเร็ว คลิ๊ก

Unknown said...

Very Good Job pg slot แตกง่าย คลิกดูเพิ่มเติม

Unknown said...

very good Slotxocasino สมัครรับโบนัส 100% คลิ๊ก

Unknown said...

Very Good Job
PG SLOT superslot โปร50 คลิกเล่นเกม

Unknown said...

Very Good Job superslot โปร50 คลิกเล่นเกม

Unknown said...

Very Good Job สล็อตpg ฝาก100 รับ100 คลิกเล่นเกม

Unknown said...

very good PGสล็อต แปะนอนเกมฮิตแตกง่าย ดูเพิ่มเติม

Unknown said...

good job ซุปเปอร์สล็อต ทุนน้อยแตกยับ ดูเพิ่มเติม

Unknown said...

Very Good Job สล็อตpg โปร100% คลิกเล่นเกม

Unknown said...

good game สล็อตPG เวลานี้ต้องเกมจินนี่ ดูเพิ่มเติม

Unknown said...

good job สล็อตPG ทุน300แตกหมื่น ดูเพิ่มเติม

Unknown said...

new game ทางเข้า pg slot auto

Unknown said...

Very Good Job ซุปเปอร์สล็อต แจกหนัก คลิกเล่นเกม

Unknown said...

very good เกมใหม่ล่าสุด PGSLOT สนใจคลิ๊ก

Unknown said...

Very Good Game พีจีสล็อต แจกสูตรสล็อต สนใจคลิ๊ก

Unknown said...

good game PGSLOT แจกสูตรสล็อตแปะนอน คลิ๊ก

Unknown said...

Very Good Job ซุปเปอร์สล็อตแจกฟรี สนใจคลิก

Unknown said...

http://pgslot-game.comhttps://pgslot-game.com

Unknown said...

https://www.superslot.gamehttps://superslot.game/

Unknown said...

slotwww.slotxocasino.net

Unknown said...

good job สล็อตpg ทุนเยอะเบทสูง ดูคลิ๊ก

office.com/setup said...

Hоw dо ореn-ѕоurсе рrоduсtіvіtу ѕuіtеѕ compare tо MS Office - аnd dоеѕ іt mаkе ѕеnѕе fоr уоur оrgаnіzаtіоn tо сhооѕе frее соmmunіtу software rаthеr thаn Microsoft's commercially licensed оffеrіng? www.office.com/setup www.office.com/setup

Unknown said...

Very Good game pg slot โปรโมชั่น100% สนใจคลิก

Unknown said...

Very Good Job pgslot สมัครใหม่โปร100 สนใจคลิก

Unknown said...

very good สล็อตpg เกมแตกดี ดูเพิ่มเติม

Unknown said...

slot betting Get free bonus 100%
Very good game. pgslot auto ดูเพิ่มเติม

Unknown said...

very good game สล็อตpg รับโบนัส100% คลิ๊ก

Unknown said...

Very Good Job สล็อตPG เกมใหม่ Fortune Ox สนใจคลิก

Unknown said...

good job สล็อตPG แจกเทคนิคเกมคลีโอ คลิ๊ก

Unknown said...

very good สล็อตPG แจกเเครดิตฟรี คลิก

Unknown said...

slotwww.slotxocasino.net

Unknown said...

slotxowww.slotxocasino.net/

Unknown said...

สมัครslotxowww.slotxocasino.net

Unknown said...

วอลเล็ตสล็อตhttps://slotxocasino.net/วอลเล็ทสล็อต

Unknown said...

สล็อตทุกค่ายเกมwww.slotxocasino.net