Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
research-article
Open access

Effects for efficiency: asymptotic speedup with first-class control

Published: 03 August 2020 Publication History
  • Get Citation Alerts
  • Abstract

    We study the fundamental efficiency of delimited control. Specifically, we show that effect handlers enable an asymptotic improvement in runtime complexity for a certain class of functions. We consider the generic count problem using a pure PCF-like base language λb and its extension with effect handlers λh.
    We show that λh admits an asymptotically more efficient implementation of generic count than any λb implementation.
    We also show that this efficiency gap remains when λb is extended with mutable state.
    To our knowledge this result is the first of its kind for control operators.

    Supplementary Material

    Presentation at ICFP '20 (a100-hillerstrom-presentation.mp4)

    References

    [1]
    Andrej Bauer. 2018. What is algebraic about algebraic efects and handlers? CoRR abs/ 1807.05923 ( 2018 ).
    [2]
    Andrej Bauer and Matija Pretnar. 2015. Programming with algebraic efects and handlers. J. Log. Algebr. Meth. Program. 84, 1 ( 2015 ), 108-123.
    [3]
    Jordan Bell and Brett Stevens. 2009. A survey of known results and research areas for n-queens. Discret. Math. 309, 1 ( 2009 ), 1-31.
    [4]
    Nick Benton and Andrew Kennedy. 2001. Exceptional Syntax Journal of Functional Programming. J. Funct. Program. 11, 4 ( 2001 ), 395-410.
    [5]
    Ulrich Berger. 1990. Totale Objekte und Mengen in der Bereichstheorie. Ph.D. Dissertation. Ludwig Maximillians-Universtität, Munich.
    [6]
    Dariusz Biernacki, Maciej Piróg, Piotr Polesiuk, and Filip Sieczkowski. 2019. Abstracting algebraic efects. PACMPL 3, POPL ( 2019 ), 6 : 1-6 : 28.
    [7]
    Dariusz Biernacki, Maciej Piróg, Piotr Polesiuk, and Filip Sieczkowski. 2020. Binders by day, labels by night: efect instances via lexically scoped handlers. PACMPL 4, POPL ( 2020 ), 48 : 1-48 : 29.
    [8]
    Richard Bird, Geraint Jones, and Oege de Moor. 1997. More haste less speed: lazy versus eager evaluation. J. Funct. Program. 7, 5 ( 1997 ), 541-547.
    [9]
    Richard S. Bird. 2006. Functional Pearl : A program to solve Sudoku. J. Funct. Program. 16, 6 ( 2006 ), 671-679.
    [10]
    Robert Cartwright and Matthias Felleisen. 1992. Observable Sequentiality and Full Abstraction. In POPL. ACM Press, 328-342.
    [11]
    Lukas Convent, Sam Lindley, Conor McBride, and Craig McLaughlin. 2020. Doo bee doo bee doo. J. Funct. Program. 30 ( 2020 ). To appear.
    [12]
    Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Cliford Stein. 2009. Introduction to Algorithms, Third Edition (3rd ed.). MIT Press.
    [13]
    Robbie Daniels. 2016. Eficient Generic Searches and Programming Language Expressivity. Master's thesis. School of Informatics, the University of Edinburgh, Scotland. http://homepages.inf.ed.ac.uk/jrl/Research/Robbie_Daniels_MSc_dissertation.pdf
    [14]
    Olivier Danvy and Andrzej Filinski. 1990. Abstracting Control. In LISP and Functional Programming. ACM, 151-160.
    [15]
    Stephen Dolan, Leo White, KC Sivaramakrishnan, Jeremy Yallop, and Anil Madhavapeddy. 2015. Efective Concurrency through Algebraic Efects. OCaml Workshop.
    [16]
    Martín Hötzel Escardó. 2007. Infinite sets that admit fast exhaustive search. In LICS. IEEE Computer Society, 443-452.
    [17]
    Kavon Farvardin and John H. Reppy. 2020. From folklore to fact: comparing implementations of stacks and continuations. In PLDI. ACM, 75-90.
    [18]
    Matthias Felleisen. 1987. The Calculi of Lambda-nu-cs Conversion: A Syntactic Theory of Control and State in Imperative Higher-order Programming Languages. Ph.D. Dissertation. Indianapolis, IN, USA. AAI8727494.
    [19]
    Matthias Felleisen. 1988. The Theory and Practice of First-Class Prompts. In POPL. ACM Press, 180-190.
    [20]
    Matthias Felleisen. 1991. On the expressive power of programming languages. Sci. Comput. Prog. 17, 1-3 ( 1991 ), 35-75.
    [21]
    Matthias Felleisen and Daniel P. Friedman. 1987. Control Operators, the SECD-machine, and the λ-Calculus. In The Proceedings of the Conference on Formal Description of Programming Concepts III, Ebberup, Denmark. Elsevier, 193-217.
    [22]
    Cormac Flanagan, Amr Sabry, Bruce F. Duba, and Matthias Felleisen. 1993. The Essence of Compiling with Continuations. In PLDI. ACM, 237-247.
    [23]
    Matthew Flatt and R. Kent Dybvig. 2020. Compiler and runtime support for continuation marks. In PLDI. ACM, 45-58.
    [24]
    Yannick Forster, Ohad Kammar, Sam Lindley, and Matija Pretnar. 2019. On the expressive power of user-defined efects: Efect handlers, monadic reflection, delimited control. J. Funct. Program. 29 ( 2019 ), e15.
    [25]
    Daniel Hillerström and Sam Lindley. 2016. Liberating efects with rows and handlers. In TyDe@ICFP. ACM, 15-27.
    [26]
    Daniel Hillerström and Sam Lindley. 2018. Shallow Efect Handlers. In APLAS (Lecture Notes in Computer Science, Vol. 11275 ). Springer, 415-435.
    [27]
    Daniel Hillerström, Sam Lindley, and Robert Atkey. 2020a. Efect handlers via generalised continuations. J. Funct. Program. 30 ( 2020 ), e5.
    [28]
    Daniel Hillerström, Sam Lindley, Robert Atkey, and K. C. Sivaramakrishnan. 2017. Continuation Passing Style for Efect Handlers. In FSCD (LIPIcs, Vol. 84 ). Schloss Dagstuhl-Leibniz-Zentrum fuer Informatik, 18 : 1-18 : 19.
    [29]
    Daniel Hillerström, Sam Lindley, and John Longley. 2020b. Efects for Eficiency: Asymptotic Speedup with First-Class Control (extended version). arXiv:2007. 00605 [cs.PL]
    [30]
    John Hughes. 1986. A Novel Representation of Lists and its Application to the Function "reverse". Inf. Process. Lett. 22, 3 ( 1986 ), 141-144.
    [31]
    Neil Jones. 2001. The expressive power of higher-order types, or, life without CONS. J. Funct. Program. 11 ( 2001 ), 5-94.
    [32]
    Ohad Kammar, Sam Lindley, and Nicolas Oury. 2013. Handlers in action. In ICFP. ACM, 145-158.
    [33]
    Oleg Kiselyov, Amr Sabry, and Cameron Swords. 2013. Extensible efects: an alternative to monad transformers. In Haskell. ACM, 59-70.
    [34]
    Oleg Kiselyov, Chung-chieh Shan, Daniel P. Friedman, and Amr Sabry. 2005. Backtracking, Interleaving, and Terminating Monad Transformers: (Functional Pearl). ( 2005 ), 192-203.
    [35]
    Donald Knuth. 1997. The Art of Computer Programming, Volume 1 : Fundamental Algorithms (third edition). Addison-Wesley.
    [36]
    Daan Leijen. 2017. Type directed compilation of row-typed algebraic efects. In POPL. ACM, 486-499.
    [37]
    Paul Blain Levy, John Power, and Hayo Thielecke. 2003. Modelling environments in call-by-value programming languages. Inf. Comput. 185, 2 ( 2003 ), 182-210.
    [38]
    Sam Lindley, Conor McBride, and Craig McLaughlin. 2017. Do be do be do. In POPL. ACM, 500-514.
    [39]
    John Longley. 1999. When is a functional program not a functional program?. In ICFP. ACM, 1-7.
    [40]
    John Longley. 2018. The recursion hierarchy for PCF is strict. Logical Methods in Comput. Sci. 14, 3 : 8 ( 2018 ), 1-51.
    [41]
    John Longley. 2019. Bar recursion is not computable via iteration. Computability 8, 2 ( 2019 ), 119-153.
    [42]
    John Longley and Dag Normann. 2015. Higher-Order Computability. Springer.
    [43]
    Robin Milner. 1977. Fully Abstract Models of Typed λ-Calculi. Theor. Comput. Sci. 4, 1 ( 1977 ), 1-22.
    [44]
    MLton. 2020. MLton website. http://www.mlton.org
    [45]
    Eugenio Moggi. 1991. Notions of Computation and Monads. Inf. Comput. 93, 1 ( 1991 ), 55-92.
    [46]
    Chris Okasaki. 1999. Purely functional data structures. Cambridge University Press.
    [47]
    Nicholas Pippenger. 1996. Pure versus impure Lisp. In POPL. ACM, 104-109.
    [48]
    Maciej Piróg, Piotr Polesiuk, and Filip Sieczkowski. 2019. Typed Equivalence of Efect Handlers and Delimited Control. In FSCD (LIPIcs, Vol. 131 ). Schloss Dagstuhl-Leibniz-Zentrum fuer Informatik, 30 : 1-30 : 16.
    [49]
    Gordon Plotkin. 1977. LCF considered as a programming language. Theor. Comput. Sci. 5, 3 ( 1977 ), 223-255.
    [50]
    Gordon D. Plotkin and John Power. 2001. Adequacy for Algebraic Efects. In FoSSaCS (Lecture Notes in Computer Science, Vol. 2030 ). Springer, 1-24.
    [51]
    Gordon D. Plotkin and Matija Pretnar. 2013. Handling Algebraic Efects. Logical Methods in Computer Science 9, 4 ( 2013 ).
    [52]
    Matija Pretnar. 2015. An Introduction to Algebraic Efects and Handlers. Electr. Notes Theor. Comput. Sci. 319 ( 2015 ), 19-35. Invited tutorial paper.
    [53]
    Dana Scott and Christopher Strachey. 1971. Proceedings of the Symposium on Computers and Automata 21 ( 1971 ).
    [54]
    Alex K. Simpson. 1998. Lazy Functional Algorithms for Exact Real Functionals. In MFCS (Lecture Notes in Computer Science, Vol. 1450 ). Springer, 456-464.
    [55]
    SML /NJ. 2020. SML/NJ website. http://www.smlnj.org
    [56]
    Michael Sperber, Kent R. Dybvig, Matthew Flatt, Anton van Stratten, Robby Bruce Findler, and Jacob Matthews. 2009. Revised6 Report on the Algorithmic Language Scheme. J. Funct. Program. 19, S1 ( 2009 ), 1-301.

    Cited By

    View all
    • (2024)Soundly Handling LinearityProceedings of the ACM on Programming Languages10.1145/36328968:POPL(1600-1628)Online publication date: 5-Jan-2024
    • (2024)Asymptotic speedup via effect handlersJournal of Functional Programming10.1017/S095679682400003034Online publication date: 5-Apr-2024

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    cover image Proceedings of the ACM on Programming Languages
    Proceedings of the ACM on Programming Languages  Volume 4, Issue ICFP
    August 2020
    1070 pages
    EISSN:2475-1421
    DOI:10.1145/3415018
    Issue’s Table of Contents
    This work is licensed under a Creative Commons Attribution International 4.0 License.

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 03 August 2020
    Published in PACMPL Volume 4, Issue ICFP

    Permissions

    Request permissions for this article.

    Check for updates

    Badges

    Author Tags

    1. asymptotic complexity analysis
    2. effect handlers
    3. generic search

    Qualifiers

    • Research-article

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • Downloads (Last 12 months)99
    • Downloads (Last 6 weeks)11
    Reflects downloads up to 10 Aug 2024

    Other Metrics

    Citations

    Cited By

    View all
    • (2024)Soundly Handling LinearityProceedings of the ACM on Programming Languages10.1145/36328968:POPL(1600-1628)Online publication date: 5-Jan-2024
    • (2024)Asymptotic speedup via effect handlersJournal of Functional Programming10.1017/S095679682400003034Online publication date: 5-Apr-2024

    View Options

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Get Access

    Login options

    Full Access

    Media

    Figures

    Other

    Tables

    Share

    Share

    Share this Publication link

    Share on social media