Tuesday, April 6, 2010

JRuby + Coroutines = really fast

Today I did some tests to see how much, and if at all, JRuby could benefit from implementing Ruby fibers with real coroutines. I was hoping to see some improvements, and that maybe JRuby will even surpass the native Ruby implementation in fiber performance.

So I got myself the current Ruby (Ruby 1.9.1-p376) and JRuby (from git) and made up a simple program that passes messages through a number of fibers.

Running a number of tests with different parameters on Ruby and an unmodified JRuby wasn't too difficult (after realizing that -1.9 isn't the same as --1.9).
But in order to run JRuby with coroutine support I first had to hack together coroutine support for JRuby :-)
As I'm not familiar with the JRuby code I had to dive around a bit. Somewhere along the way I realized that I'll probably need CoroutineLocals, so I had to implement those first. Then some more hacking and I got myself the (probably) first JRuby implementation to use real coroutines.
I only had to modify:
FiberLibrary.java (to use coroutines instead of threads)
ThreadService.java (to use CoroutineLocals instead of ThreadLocals)
Ruby.java (I'm not sure why, but I had to change the way the fiber library is included to addLazyBuiltin)

That was easy! A good sign for the quality of the JRuby code, I suppose...

But here are the results:
I ran different numbers of messages through a line of 5, 50, 500 and 5000 consecutive fibers. Here are the charts that compare Ruby, JRuby with coroutine support and JRuby without coroutine support. (the x-axis shows the number of messages, and the y-axis is time taken in seconds)

5 fibers:

50 fibers:

500 fibers:

5000 fibers:

I somewhat expected JRuby with coroutine support to win over JRuby without by a large margin (because Threads are used to emulate fibers), but being faster than Ruby is of course a nice bonus!

But now I should get back to work and integrate all the fixes I had to do to make it work...


  1. Lukas, this is very cool work! I can't wait until someone (maybe myself) does the same thing for Jython to support the greenlets API.

  2. cool work, I hope we can found it in the next branch ;)

  3. please post the code for the tests you ran.

  4. Awesome! Fibers are one of the best features of Ruby 1.9.

  5. FWIW, if Lucas can land the changes and I can get a build for OS X, I'm totally comfortable shipping support in JRuby 1.5 for fast coroutine-based fibers.

  6. Ditto -- Awesome! Very excited about using Fibers and JRuby in the future.

  7. what is the status of this?

  8. Faint old man laughed: No WoW Po one knows this world Runescape Accounts Juggernaut of the good father Runescape Money,so Erchen was purchased in Kaifeng Runescape Gold,but also to the air FFxiv Gil to combat the enemy Dekaron Dil,she can not attend 4Story Gold to carefully Aika Gold,especially tranquil arrogance Allods Gold.Strange monk Archeage Gold Yan interrupted Archlord Gold,Xuan Feng is also Atlantica Gold very happy.So Kenshin Blade Soul Gold seal sword.villain has been Cabal Alz Santo clean up.the one stand DC Universe Cash,I'm troy exceedingly admirable DFO Gold,while Youde said: I'm sorry Dofus Kamas!,Suddenly hearing the bad news Dragonica Gold.Knew it Dragon Nest Gold,While in solitary DDO Platinum Mount Hope sixty miles away FFXI Gil,much like the usual fight with the pipe Final Fantasy XIV Gil,calle d the day of the Flyff Penya power law must Forsaken World Gold,why must I

  9. ran up and Grand Fantasia Gold eliminating most Guild Wars 2 Gold of the effort Iris Gold.Really see too low Knight Noah to friends! which will Last Chaos Gold include the previous Lotro Gold day to save the live s of kindred Mabinogi Gold absolutely Vindictus Gold.not at all mind the Maple Mesos enemy Buy Mesos.but also in the invisible Maplestory Mesos film Ashikaga General a very loud ass Metin2 Yang.like a lumbering Nostale Gold elephant to Perfect World Gold deal with the same mice R2 Gold,Suddenly see Ragnarok Zeny a group of savage Runes of Magic Gold,shouted: Who.Rappelz Rupees Xu Tiande great surprise Shaiya Gold,Side arms of Silkraod Gold the legendary Swtor Credits Dream Volume Cavalry Tera Gold.......... Moedas PW......

  10. Awsome information given by you !!!

    W3 D Technologies is a pioneer in Dell Boomi Training sector, providing the Dell Boomi Online Training course we have experienced expert faculty for Dell Boomi

    Dell Boomi Online Training | Dell Boomi Certification Course

  11. We are offering Dell Boomi Online Training with latest techniques. Our experts have more than 8 years experienced and certified.
    Dell Boomi Online Training

  12. I like your post and Fibers are one of the best features of Ruby 1.9
    for more information clickhere below
    Ehow-india | How to Guides India | Ehow-India How To India Guides

  13. this is good article .your guidelines is so good.in this article so much information is here.

  14. very informative article.And very well explained about different protocols.keep posting like good content posts.
    For more information please visit our website.
    Oracle Fusion Cloud HCM Training

  15. CALFRE is a local search engine for online and classroom training institute. we have online training for the course
    oracle fusion financials.our oracle fusion financials online training institute Hyderabad, Bangalore, Delhi, Chennai,
    Kolkata, Pune, Mumbai, Ahmedabad, Gurgon, Noida, India, Dubai, UAE, USA, Kuwait, UK, Singapore, Saudi Arabia, Canada

    Oracle fusion Financials Online Training

    Oracle Fusion Financials online Training

  16. HI,
    this is a nice topic. Thanks for sharing such a nice topic.
    oracle fusion HCM online training.

  17. Awesome! Very excited about using Fibers and JRuby in the future


  18. Awesome post... your article is really informative and helpful for me and other bloggers too.

    oracle fusion scm online training

  19. Very interesting blog to read and to share, thanks for sharing such a good blog.............................For More Information Please visit Oracle SCM Training in Dubai Internet City.

  20. Your given most of the usefull information, i read your post is very nice thank you.......................................Find best Java Training Institute details in local Search Engine Website Calfre.com.

  21. The information which you have provided is very good. It is very useful who is looking for

    Oracle Fusion HCM Training Institutes in Hyderabad

  22. This comment has been removed by the author.

  23. Very good post.
    All the ways that you suggested for find a new post was very good.
    Keep doing posting and thanks for sharing.

  24. Thanks for providing such a great information in the blog and also very helpful to all the students.

    Oracle Fusion HCM Online Training

  25. Thank you for sharing such a valuable article with good information containing in this blog.

    Oracle Fusion HCM Training In Hyderabad

  26. Thanks for great article with suitable exlpanation........
    Oracle R12 Financials Training

  27. a lots of good useful information microsoft azure training is vey useful on azure

  28. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a .Net developer learn from Dot Net Training in Chennai. or learn thru ASP.NET Essential Training Online . Nowadays Dot Net has tons of job opportunities on various vertical industry.Dell Boomi Training in Bangalore

  29. Thanks for sharing awesome information.
    Tech Leads IT providing the Best Oracle Fusion SCM Online Training.
    Best Oracle Fusion SCM Online Training Hyderabad
    Oracle Fusion Finance Online Training
    Oracle Fusion HCM Online Training
    For More info visit us: https://www.techleadsit.com/oracle-fusion-scm-online-training-course/

  30. Thanks for sharing such a great information. Its really nice and informative. devops training videos.

  31. This comment has been removed by the author.

  32. After exploring a handful of the articles on your website, I seriously like your way of writing a blog. I bookmarked it to my bookmark site list and will be checking back in the near future. Take a look at my web site too and let me know how you feel.
    Click here to get More information.

  33. Soft Online provides best training for Oracle Fusion Cloud Financials Online Training with real time experts. We trained with real time projects and provide placement assistance.
    For more details: https://www.softonlinetraining.com/oracle-fusion-cloud-financials/
    Oracle Cloud Financials Online Training,
    Oracle Fusion Financials Training in Hyderabad

  34. This post is really nice and informative. The explanation given is really comprehensive and informative..

    windows azure training

  35. This comment has been removed by the author.

  36. I just loved your article on the beginners guide to starting a blog.If somebody take this blog article seriously in their life, he/she can earn his living by doing blogging.thank you for thizs article. pega online training , best pega online training ,
    top pega online training

  37. Nice article. I liked very much. All the informations given by you are really helpful for my research. keep on posting your views.Home lifts

  38. article from a very amazing blog, Good Job, Thank you for presenting a wide variety of information that is very interesting to see in this artikle |Home lifts
    Home lifts

  39. Thanks for giving great kind of information. So useful and practical for me. Thanks for your excellent blog, nice work keep it up thanks for sharing the knowledge.
    Vacuum Lifts India

  40. It’s too informative blog and I am getting conglomerations of info’s. Thanks for sharing; I would like to see your updates regularly so keep blogging. If anyone looking car just get here c Software Testing Training in Chennai | Software Testing Training in Anna Nagar | Software Testing Training in OMR | Software Testing Training in Porur | Software Testing Training in Tambaram | Software Testing Training in Velachery

  41. Thanks, Experience with various technologies and businesses this is generally helpful. selenium training

  42. Thanks for Sharing This Article.It is very so much valuable content. I hope these Commenting lists will help to my website
    top servicenow online trainingThanks for Sharing This Article.It is very so much valuable content. I hope these Commenting lists will help to my website
    top servicenow online training
    AWS training in Chennai

    AWS Online Training in Chennai

    AWS training in Bangalore

    AWS training in Hyderabad

    AWS training in Coimbatore

    AWS training

  43. Wow!! Really a nice Article about Angular Js. Thank you so much for your efforts. Definitely, it will be helpful for others. I would like to follow your blog. Share more like this. Thanks Again.
    python training in bangalore

    python training in hyderabad

    python online training

    python training

    python flask training

    python flask online training

    python training in coimbatore

  44. We provide best Selenium training in Bangalore, automation testing with live projects. Cucumber, Java Selenium and Software Testing Training in Bangalore.
    Online selenium training in India - KRN Informatix is a leading Selenium Training Institute in Bangalore offering extensive Selenium Training
    Selenium Training in Bangalore
    Software Testing Training in Bangalore
    Java Selenium Training in Bangalor
    Best Selenium Training in Bangalore
    Best Selenium Training Institute in Bangalore

  45. You’re so interesting! I don’t believe I’ve truly read something like this before. So great to find someone with genuine thoughts on this issue. Really.. many thanks for starting this up. This website is something that’s needed on the internet, someone with some originality!

    CBSE Schools In Ahmedabad
    CBSE Schools In Surat
    CBSE Schools In Rajkot
    CBSE Schools In Visakhapatnam
    CBSE Schools In Kangra
    CBSE Schools In Shimla
    CBSE Schools In Jammu
    CBSE Schools In Solan
    CBSE Schools In Mangalore
    CBSE Schools In Mysore

  46. Welcome to CapturedCurrentNews – Latest & Breaking India News 2021
    Hello Friends My Name Anthony Morris.latest and breaking news drupepower.com

  47. nice post thanks for sharing nice information if like know more about snow flakes visit it https://snowflakemasters.in/

  48. Infycle Technologies, the best software training institute in Chennai Perfect place to learn Big Data Hadoop Training in Chennai for experienced, and Tech professionals. And we also put up other courses like Data Science, Manual and Automation Testing, DevOps, Medical Coding, Oracle, Java, Data Science, AWS, Python, etc., at the end of the course period the pupil will be able to crack jobs on top MNC’s. for more details call 7504633633.

  49. i like your post and all your headings are good....hindi skill

  50. Really Great Post. Thanks For Sharing. If You’re Looking for Home Lifts for Malaysia just visit our blogs:
    Top Lift Companies in Malaysia
    vacuum home lift in Malaysia

  51. Great blog post, thanks for sharing.

  52. Ziyyara offers the best way to learn Hindi online! With our engaging and easy-to-use platform, you'll be speaking the Hindi language fluently in any time.
    Call Us for Free Demo:- +91- 9654271931, +968-71912179
    Visit us:- Learn hindi language


  53. We are manufacturing world's best lift for home in India. We are providing the certified lifts for your homes, buildings, bungalows and villas. Nibav Home Elevators will have the only elevator technology in the world that does not require any battery backup or temporary power supply in the event of power failure. Get an accurate home lift price for your home by contacting us Today.

  54. Nail craftsmanship is something that has been drawing in ladies of all age bunch in the new years. Having smart nail is a piece of your character that can make you separated from the remainder of the crow and make you stick out. Nail Course in Noida presented by Shweta Gaur Cosmetics Craftsman and Foundation has proficient mentors who are all around knowledgeable about giving preparation to the nail course in Noida.Individuals are getting Best Nail Extension in Noida productive with time and nail workmanship is prominently developing as time passes. There are immense profession potential open doors in this field in the event that you become a talented nail workmanship creator. A nail course will assist you with learning the fundamental as well as the development level of nail planning. You will get to figure out how to do an assortment of nail expressions. You can figure out how to utilize different varieties according to various events, nail craftsmanship that includes expansions, sparkle, gel augmentation and substantially more. Join Nail Course in Noida presented by Shweta Gaur Cosmetics Craftsman and Foundation and become an unmistakable nail workmanship expert in a span of 10 days.

  55. Step-by-Step Hacking Tutorials about WiFi hacking,
    Kali Linux, Metasploit, exploits, ethical hacking, information security, malware analysis and scanning

  56. We provide complete technology and business development solutions to MFDs to increase their digital brand presence and grow their Mutual Fund business online.

  57. "Great article, felt good after reading, worth it.
    i would like to read more from you.
    keep posting more.
    also follow Propmtengineeringcourseinhyderabad"

  58. "Great article, felt good after reading, worth it.
    i would like to read more from you.
    keep posting more.
    also follow MERN Stack Course In Hyderabad"