Optimizing SYB is easy!

  • Authors:
  • Michael D. Adams;Andrew Farmer;José Pedro Magalhães

  • Affiliations:
  • University of Illinois at Urbana-Champaign, Urbana-Champaign, IL, USA;University of Kansas, Lawrence, KS, USA;University of Oxford, Oxford, United Kingdom

  • Venue:
  • Proceedings of the ACM SIGPLAN 2014 Workshop on Partial Evaluation and Program Manipulation
  • Year:
  • 2014

Quantified Score

Hi-index 0.00

Visualization

Abstract

The most widely used generic-programming system in the Haskell community, Scrap Your Boilerplate (SYB), also happens to be one of the slowest. Generic traversals in SYB are often an order of magnitude slower than equivalent handwritten, non-generic traversals. Thus while SYB allows the concise expression of many traversals, its use incurs a significant runtime cost. Existing techniques for optimizing other generic-programming systems are not able to eliminate this overhead. This paper presents an optimization that completely eliminates this cost. Essentially, it is a partial evaluation that takes advantage of domain-specific knowledge about the structure of SYB. It optimizes SYB-style traversals to be as fast as handwritten, non-generic code, and benchmarks show that this optimization improves the speed of SYB-style code by an order of magnitude or more.