Title | : | Effectively composing concurrency libraries |
Speaker | : | Deepali Narendra Ande (IITM) |
Details | : | Tue, 14 Mar, 2023 11:00 AM @ SSB 233 |
Abstract: | : | Effect handlers provide a programming abstraction for manipulating control flow in the program using delimited continuation, making them an excellent choice for concurrent, parallel, asynchronous program implementation. OCaml 5 introduces effect handlers as a mechanism for concurrent programming in direct style. To run tasks concurrently, a task scheduler is required. Baking in the task scheduler in compiler or runtime makes it monolithic and complex to modify and maintain Using effect handlers, however, we may build our own concurrency library with its own task scheduler. Each library and its scheduler are fine-tuned for specific functionality, making it simple to manage the library. Each library has its own scheduling strategy to manage its tasks, where notion of a task is also unique to the scheduler. When several such libraries are utilised concurrently in an application, tasks from various schedulers do not interact well. They are unaware of one another's existence and can hamper the progress of other tasks. Thus, there is a need for synchronization across various library schedulers. If we do not address this issue, the majority of these libraries will stay incompatible. It creates a schism in the programming language’s library ecosystem. Many a times, applications need to be rewritten in order to use a different library or they end up reliant on a single library throughout. Improper task synchronization can negatively impact the performance of an application. In our research work, we observe that the composability of effect handlers permits composability of schedulers. The key idea is that we can use effect handlers to define a uniform interface for suspending and resuming tasks, which is implemented by each of the schedulers. On top of this, we define scheduler-agnostic synchronization structures that allows tasks from different schedulers to interact. We also discuss on how this mechanism can be extended to capture the notion of task cancellation that extends across different schedulers. The similar concept can be applied to the composition of monadic libraries with effect-based libraries. This is advantageous for numerous real-world applications that utilise legacy monadic libraries. |