An Optimised Flow for Futures: From Theory to Practice

07/15/2021
by   Nicolas Chappe, et al.
0

A future is an entity representing the result of an ongoing computation. A synchronisation with a "get" operation blocks the caller until the computation is over, to return the corresponding value. When a computation in charge of fulfilling a future delegates part of its processing to another task, mainstream languages return nested futures, and several "get" operations are needed to retrieve the computed value (we call such futures "control-flow futures"). Several approaches were proposed to tackle this issues: the "forward" construct, that allows the programmer to make delegation explicit and avoid nested futures, and "data-flow explicit futures" which natively collapse nested futures into plain futures. This paper supports the claim that data-flow explicit futures form a powerful set of language primitives, on top of which other approaches can be built. We prove the equivalence, in the context of data-flow explicit futures, between the "forward" construct and classical "return" from functions. The proof relies on a branching bisimulation between a program using "forward" and its "return" counterpart. This result allows language designers to consider "forward" as an optimisation directive rather than as a language primitive. Following the principles of the Godot system, we provide a library implementation of control-flow futures, based on data-flow explicit futures implemented in the compiler. This small library supports the claim that the implementation of classical futures based on data-flow ones is easier than the opposite. Our benchmarks show the viability of the approach from a performance point of view.

READ FULL TEXT

page 5

page 39

research
09/10/2020

Disjunctive Delimited Control

Delimited control is a powerful mechanism for programming language exten...
research
09/12/2023

Compositional Separation of Control Flow and Data Flow

Every constructive model of computation (CMC) has an underlying composit...
research
05/11/2023

Differentiable Programming: Efficient Smoothing of Control-Flow-Induced Discontinuities

We want to obtain derivatives in discontinuous program code, where defau...
research
07/18/2022

Bernoulli Factories for Flow-Based Polytopes

We construct explicit combinatorial Bernoulli factories for the class of...
research
06/01/2023

AI Chain on Large Language Model for Unsupervised Control Flow Graph Generation for Statically-Typed Partial Code

Control Flow Graphs (CFGs) are essential for visualizing, understanding ...
research
06/09/2011

A Knowledge Compilation Map

We propose a perspective on knowledge compilation which calls for analyz...
research
07/02/2022

LibNDT: Towards a Formal Library on Spreadable Properties over Linked Nested Datatypes

Nested datatypes have been widely studied in the past 25 years, both the...

Please sign up or login with your details

Forgot password? Click here to reset