Making it Fast: The Power of Benchmarking

schedule 04:00 PM - 04:45 PM place Sigma Hall 1

There's an old expression, usually attributed to Kent Beck, that we should "Make it work, make it right, make it fast", in that order. This talk is going to focus on making it fast.

Not long ago, I was working on a little problem in Elixir that involved a two dimensional array. Now, Elixir doesn't really have arrays, it has lists, maps, tuples, and binaries, so the one thing we can be sure about when implementing a 2-d array is that we're going to be simulating it using something else. What I discovered was surprising, and served as an important lesson about actually benchmarking things.

In this talk, we'll discuss the importance of benchmarking, demonstrate some tools that make benchmarking in Elixir very simple, and show you some surprising results about which approaches are faster in this language.

 
3 favorite thumb_down thumb_up 0 comments visibility_off  Remove from Watchlist visibility  Add to Watchlist
 

Outline/structure of the Session

Rough outline:

  • Why do we make it fast last?
  • Measure first, then optimize. Why benchmarking is always the first step in optimization.
  • Let's implement a 2-d array, by making it work, making it right, then making it fast.
  • Why are we sometimes surprised by benchmarking results?
  • How important is Tail-call optimization?
  • More examples

Learning Outcome

Attendees will know what to benchmark, and how to benchmark it. Hopefully we will show enough surprising results that you will always have an open mind about what is fast and what is slow.

Target Audience

Elixir programmers interested in optimizing their code

Prerequisite

You should have at least a basic knowledge of Elixir, but a deep understanding of OTP and concurrency will probably not be necessary. If you've ever wondered why something you wrote in Elixir seems slow, then this talk is for you. If you've ever written some data structure in Elixir and worried that you might not be doing things the "right" way, then this talk is for you.

schedule Submitted 2 months ago

Comments Subscribe to Comments

comment Comment on this Proposal

  • Liked Manuel Chakravarty
    keyboard_arrow_down

    Manuel Chakravarty - Haskell SpriteKit - a Purely Functional API for a Stateful Animation System and Physics Engine

    Manuel Chakravarty
    Manuel Chakravarty
    Lambda Scientist
    UNSW Sydney
    schedule 4 months ago
    Sold Out!
    45 mins
    Demonstration
    Intermediate

    Graphics, animation, and games programming in Haskell faces a dilemma. We can either use existing frameworks with their highly imperative APIs (such as OpenGL, Cocos2D, or SpriteKit) or we waste a lot of energy trying to re-engineer those rather complex systems from scratch. Or, maybe, we can escape the dilemma. Instead of a Haskell program directly manipulating the mutable object-graph of existing high-level frameworks, we provide an API for purely functional transformations of a Haskell data structure, together with an adaptation layer that transcribes those transformations into edits of the mutable object-graph.

    I this talk, I will explain how I used this approach to architect a Haskell binding to the animation system and physics engine of Apple’s SpriteKit framework. I will discuss both how the binding is structured and how it achieves the translation of Haskell side changes to SpriteKit and vice versa, such that it is sufficiently efficient. Moreover, I will demonstrate by example how to use the Haskell library to implement a simple game.

  • Liked Tony Morris
    keyboard_arrow_down

    Tony Morris - Functional Programming in Aviation

    45 mins
    Demonstration
    Beginner

    In this talk & demo, we have a look at some of the low-hanging problems in general aviation and how functional programming can be applied to provide significant improvements in efficiency and air safety. The current solutions to problems such as navigation, traffic/terrain collision avoidance and weight/balance calculations will be demonstrated to the audience, mostly for amusement. More seriously, we will have a look at the legacy that has led to the way things are, and how to improve by applying our programming skills.

    We will look at:

    • how aviation safety is regulated.
    • how aeronautical services are provided to flight operators.
    • how aeronautical navigation is conducted and regulated.
    • how the weight and balance for a flight is conducted.
    • the methods by which aircraft and ground coordinate between each other.

    We will see:

    • some real (and basic) data management problems in aviation, that very obviously threaten safety, then solve them, using programming.
    • we will see a live demonstration of aeronautical navigation methods, investigate incident reports where lives were lost as a result, and consider how our programming skills can yield improvements, possibly even save lives.
    • we will conduct a real weight&balance calculation for a flight, then once hilarity inevitably ensues, we will look at the problems that arise by this method, then solve them using data structures and functional programming. Some
      of these practical problems are obvious, even to a non-aviator, and the predictable incident reports are the end result.
    • finally, we will have a look at a live demonstration of a software defined radio (SDR), receiving ADS-B transmissions from aircraft (live), an AHRS implementation and GNSS receiver using off-the-shelf, low-cost parts. We will look at why these instruments are helpful to aircraft pilots and interact with that device using the Haskell programming language.
  • Liked Roger Hui
    keyboard_arrow_down

    Roger Hui - Proofs, Derivations, Tests

    Roger Hui
    Roger Hui
    programmer
    Dyalog Ltd.
    schedule 4 months ago
    Sold Out!
    45 mins
    Talk
    Intermediate

    John Hughes and Mary Sheeran in Why Functional Programming Matters [0] list “algebra as a litmus test” as one of the four salient features of functional programming, and Ken Iverson in Notation as a Tool of Thought [1] lists “amenability to formal proof” as one of the five important characteristics of notation. Using the language APL, we prove the correctness of some programs, derive simplifications, and illustrate design validation and program test techniques for functional programs.

    [0] Hughes, John, and Mary Sheeran, Why Functional Programming Matters, Code Mesh, London, 2015-11-02 to -04.

    [1] Iverson, Kenneth E., Notation as a Tool of Thought, Communications of the ACM, volume 23, number 8, 1980-08.

  • 45 mins
    Demonstration
    Beginner

    In Indian classical music, we have Jugalbandi, where two lead musicians or vocalist engage in a playful competition. There is jugalbandi between Flutist and a Percussionist (say using Tabla as the instrument). Compositions rendered by flutist will be heard by the percussionist and will replay the same notes, but now on Tabla and vice-versa is also possible.

    In a similar way, we will perform Code Jugalbandi to see how the solution looks using different programming languages and paradigms.This time the focus of code jugalbandi will be on solutioning in different paradigms - object-oriented or functional programming and array-oriented paradigms.

    During the session, Morten and Dhaval will take turns at coding the same problem using different languages and paradigms. There would be multiple such rounds during the Jugalbandi.

  • Liked Anil Wadghule
    keyboard_arrow_down

    Anil Wadghule - Building Distributed System with Erlang Ecosystem

    45 mins
    Demonstration
    Intermediate

    In this talk, we will explore how can we write a distributed system with Elixir/Erlang. We will cover distributed systems basics, how a distributed system is capable of enhanced performance and how it gives us higher availability.

    Then we would start with a demonstration of a distributed system written with Elixir programming language. We will spend most of the talk discussing the demo code.

    We will also cover main advantages of Elixir/Erlang ecosystem to build distributed systems.

    We will explore aspects such a latency, throughput, computing power. We will understand how Elixir is capable for fault tolerance, resilience. We will explore tool set provided by OTP library. What tools from library helps us to write a distributed system.

    But distributed Erlang/Elixir *has known limitations*. For example, issues with when a network is fully meshed, how many numbers of nodes which can scale we get in a cluster, how sending large data over distribution is an issue etc. What are solutions for it?

  • 20 mins
    Talk
    Beginner


    A lot of companies still decide to go with Node.js / Java / Ruby / Python for building web apps.

    In this talk, we will focus on, how Elixir ecosystem is ready to replace Node.js / Java / Ruby / Python for most of the web apps

    The aim of this talk is to present why Elixir lang is a good choice for building your next web app.

    We will explore some of the features and tool that Phoenix web framework provides that replaces the need of using Java / Node.js / Ruby / Python for web apps. e.g. Better concurrency model, Ecto for database interaction,  Phoenix channels, Simple APIs, Umbrella apps etc, Speed of development.

    The talk will have a deep comparison of the runtime of Node.js, JVM, Ruby/Python with Elixir runtime. (e.g. http://joearms.github.io/2013/04/02/Red-and-Green-Callbacks.html for comparing Erlang callbacks with JavaScript callbacks, Comparison of JVM with BEAM  http://ds.cs.ut.ee/courses/course-files/To303nis%20Pool%20.pdf etc)

    We will also compare syntaxes of these languages by seeing the code of the same app but with multiple languages.

    This talk will also show how using Elixir also helps us a become better programmer because of features like immutability, functions, pattern matching, first class processes etc, great syntax.

    At the end of the talk, every Java / Node.js / Ruby / Python developer should feel confident about Elixir and talk will motivate them to choose Elixir over Java / Node.js / Ruby / Python for building the next web app.

  • Liked Shantanu Kumar
    keyboard_arrow_down

    Shantanu Kumar - A functional workflow for bootstrapping applications

    Shantanu Kumar
    Shantanu Kumar
    Principal Engineer
    Concur
    schedule 2 months ago
    Sold Out!
    45 mins
    Talk
    Intermediate

    Application configuration and initialization are tangential to delivering business value, yet we frequently get bogged down by their incidental complexity. They crosscut various (Dev/QA/Prod etc.) environments and impact the workflow in subtle, disparate ways. In this session, I will discuss the experience of tackling this beast for several projects in a large team using an elegant functional programming approach. The approach was turned into a data-driven Clojure framework for applications to use. This success story is over two years old in production and it scales from a junior developer looking to learn the ropes to experienced folks focusing on advanced use cases. I will discuss the fundamentals of this approach, how it is used in production, in QA, and in development. I will also share the REPL-enabled development workflow and how it facilitates automated unit and integration testing.

  • Liked Manoj Govindan
    keyboard_arrow_down

    Manoj Govindan - Learning Computer Architecture

    Manoj Govindan
    Manoj Govindan
    Director, Engineering
    Perfios
    schedule 2 months ago
    Sold Out!
    45 mins
    Experience Report
    Intermediate

    Computer Architecture begins with electronics. As computers are built layer upon layer starting with primitive gates baked into silicon, followed by chips and logic gates, hardware platform including ALU, RAM, cache etc., and so on, so is the study of computer architecture a study of each of these layers of abstraction.

    Students of computer architecture usually rely on simulators, often written in Java or similar imperative/object oriented languages, to aid their learning. Here are some examples of such a program:

    Simulating XOR gate

    As an Erlang/functional programming enthusiast studying computer architecture I decided to write my own equivalent tools in Erlang and TypeScript as I went about my learning. I am studying computer architecture and simultaneously writing the required simulators and other tooling in Erlang and TypeScript.

    Building such emulators and tools in Erlang and Typescript results in distinctly different architectures. I'll be demoing the simulator I built and talking about lessons learned doing this.

  • Liked Sandesh Soni
    keyboard_arrow_down

    Sandesh Soni - Putting REST to Rest using GraphQL

    20 mins
    Talk
    Beginner

    Alternative to APIs - GraphQL by Facebook

    Using GraphQL with Elixir using AbsInThe-GraphQL library

  • Liked Ravi Mohan
    keyboard_arrow_down

    Ravi Mohan - Predator: A Framework for Developing Programmatic Players for Complex Board Games

    Ravi Mohan
    Ravi Mohan
    CEO
    AxiomChoice
    schedule 4 months ago
    Sold Out!
    45 mins
    Experience Report
    Beginner

    Summary: An Experience Report on How I'm using Erlang and PureScript to create programmatic opponents aka 'bots' for complex boardgames I love to play but I can't find people to play with!

    The number of boardgames that you can whip out at a gathering and expect people to want play is very small.. Monopoly, Snakes and Ladders, and maybe, if you are *very* lucky, Settlers of Catan. And that's about it.


    Getting people to play these games is relatively easy.

    However the world of boardgames is *much* wider.

    There are literally tens of thousands of boardgames that simulate everything from very abstract geometry puzzles to ones that simulate complex economies and political situations.

    Some of the latter are used in very unexpected ways, e.g to train spies and military officers.

    Here is an example of an interesting game.

    A Distant Plain (by GMT Games) is a boardgame for 4 players that put them in the roles of the US military forces, the Afghan government, the Taliban, and Warlords/drug dealers, all competing for power in Afghanistan.

    ADP

    adpcards

    Here is another
    The War of the Ring, a game for 2 players.

    "In War of the Ring, one player takes control of the Free Peoples (FP), the other player controls Shadow Armies (SA). Initially, the Free People Nations are reluctant to take arms against Sauron, so they must be attacked by Sauron or persuaded by Gandalf or other Companions, before they start to fight properly ...."

    WarOfRings1

    And one more

    "The battle of Sekigahara, fought in 1600 at a crossroads in Japan, unified that nation under the Tokugawa family for more than 250 years.

    Sekigahara allows you to re-contest that war as Ishida Mitsunari, defender of a child heir, or Tokugawa Ieyasu, Japan's most powerful daimyo (feudal lord)."

    ."

    What these games have in common
    1. They are wonderful games, immersing you into their respective worlds.
    2. They have (relative to Snakes and Ladders or Monopoly) complex rulesets, which take effort and time to master.
    3. They are rarely played in India.
    4. Even when people own them, opponents are almost impossible to find and schedule.

    Which means that if you own these games and live in India, getting to actually play these games is close to impossible.

    Which is a problem.

    Being a programmer, I solve this problem by writing programmatic opponents (aka 'bots') to take the place of other players. This involves all kinds of interesting sub problems - game representation, logic processing for rules, building AI 'smarts' for your opponents, gui and event handling etc.

    Since I am doing this in my non existent spare time, I use time and effort saving languages with good capabilities for abstraction(aka functional languages!),

    In this case I use Erlang (originally Haskell, I'm using this project to learn Erlang) for the backend and PureScript for the front end.

    This talk is about the many challenges I faced in building automated game players (and extracting common frameworks/libraries) from them, while simultaneously learning two FP languages.

    Since this is an experience report, it is basically a list of lessons learned, victories *and defeats*, what worked *and what didn't work*.

    If you can't use FP at work, but are considering doing so on a personal project, or want to learn how to get going on an FP learning effort, you might benefit from my experience - both successes and failures

  • Liked Sandesh Soni
    keyboard_arrow_down

    Sandesh Soni - Elixir on Ruby

    20 mins
    Talk
    Beginner

    For ruby and rails users who want to understand and learn elixir

    give a basic understanding
    Topic is not why Elixir? Its how Elixir.


    mix tooling, Ecto, tests
    Popular Elixir Library Alternates for Ruby libraries(Authentication, etc)

    This does not cover OTP framework.