PNWS 2014 - Miniboxing: JVM Generics without the overhead

Channel:
Subscribers:
42,400
Published on ● Video Link: https://www.youtube.com/watch?v=RnIupOJv_oM



Duration: 44:38
762 views
6


By, Vlad Ureche
Generics are now a must-have in any statically typed programming language. Yet, there is a strong tension between the uniform interface exposed to programmers and the low level implementation, which has to deal with data of different sizes and semantics: booleans, integers, floating-point numbers and heap objects. Different languages have taken in very different paths to implementing generics, each with its own advantages and drawbacks. In Java and other JVM languages the standard is boxing primitive values, meaning that heap objects are used to carry primitive values. This leads to significant slowdowns and increased heap consumption, especially when using generic collections for primitive types.

Scala proposes specialization as an alternative to boxing: the compiler can duplicate and adapt user code for each primitive type, thus using unboxed data. Specialization has been shown to reliably speed up code and is extensively used in established community libraries, such as spire (non/spire) and breeze (scalanlp.org). But statically duplicating code can result in significant jar sizes and long compilation times. For example, specializing a 3-element tuple, which takes three type parameters, yields 1000 almost-identical classes.

In the miniboxing project we set out to reduce the static bytecode size while maintaining optimality: we build on the idea of tagged union, thus offering a single variant of the code for all primitive value types. This means the 3-element tuple can now be specialized with just 8 classes. But matching the performance of specialization was a long and convoluted journey. In this presentation I will explain the basics of miniboxing and show what we had to do to match the speed of specialized code.

The project's website, scala-miniboxing.org, contains all you need to get started: the miniboxing compiler plugin, documentation, usage examples and benchmarks.

Help us caption & translate this video!

http://amara.org/v/FnQs/




Other Videos By Confreaks


2014-12-15PNWS 2014 - What every (Scala) programmer should know about category theory
2014-12-15PNWS 2014 - Towards a Safer Scala
2014-12-15PNWS 2014 - Composing Project Archetypes with SBT AutoPlugins
2014-12-15PNWS 2014 - Building a Better Future: Advanced Error Handling for Concurrent Programming with Scalaz
2014-12-15PNWS 2014 - Unruly Creatures: Strategies for dealing with Real Numbers
2014-12-15PNWS 2014 - Hands-on Scala.js
2014-12-15PNWS 2014 - One Year of Akka
2014-12-15PNWS 2014 - What's new since Programming in Scala
2014-12-15PNWS 2014 - Adding Tree and Tree: Distributed Decision Tree Learning
2014-12-15PNWS 2014 - The First Hit is Always Free: A Skeptic's Look at scalaz' Gateway Drugs
2014-12-12PNWS 2014 - Miniboxing: JVM Generics without the overhead
2014-12-12PNWS 2014 - Apache Spark II: Streaming Big Data Analytics with Team Apache, Scala & Akka
2014-12-12PNWS 2014 - Apache Spark I: From Scala Collections to Fast Interactive Big Data with Spark
2014-12-12PNWS 2014 - Don’t cross the streams
2014-12-12PNWS 2014- Types out of patmat
2014-12-08Keep Ruby Weird 2014 - Ten Years of Ruby Conferences: A Dramatic Revue
2014-12-05Keep Ruby Weird 2014 - Opening Keynote
2014-12-05Keep Ruby Weird 2014 - Ten Years of Ruby Conferences: A Dramatic Revue
2014-12-05RubyConf 2014 - Chat Robots Next Level Tooling by Ole Michaelis
2014-12-05RubyConf 2014 - Roda: The Routing Tree Web Framework by Jeremy Evans
2014-12-05RubyConf 2014 - Build the Unified Logging Layer with Fluentd and Ruby by Kiyoto Tamura