• Cite Icon19
  • https://doi.org/10.5075/epfl-thesis-4820Copy DOI Icon

Compiling Scala for Performance

  • Abstract
  • Literature Map
  • References
  • Citations
  • Similar Papers
Abstract

Scala is a new programming language bringing together object-oriented and functional programming. Its defining features are uniformity and extensibility. Scala offers great flexibility for programmers, allowing them to grow the language through libraries. Oftentimes what seems like a language feature is in fact implemented in a library, effectively giving programmers the power of language designers. The downside of this flexibility is that familiar looking code may hide unexpected performance costs. It is important for Scala compilers to bring down this cost as much as possible. We identify several areas of impact for Scala performance: higher-order functions and closures, and generic containers used with primitive types. We present two complementary approaches for improving performance in these areas: optimizations and specialization. Compiler optimization can bring down the cost through a combination of aggressive inlining of higher-order functions, an extended version of copy-propagation and dead-code elimination. Both anonymous functions and boxing can be eliminated by this approach. We show on a number of benchmarks that these language features can be up to 5 times faster when properly optimized, on current day JVMs. We propose a new approach to compiling parametric polymorphism for performance at primitive types. We mix a homogeneous translation scheme with user-directed specialization for primitive types. Type parameters may be annotated to require specialization of code depending on them. We propose definition-site specialization for primitive types, achieving separate compilation and no boxing when both the definition and call site are specialized. Specialized classes are compatible with unspecialized code, and specialization agnostic code can work with specialized instances, meaning that specialization is opportunistic. We present a formalism of a small subset of Scala with specialization and prove that specialization preserves types. We implemented this translation in the Scala compiler and report on improvements on a set of benchmarks, showing that specialization can make programs more than two times faster.

Similar Papers
  • Supplementary Content

Co-Contextual Type Systems: Contextless Deductive Reasoning for Correct Incremental Type Checking

  • Mar 02, 2020
  • TUbilio (Technical University of Darmstadt)
  • Edlira Kuci
  • Research Article
  • Citations6

Exploring compiler optimization opportunities for the OpenMP 4.x accelerator model on a POWER8+GPU platform

  • Nov 13, 2016
  • Akira Hayashi +4
  • Research Article
  • Citations17

Compiling scala for the Java virtual machine

  • Jan 01, 2005
  • Infoscience (Ecole Polytechnique Fédérale de Lausanne)
  • Michel Schinz
  • Supplementary Content

Formal Design and Analysis for DNA Implementations of Chemical Reaction Networks

  • Jul 16, 2020
  • Robert F Johnson
  • Supplementary Content

Architecting Query Compilers for Diverse Workloads

  • Jun 10, 2019
  • Figshare
  • Ruby Y Tahboub
  • Research Article
  • Citations4

Verification by Reduction to Functional Programs

  • Jan 01, 2017
  • Infoscience (Ecole Polytechnique Fédérale de Lausanne)
  • Régis Blanc
  • Research Article
  • Citations1

The new COBOL standard

  • Feb 21, 1989
  • S Srinivasan
  • Research Article
  • Citations5

Promoting rewriting to a programming language: a compiler for non-deterministic rewrite programs in associative-commutative theories

  • Mar 01, 2001
  • Journal of Functional Programming
  • Kirchnerhélène +1
  • Research Article
  • Citations5

Miniboxing

  • Oct 29, 2013
  • ACM SIGPLAN Notices
  • Vlad Ureche +2
  • Conference Article
  • Citations2

Inlining of mathematical functions in HP-UX for Itanium® 2

  • Mar 23, 2003
  • James W Thomas
  • Supplementary Content

Research data supporting "Prefetching in Functional Languages"

  • May 15, 2020
  • Apollo (University of Cambridge)
  • Sam Ainsworth +1
  • Conference Article
  • Citations2

Just-In-Time Java? Compilation for the Itanium® Processor

  • Sep 22, 2002
  • Tatiana Shpeisman +2
  • Research Article
  • Citations14

Concolic testing for functional languages

  • May 12, 2017
  • Science of Computer Programming
  • Aggelos Giantsios +2
  • Research Article

台灣歌仔冊擬音「便宜字」書寫現象的類型

  • Jun 01, 2011
  • 國文學誌
  • 臧汀生
  • Book Chapter

Chapter 1 - SQL Is Declarative, Not Procedural

  • Jan 01, 2008
  • Joe Celko's Thinking in Sets: Auxiliary, Temporal, and Virtual Tables in SQL
  • Joe Celko
Cactus Communications logo

Copyright 2026 Cactus Communications. All rights reserved.