Main Content

Using Ruby to generate faster Ruby code through partial evaluation

A talk by at RubyConf 2009

About the Talk

November 20, 2009 6:15 AM

San Francisco

San Francisco

Ruby performance has become a focus of the Ruby community in recent years. Both new implementations of Ruby (i.e. YARV, JRuby, IronRuby, MacRuby, and Rubinius) and "best-practices" have been introduced to address performance issues. We take a complementary approach in our work, applying source-to-source translation to partially evaluate Ruby. Partial evaluation pre-computes the parts of a program known before run-time to avoid performing these calculations at run-time. We introduce our partial evaluator and two Ruby-embedded DSLs we developed to aid our implementation---RubyWrite and ShadowBoxing. The partial evaluator takes a Ruby source program as input and outputs an equivalent Ruby program with statically known values pre-computed. RubyWrite enables us to easily represent and manipulate the abstract syntax tree (AST). ShadowBoxing lets us write succinct rules to "unparse" the AST back to Ruby source. Our approach sits neatly between making programmers entirely responsible for performance and faster Ruby implementations, providing a tool that can be used on any implementation to help improve performance.

Ratings and Recommendations

Avg. Rating

Average based
on 4 ratings

comments powered by Disqus