skip to main content
research-article

Automating ad hoc data representation transformations

Published:23 October 2015Publication History
Skip Abstract Section

Abstract

To maximize run-time performance, programmers often specialize their code by hand, replacing library collections and containers by custom objects in which data is restructured for efficient access. However, changing the data representation is a tedious and error-prone process that makes it hard to test, maintain and evolve the source code. We present an automated and composable mechanism that allows programmers to safely change the data representation in delimited scopes containing anything from expressions to entire class definitions. To achieve this, programmers define a transformation and our mechanism automatically and transparently applies it during compilation, eliminating the need to manually change the source code. Our technique leverages the type system in order to offer correctness guarantees on the transformation and its interaction with object-oriented language features, such as dynamic dispatch, inheritance and generics. We have embedded this technique in a Scala compiler plugin and used it in four very different transformations, ranging from improving the data layout and encoding, to retrofitting specialization and value class status, and all the way to collection deforestation. On our benchmarks, the technique obtained speedups between 1.8x and 24.5x.

Skip Supplemental Material Section

Supplemental Material

References

  1. Scala Streams Repository. URL https://web.archive.org/ web/20150719095701/https://github.com/biboudis/ scala-streams.Google ScholarGoogle Scholar
  2. Gaussian integers wikipedia article. URL https://web.archive. org/web/20150627074634/https://en.wikipedia.org/wiki/ Gaussian_integer.Google ScholarGoogle Scholar
  3. ILDL Scala Compiler Plugin Source Code (also available in the artifact attached to the paper),. URL https://web.archive.org/ web/20150719095959/https://github.com/miniboxing/ ildl-plugin.Google ScholarGoogle Scholar
  4. ILDL Scala Compiler Plugin Documentation (also available in the artifact attached to the paper),. URL https://web.archive.org/ web/20150719095927/https://github.com/miniboxing/ ildl-plugin/wiki.Google ScholarGoogle Scholar
  5. LDL-based Staging Scala Compiler Plugin. URL https://web.archive. org/web/20150719095846/https://github.com/miniboxing/ staging-plugin.Google ScholarGoogle Scholar
  6. The Miniboxing plugin website. URL https://web.archive.org/web/ 20141218011004/http://scala-miniboxing.org/.Google ScholarGoogle Scholar
  7. Rosetta Code Website. URL https://web.archive.org/web/ 20090106202220/http://rosettacode.org/.Google ScholarGoogle Scholar
  8. ScalaBlitz Optimizer. URL https://web.archive.org/web/ 20141218200210/http://scala-blitz.github.io/.Google ScholarGoogle Scholar
  9. Scala SIP-15: Value Classes. URL http://docs.scala-lang.org/ sips/completed/value-classes.html.Google ScholarGoogle Scholar
  10. Sparkle Tool. URL https://web.archive.org/web/ 20150719095739/https://github.com/mighdoll/sparkle.Google ScholarGoogle Scholar
  11. Optimistic Respecialization Attempts 1-5,. URL https://web.archive. org/web/20150719095636/http://io.pellucid.com/blog/ optimistic-respecialization.Google ScholarGoogle Scholar
  12. Optimistic Respecialization Attempt 6,. URL https://web.archive. org/web/20150719095603/http://io.pellucid.com/blog/ optimistic-respecialization-attempt-6.Google ScholarGoogle Scholar
  13. P. Aleksandar, D. Petrashko, and M. Odersky. Efficient Lock-Free Work-stealing Iterators for Data-Parallel Collections. In PDP ’15. IEEE, 2015.Google ScholarGoogle Scholar
  14. A. Biboudis, N. Palladinos, and Y. Smaragdakis. Clash of the Lambdas. ICOOLPS, 2014.Google ScholarGoogle Scholar
  15. A. Biboudis, N. Palladinos, G. Fourtounis, and Y. Smaragdakis. Streams a la carte: Extensible Pipelines with Object Algebras. In ECOOP ’15. ACM, 2015.Google ScholarGoogle Scholar
  16. C. F. Bolz, A. Cuni, M. Fijalkowski, and A. Rigo. Tracing the meta-level: PyPy’s tracing JIT compiler. In ICOOLPS, Genova, Italy, 2009. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. C. F. Bolz, L. Diekmann, and L. Tratt. Storage Strategies for Collections in Dynamically Typed Languages. In OOPSLA, OOPSLA ’13. ACM, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. K. J. Brown, A. K. Sujeeth, H. J. Lee, T. Rompf, H. Chafi, M. Odersky, and K. Olukotun. A heterogeneous parallel framework for domain-specific languages. In PACT. IEEE Computer Society, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. E. Burmako. Scala Macros: Let Our Powers Combine!: On How Rich Syntax and Static Types Work with Metaprogramming. In SCALA. ACM, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. A. Deutsch. On Determining Lifetime and Aliasing of Dynamically Allocated Data in Higher-order Functional Specifications. In POPL. ACM, 1990.. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. I. Dragos. Compiling Scala for Performance. PhD thesis, École Polytechnique Fédérale de Lausanne, 2010.Google ScholarGoogle Scholar
  22. I. Dragos and M. Odersky. Compiling Generics Through User-Directed Type Specialization. In ICOOOLPS, Genova, Italy, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. A. Gal. Trace-based Just-in-time Type Specialization for Dynamic Languages. In PLDI. ACM, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. C. F. Gauss. Theoria residuorum biquadraticorum, volume 1. Apud Dieterich, 1828.Google ScholarGoogle Scholar
  25. A. Genêt, V. Ureche, and M. Odersky. Improving the Performance of Scala Collections with Miniboxing (EPFL-REPORT-200245). Technical report, EPFL, 2014. URL http://scala-miniboxing.org/.Google ScholarGoogle Scholar
  26. A. Georges, D. Buytaert, and L. Eeckhout. Statistically Rigorous Java Performance Evaluation. In Proceedings of the 22nd annual ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages and Applications, OOPSLA ’07, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. B. Goetz. State of the Specialization, 2014. URL https://web.archive. org/web/20150102143158/http://cr.openjdk.java.net/ ~briangoetz/valhalla/specialization.html.Google ScholarGoogle Scholar
  28. R. Harper and G. Morrisett. Compiling Polymorphism Using Intensional Type Analysis. In PoPL. ACM, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. S. L. P. Jones and J. Launchbury. Unboxed Values as First Class Citizens in a Non-Strict Functional Language. In Functional Programming Languages and Computer Architecture. Springer, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. V. Jovanovic, V. Nikolaev, N. D. Pham, V. Ureche, S. Stucki, C. Koch, and M. Odersky. Yin-Yang: Transparent Deep Embedding of DSLs. Technical report, EPFL, 2013.Google ScholarGoogle Scholar
  31. B. W. Lampson and H. E. Sturgis. Reflections on an Operating System Design. Commun. ACM, 1976. ISSN 0001-0782. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. X. Leroy. Unboxed Objects and Polymorphic Typing. In PoPL. ACM, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. H. Miller, P. Haller, E. Burmako, and M. Odersky. Instant Pickles: Generating Object-oriented Pickler Combinators for Fast and Extensible Serialization. In OOPSLA. ACM, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. R. Morrison, A. Dearle, R. C. H. Connor, and A. L. Brown. An Ad Hoc Approach to the Implementation of Polymorphism. ACM TOPLAS, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. B. C. Oliveira, T. Schrijvers, W. Choi, W. Lee, and K. Yi. The Implicit Calculus: A New Foundation for Generic Programming. In PLDI. ACM, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. A. Prokopec. ScalaMeter. URL http://axel22.github.com/ scalameter/.Google ScholarGoogle Scholar
  37. T. Rompf and M. Odersky. Lightweight Modular Staging: A Pragmatic Approach to Runtime Code Generation and Compiled DSLs. In GPCE, 2010.. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. J. Rose. Value Types and Struct Tearing,. URL https://web. archive.org/web/20150530182530/https://blogs.oracle. com/jrose/entry/value_types_and_struct_tearing.Google ScholarGoogle Scholar
  39. J. Rose. Value Types in the VM,. URL https://web.archive.org/ web/20150525232233/https://blogs.oracle.com/jrose/ entry/value_types_in_the_vm.Google ScholarGoogle Scholar
  40. Z. Shao. Flexible Representation Analysis. In ICFP. ACM, 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. L. Stadler, T. Würthinger, and H. Mössenböck. Partial Escape Analysis and Scalar Replacement for Java. In CGO. ACM, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. W. Taha. A Gentle Introduction to Multi-stage Programming. In Domain-Specific Program Generation, pages 30–50. Springer, 2004.Google ScholarGoogle Scholar
  43. D. Tarditi, G. Morrisett, P. Cheng, C. Stone, R. Harper, and P. Lee. TIL: A Type-Directed Optimizing Compiler for ML. In PLDI. ACM, 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  44. P. J. Thiemann. Unboxed Values and Polymorphic Typing Revisited. In Functional Programming Languages and Computer Architecture. ACM, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  45. V. Ureche. Additional Material for "Unifying Data Representation Transformations (EPFL-REPORT-200246)". Technical report, EPFL, 2014.Google ScholarGoogle Scholar
  46. V. Ureche, C. Talau, and M. Odersky. Miniboxing: Improving the Speed to Code Size Tradeoff in Parametric Polymorphism Translations. In OOPSLA, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  47. V. Ureche, E. Burmako, and M. Odersky. Late Data Layout: Unifying Data Representation Transformations. In OOPSLA ’14. ACM, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  48. V. Ureche, M. Stojanovic, R. Beguet, N. Stucki, and M. Odersky. Improving the Interoperation between Generics Translations. In PPPJ. ACM, 2015. Google ScholarGoogle ScholarDigital LibraryDigital Library
  49. P. Wadler. Views: A Way for Pattern Matching to Cohabit with Data Abstraction. In PoPL. ACM, 1987. Google ScholarGoogle ScholarDigital LibraryDigital Library
  50. P. Wadler. Deforestation: Transforming Programs to Eliminate Trees. In ESOP ’88. North-Holland Publishing Co., 1988. Google ScholarGoogle ScholarDigital LibraryDigital Library
  51. P. Wadler and S. Blott. How to Make Ad-hoc Polymorphism Less Ad hoc. In PoPL. ACM, 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  52. T. Würthinger, C. Wimmer, A. Wöß, L. Stadler, G. Duboscq, C. Humer, G. Richards, D. Simon, and M. Wolczko. One VM to Rule Them All. In Onward! ACM, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  53. G. Xu. CoCo: Sound and Adaptive Replacement of Java Collections. In ECOOP. Springer-Verlag, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Automating ad hoc data representation transformations

    Recommendations

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in

    Full Access

    • Published in

      cover image ACM SIGPLAN Notices
      ACM SIGPLAN Notices  Volume 50, Issue 10
      OOPSLA '15
      October 2015
      953 pages
      ISSN:0362-1340
      EISSN:1558-1160
      DOI:10.1145/2858965
      • Editor:
      • Andy Gill
      Issue’s Table of Contents
      • cover image ACM Conferences
        OOPSLA 2015: Proceedings of the 2015 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and Applications
        October 2015
        953 pages
        ISBN:9781450336895
        DOI:10.1145/2814270

      Copyright © 2015 ACM

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 23 October 2015

      Check for updates

      Qualifiers

      • research-article

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader
    About Cookies On This Site

    We use cookies to ensure that we give you the best experience on our website.

    Learn more

    Got it!