Simplifying explicit subtyping coercions in a polymorphic calculus with effects

Filip Koprivec,Matija Pretnar
2024-04-06
Abstract:Algebraic effect handlers are becoming increasingly popular way of structuring and reasoning about effectful computations, and their performance is often a concern. One of the proposed approaches towards efficient compilation is tracking effect information through explicit subtyping coercions. However, in the presence of polymorphism, these coercions are compiled to additional arguments of compiled functions, incurring significant overhead.
Programming Languages
What problem does this paper attempt to address?
### What problem does this paper attempt to solve? This paper aims to solve the performance overhead problem caused by explicit subtyping coercions in programming languages with polymorphism and effects. Specifically: 1. **Background problems**: - **Algebraic effect handlers**: These mechanisms allow programmers to handle computations with side effects in a structured way. However, their performance often becomes the focus of attention. - **The need for an optimizing compiler**: In order to improve performance, it is necessary to develop an optimizing compiler that can effectively track and handle effect information. 2. **Limitations of existing methods**: - In current methods, effect information is tracked through explicit subtyping coercions. For polymorphic functions, these coercions need to be passed as additional parameters, resulting in significant runtime overhead. - As the size of the program grows, the number of automatically - derived coercions also increases, further degrading performance. 3. **Goals of the paper**: - Propose an algorithm that can reduce or even completely eliminate redundant coercion parameters, so that the performance of the compiled code is close to that of manually monomorphised code. - Ensure that the simplification process does not change the semantics of the program, that is, maintain semantic equivalence. 4. **Specific contributions**: - **Identify the requirements of the simplification stage**: Determine the requirements for the correctness of the simplification algorithm stage in the type system. - **Simplify constraints step by step**: Propose multiple stages of step - by - step simplification to reduce unnecessary constraints. - **Proof of semantic preservation**: Prove that all proposed simplification operations preserve the denotational semantics. - **Implementation and evaluation**: Implement the simplification algorithm in the Eff language and evaluate its impact on code size and runtime performance. Through these efforts, the author hopes to provide an efficient and maintainable compilation method in programming languages that support algebraic effect handlers, thereby improving performance in practical applications.