Efficient coroutines for the Java platform

Lukas Stadler, Thomas Würthinger, Christian Wimmer
{"title":"Efficient coroutines for the Java platform","authors":"Lukas Stadler, Thomas Würthinger, Christian Wimmer","doi":"10.1145/1852761.1852765","DOIUrl":null,"url":null,"abstract":"Coroutines are non-preemptive lightweight processes. Their advantage over threads is that they do not have to be synchronized because they pass control to each other explicitly and deterministically. Coroutines are therefore an elegant and efficient implementation construct for numerous algorithmic problems.\n Many mainstream languages and runtime environments, however, do not provide a coroutine implementation. Even if they do, these implementations often have less than optimal performance characteristics because of the tradeoff between run time and memory efficiency.\n As more and more languages are implemented on top of the Java virtual machine (JVM), many of which provide coroutinelike language features, the need for a coroutine implementation has emerged. We present an implementation of coroutines in the JVM that efficiently handles a large range of workloads. It imposes no overhead for applications that do not use coroutines and performs well for applications that do.\n For evaluation purposes, we use our coroutines to implement JRuby fibers, which leads to a significant speedup of certain JRuby programs. We also present general benchmarks that show the performance of our approach and outline its run-time and memory characteristics.","PeriodicalId":169989,"journal":{"name":"Principles and Practice of Programming in Java","volume":"20 1","pages":"0"},"PeriodicalIF":0.0000,"publicationDate":"2010-09-15","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"18","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"Principles and Practice of Programming in Java","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.1145/1852761.1852765","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 18

Abstract

Coroutines are non-preemptive lightweight processes. Their advantage over threads is that they do not have to be synchronized because they pass control to each other explicitly and deterministically. Coroutines are therefore an elegant and efficient implementation construct for numerous algorithmic problems. Many mainstream languages and runtime environments, however, do not provide a coroutine implementation. Even if they do, these implementations often have less than optimal performance characteristics because of the tradeoff between run time and memory efficiency. As more and more languages are implemented on top of the Java virtual machine (JVM), many of which provide coroutinelike language features, the need for a coroutine implementation has emerged. We present an implementation of coroutines in the JVM that efficiently handles a large range of workloads. It imposes no overhead for applications that do not use coroutines and performs well for applications that do. For evaluation purposes, we use our coroutines to implement JRuby fibers, which leads to a significant speedup of certain JRuby programs. We also present general benchmarks that show the performance of our approach and outline its run-time and memory characteristics.
Java平台的高效协同程序
协程是非抢占式的轻量级进程。与线程相比,它们的优点是不必同步,因为它们显式地、确定地相互传递控制。因此,协程是解决众多算法问题的一种优雅而高效的实现结构。然而,许多主流语言和运行时环境不提供协程实现。即使它们这样做,由于在运行时间和内存效率之间的权衡,这些实现通常也没有最优的性能特征。随着越来越多的语言在Java虚拟机(JVM)上实现,其中许多提供了类似协同程序的语言特性,对协同程序实现的需求就出现了。我们在JVM中提供了一个协程的实现,它可以有效地处理大量的工作负载。对于不使用协程的应用程序,它不会带来任何开销,而对于使用协程的应用程序,它的性能也很好。出于评估的目的,我们使用我们的协程来实现JRuby纤维,这导致某些JRuby程序的显著加速。我们还提供了显示我们的方法的性能的一般基准测试,并概述了其运行时和内存特性。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
求助全文
约1分钟内获得全文 求助全文
来源期刊
自引率
0.00%
发文量
0
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
确定
请完成安全验证×
copy
已复制链接
快去分享给好友吧!
我知道了
右上角分享
点击右上角分享
0
联系我们:info@booksci.cn Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。 Copyright © 2023 布克学术 All rights reserved.
京ICP备2023020795号-1
ghs 京公网安备 11010802042870号
Book学术文献互助
Book学术文献互助群
群 号:604180095
Book学术官方微信