Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
10.1145/3009837.3009880acmconferencesArticle/Chapter ViewAbstractPublication PagespoplConference Proceedingsconference-collections
research-article

Stream fusion, to completeness

Published: 01 January 2017 Publication History
  • Get Citation Alerts
  • Abstract

    Stream processing is mainstream (again): Widely-used stream libraries are now available for virtually all modern OO and functional languages, from Java to C# to Scala to OCaml to Haskell. Yet expressivity and performance are still lacking. For instance, the popular, well-optimized Java 8 streams do not support the zip operator and are still an order of magnitude slower than hand-written loops.
    We present the first approach that represents the full generality of stream processing and eliminates overheads, via the use of staging. It is based on an unusually rich semantic model of stream interaction. We support any combination of zipping, nesting (or flat-mapping), sub-ranging, filtering, mapping—of finite or infinite streams. Our model captures idiosyncrasies that a programmer uses in optimizing stream pipelines, such as rate differences and the choice of a “for” vs. “while” loops. Our approach delivers hand-written–like code, but automatically. It explicitly avoids the reliance on black-box optimizers and sufficiently-smart compilers, offering highest, guaranteed and portable performance.
    Our approach relies on high-level concepts that are then readily mapped into an implementation. Accordingly, we have two distinct implementations: an OCaml stream library, staged via MetaOCaml, and a Scala library for the JVM, staged via LMS. In both cases, we derive libraries richer and simultaneously many tens of times faster than past work. We greatly exceed in performance the standard stream libraries available in Java, Scala and OCaml, including the well-optimized Java 8 streams.

    References

    [1]
    Reactive extensions, 2016.
    [2]
    A. Biboudis, N. Palladinos, and Y. Smaragdakis. Clash of the Lambdas. arXiv preprint arXiv:1406.6631, 9th International Workshop on Implementation, Compilation, Optimization of Object-Oriented Languages, Programs and Systems, 2014.
    [3]
    A. Biboudis, N. Palladinos, G. Fourtounis, and Y. Smaragdakis. Streams a la carte: Extensible Pipelines with Object Algebras. In 29th European Conference on Object-Oriented Programming (ECOOP 2015), volume 37, pages 591–613, 2015. ISBN 978-3-939897-86-6.
    [4]
    A. Bondorf. Improving binding times without explicit CPSconversion. In Lisp & Functional Programming, pages 1–10, 1992.
    [5]
    D. Coutts, R. Leshchinskiy, and D. Stewart. Stream fusion: From lists to streams to nothing at all. In Proceedings of the 12th ACM SIGPLAN International Conference on Functional Programming, ICFP ’07, pages 315–326, New York, NY, USA, 2007. ACM. ISBN 978- 1-59593-815-2.
    [6]
    A. Farmer, A. Gill, E. Komp, and N. Sculthorpe. The HERMIT in the Machine: A Plugin for the Interactive Transformation of GHC Core Language Programs. In Proceedings of the 2012 Haskell Symposium, Haskell ’12, pages 1–12, New York, NY, USA, 2012. ACM. ISBN 978-1-4503-1574-6.
    [7]
    A. Farmer, C. Hoener zu Siederdissen, and A. Gill. The HERMIT in the Stream: Fusing Stream Fusion’s concatMap. In Proceedings of the ACM SIGPLAN 2014 Workshop on Partial Evaluation and Program Manipulation, PEPM ’14, pages 97–108, New York, NY, USA, 2014.
    [8]
    ACM. ISBN 978-1-4503-2619-3.
    [9]
    J. Gibbons and G. Jones. The under-appreciated unfold. In ICFP ’98: Proceedings of the ACM International Conference on Functional Programming, volume 34(1), pages 273–279, New York, Sept. 1998.
    [10]
    ACM Press.
    [11]
    A. Gill, J. Launchbury, and S. L. Peyton Jones. A short cut to deforestation. In Proceedings of the Conference on Functional Programming Languages and Computer Architecture, FPCA ’93, pages 223–232, New York, NY, USA, 1993. ACM. ISBN 0-89791-595-X.
    [12]
    N. Halbwachs, P. Caspi, P. Raymond, and D. Pilaud. The synchronous data flow programming language LUSTRE. Proceedings of the IEEE, 79(9):1305–1320, 1991.
    [13]
    J. Inoue and W. Taha. Reasoning about multi-stage programs. In ESOP, volume 7211 of Lecture Notes in Computer Science, pages 357–376. Springer, 2012.
    [14]
    M. Jonnalagedda and S. Stucki. Fold-based Fusion As a Library: A Generative Programming Pearl. In Proceedings of the 6th ACM SIGPLAN Symposium on Scala, SCALA 2015, pages 41–50, New York, NY, USA, 2015. ACM. ISBN 978-1-4503-3626-0.
    [15]
    G. Keller, M. M. Chakravarty, R. Leshchinskiy, S. Peyton Jones, and B. Lippmeier. Regular, shape-polymorphic, parallel arrays in Haskell. In Proceedings of the 15th ACM SIGPLAN International Conference on Functional Programming, ICFP ’10, pages 261–272, New York, NY, USA, 2010. ACM. ISBN 978-1-60558-794-3.
    [16]
    R. Kelsey and P. Hudak. Realistic compilation by program transformation (detailed summary). In Proceedings of the 16th ACM SIGPLANSIGACT Symposium on Principles of Programming Languages, POPL ’89, pages 281–292, New York, NY, USA, 1989. ACM. ISBN 0- 89791-294-2.
    [17]
    P. Khuong. Introducing pipes, a lightweight stream fusion edsl, 2011.
    [18]
    O. Kiselyov. Iteratees. In FLOPS, volume 7294 of LNCS, pages 166– 181. Springer, 2012.
    [19]
    O. Kiselyov. The Design and Implementation of BER MetaOCaml. In Functional and Logic Programming, pages 86–102. Springer, 2014.
    [20]
    B. Lippmeier, M. M. Chakravarty, G. Keller, and A. Robinson. Data flow fusion with series expressions in Haskell. In Proceedings of the 2013 ACM SIGPLAN Symposium on Haskell, Haskell ’13, pages 93– 104, New York, NY, USA, 2013. ACM. ISBN 978-1-4503-2383-3.
    [21]
    G. Mainland, R. Leshchinskiy, and S. Peyton Jones. Exploiting vector instructions with generalized stream fusion. In Proceedings of the 18th ACM SIGPLAN International Conference on Functional Programming, ICFP ’13, pages 37–48, New York, NY, USA, 2013. ACM. ISBN 978-1-4503-2326-0.
    [22]
    E. Meijer, M. Fokkinga, and R. Paterson. Functional programming with bananas, lenses, envelopes and barbed wire. In J. Hughes, editor, Functional Programming Languages and Computer Architecture: 5th Conference, number 523 in Lecture Notes in Computer Science, pages 124–144, Berlin, 1991. The Association for Computing Machinery, Springer.
    [23]
    D. G. Murray, M. Isard, and Y. Yu. Steno: automatic optimization of declarative queries. In ACM SIGPLAN Notices, volume 46, pages 121–131. ACM, 2011.
    [24]
    N. Palladinos and K. Rontogiannis. LinqOptimizer: An automatic query optimizer for LINQ to Objects and PLINQ. Technical report, Nessos Information Technologies S.A., 2013.
    [25]
    S. Peyton Jones, A. Tolmach, and T. Hoare. Playing by the rules: rewriting as a practical optimisation technique in GHC. In Haskell workshop, volume 1, pages 203–233, 2001.
    [26]
    M. Pouzet. Lucid synchrone, version 3. Tutorial and reference manual. Université Paris-Sud, LRI, 2006.
    [27]
    A. Prokopec and D. Petrashko. ScalaBlitz: Lightning-fast Scala collections framework. Technical report, LAMP Scala Team, EPFL, 2013.
    [28]
    T. Rompf and M. Odersky. Lightweight modular staging: A pragmatic approach to runtime code generation and compiled dsls. Commun. ACM, 55(6):121–130, June 2012. ISSN 0001-0782.
    [30]
    T. Rompf, A. K. Sujeeth, N. Amin, K. J. Brown, V. Jovanovic, H. Lee, M. Jonnalagedda, K. Olukotun, and M. Odersky. Optimizing data structures in high-level programs: New directions for extensible compilers based on staging. In Proceedings of the 40th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL ’13, pages 497–510, New York, NY, USA, 2013. ACM. ISBN 978-1-4503-1832-7.
    [31]
    M. Shaw, W. A. Wulf, and R. L. London. Abstraction and verification in Alphard: defining and specifying iteration and generators. Communications of the ACM, 20(8):553–564, 1977.
    [32]
    A. Shipilev, S. Kuksenko, A. Astrand, S. Friberg, and H. Loef. OpenJDK: jmh.
    [33]
    M. H. B. Sørensen, R. Glück, and N. D. Jones. Towards unifying deforestation, supercompilation, partial evaluation, and generalized partial computation. In D. Sannella, editor, Programming Languages and Systems: Proceedings of ESOP'94, 5th European Symposium on Programming, number 788 in Lecture Notes in Computer Science, pages 485-500, Berlin, 11-13 Apr. 1994. Springer.
    [34]
    G. Stewart, M. Gowda, G. Mainland, B. Radunovic, D. Vytiniotis, and C. L. Agullo. Ziria: A DSL for wireless systems programming. In Proceedings of the Twentieth International Conference on Architectural Support for Programming Languages and Operating Systems, ASPLOS ’15, pages 415–428, New York, NY, USA, 2015. ACM. ISBN 978-1-4503-2835-7.
    [35]
    J. Svenningsson. Shortcut fusion for accumulating parameters & ziplike functions. In Proceedings of the Seventh ACM SIGPLAN International Conference on Functional Programming, ICFP ’02, pages 124–132, New York, NY, USA, 2002. ACM. ISBN 1-58113-487- 8.
    [36]
    B. J. Svensson and J. Svenningsson. Defunctionalizing Push Arrays. In Proceedings of the 3rd ACM SIGPLAN Workshop on Functional High-performance Computing, FHPC ’14, pages 43–52, New York, NY, USA, 2014. ACM. ISBN 978-1-4503-3040-4.
    [37]
    W. Taha. A Gentle Introduction to Multi-stage Programming. In C. Lengauer, D. Batory, C. Consel, and M. Odersky, editors, Domain-Specific Program Generation, number 3016 in Lecture Notes in Computer Science, pages 30–50. Springer Berlin Heidelberg, 2004. ISBN 978-3-540-22119-7 978-3-540-25935-0.
    [38]
    P. L. Wadler. Deforestation: Transforming programs to eliminate trees. Theoretical Computer Science, 73(2):231–248, June 1990.
    [39]
    R. C. Waters. User manual for the series macro package. MIT AI Memo 1082, 1989.
    [40]
    R. C. Waters. Automatic transformation of series expressions into loops. ACM Trans. Program. Lang. Syst., 13(1):52–98, Jan. 1991. ISSN 0164-0925.

    Cited By

    View all
    • (2024)Mechanised Hypersafety Proofs about Structured DataProceedings of the ACM on Programming Languages10.1145/36564038:PLDI(647-670)Online publication date: 20-Jun-2024
    • (2024)Program generation meets program verificationScience of Computer Programming10.1016/j.scico.2023.103035232:COnline publication date: 1-Jan-2024
    • (2023)Energy Efficient Software in an Engineering CourseComposability, Comprehensibility and Correctness of Working Software10.1007/978-3-031-42833-3_3(77-97)Online publication date: 18-Oct-2023
    • Show More Cited By

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    cover image ACM Conferences
    POPL '17: Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages
    January 2017
    901 pages
    ISBN:9781450346603
    DOI:10.1145/3009837
    Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected].

    Sponsors

    In-Cooperation

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 01 January 2017

    Permissions

    Request permissions for this article.

    Check for updates

    Author Tags

    1. Code generation
    2. multi-stage programming
    3. optimization
    4. stream fusion
    5. streams

    Qualifiers

    • Research-article

    Conference

    POPL '17
    Sponsor:

    Acceptance Rates

    Overall Acceptance Rate 824 of 4,130 submissions, 20%

    Upcoming Conference

    POPL '25

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • Downloads (Last 12 months)70
    • Downloads (Last 6 weeks)8

    Other Metrics

    Citations

    Cited By

    View all
    • (2024)Mechanised Hypersafety Proofs about Structured DataProceedings of the ACM on Programming Languages10.1145/36564038:PLDI(647-670)Online publication date: 20-Jun-2024
    • (2024)Program generation meets program verificationScience of Computer Programming10.1016/j.scico.2023.103035232:COnline publication date: 1-Jan-2024
    • (2023)Energy Efficient Software in an Engineering CourseComposability, Comprehensibility and Correctness of Working Software10.1007/978-3-031-42833-3_3(77-97)Online publication date: 18-Oct-2023
    • (2022)Deep Fusion for Efficient Nested Recursive ComputationsProceedings of the 21st ACM SIGPLAN International Conference on Generative Programming: Concepts and Experiences10.1145/3564719.3568698(33-44)Online publication date: 29-Nov-2022
    • (2022)Composable Sequence Macros for Fast IterationProceedings of the 21st ACM SIGPLAN International Conference on Generative Programming: Concepts and Experiences10.1145/3564719.3568696(59-71)Online publication date: 29-Nov-2022
    • (2022)Coinduction inductively: mechanizing coinductive proofs in Liquid HaskellProceedings of the 15th ACM SIGPLAN International Haskell Symposium10.1145/3546189.3549922(1-12)Online publication date: 6-Sep-2022
    • (2022)Functional collection programming with semi-ring dictionariesProceedings of the ACM on Programming Languages10.1145/35273336:OOPSLA1(1-33)Online publication date: 29-Apr-2022
    • (2022)From functional to imperative: combining destination-passing style and viewsProceedings of the 8th ACM SIGPLAN International Workshop on Libraries, Languages and Compilers for Array Programming10.1145/3520306.3534502(25-36)Online publication date: 13-Jun-2022
    • (2022)Optimizing Parallel Java Streams2022 26th International Conference on Engineering of Complex Computer Systems (ICECCS)10.1109/ICECCS54210.2022.00012(23-32)Online publication date: Mar-2022
    • (2022)Unified Program Generation and Verification: A Case Study on Number-Theoretic TransformFunctional and Logic Programming10.1007/978-3-030-99461-7_8(133-151)Online publication date: 10-May-2022
    • Show More Cited By

    View Options

    Get Access

    Login options

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Media

    Figures

    Other

    Tables

    Share

    Share

    Share this Publication link

    Share on social media