Home

Awesome

Contributors Forks Stargazers Issues MIT License

<br /> <div align="center"> <a href="https://github.com/iyyel/fio"> <img src="images/fio_logo_wide.png" width="auto" height="300" alt="FIO Logo"> </a> <p align="center"> <br /> 🪻 A type-safe, highly concurrent and asynchronous library for F# based on pure functional programming <br /> </p> </div>

Table of Contents

Introduction

FIO is a type-safe, highly concurrent and asynchronous library for F# that is based on principles from pure functional programming. It provides a construct known as the IO monad for handling expressions with side effects. It uses the concept of "green threads" also known as "fibers" to provide scalable and efficient concurrency.

FIO is an attempt at creating a similar environment to that of ZIO for Scala. FIO is both inspired by ZIO and Cats Effect.

FIO was developed as part of a master's thesis in Computer Science and Engineering at the Technical University of Denmark (DTU). You can read the thesis, which provides more details about FIO, here.

DISCLAIMER: FIO is in early development stages and a lot of improvements and enhancements can be made. This README might be lackluster.

Built With

FIO is built using the following technologies:

Getting Started

It is easy to get started with FIO.

Usage

Create a new class and import the library using "open FSharp.FIO". For example:

open FSharp.FIO

[<EntryPoint>]
let main _ =
  let askForName =
    fio (fun () -> printfn "%s" "Hello! What is your name?")
    >> fun _ ->
    fio (fun () -> Console.ReadLine())
    >> fun name ->
    fio (fun () -> printfn $"Hello, %s{name}, welcome to FIO!")

  let fiber = Advanced.Runtime().Run askForName
  let result = fiber.Await()
  printfn $"%A{result}"

Benchmarks

This repository contains five benchmarks that each tests an aspect of concurrent computing. All benchmarks reside from the Savina - An Actor Benchmark Suite paper.

The benchmarks can be given the following command line options:

OPTIONS:

    --naive-runtime       specify naive runtime. (specify only one runtime)
    --intermediate-runtime <evalworkercount> <blockingworkercount> <evalstepcount>
                          specify eval worker count, blocking worker count and eval step count for intermediate
                          runtime. (specify only one runtime)
    --advanced-runtime <evalworkercount> <blockingworkercount> <evalstepcount>
                          specify eval worker count, blocking worker count and eval step count for advanced runtime.
                          (specify only one runtime)
    --deadlocking-runtime <evalworkercount> <blockingworkercount> <evalstepcount>
                          specify eval worker count, blocking worker count and eval step count for deadlocking
                          runtime. (specify only one runtime)
    --runs <runs>         specify the number of runs for each benchmark.
    --process-increment <processcountinc> <inctimes>
                          specify the value of process count increment and how many times.
    --pingpong <roundcount>
                          specify round count for pingpong benchmark.
    --threadring <processcount> <roundcount>
                          specify process count and round count for threadring benchmark.
    --big <processcount> <roundcount>
                          specify process count and round count for big benchmark.
    --bang <processcount> <roundcount>
                          specify process count and round count for bang benchmark.
    --spawn <processcount>
                          specify process count for spawn benchmark.
    --help                display this list of options.           display this list of options.

For example, running 30 runs of each benchmark using the advanced runtime with 7 evaluation workers, 1 blocking worker and 15 evaluation steps would look as so:

--advanced-runtime 7 1 15 --runs 30 --pingpong 120000 --threadring 2000 1 --big 500 1 --bang 3000 1 --spawn 3000

Additionally, the FIO project supports two conditional compilation options:

DISCLAIMER: These features are very experimental.

Performance

Below the scalability of each interpreter can be seen for each benchmark. I is denoting the intermediate runtime and A the advanced. To give some insight into the interpreters, the naive interpreter uses operating system threads, the intermediate uses fibers with handling of blocked FIO programs in linear time, and the advanced uses fibers with constant time handling.

Threadring

<img src="images/threadring_scalability_plot.png" width="auto" height="500" alt="Threadring scalability plot">

Big

<img src="images/big_scalability_plot.png" width="auto" height="500" alt="Threadring scalability plot">

Bang

<img src="images/bang_scalability_plot.png" width="auto" height="500" alt="Threadring scalability plot">

Spawn

<img src="images/spawn_scalability_plot.png" width="auto" height="500" alt="Threadring scalability plot">

License

Distributed under the GNU General Public License v3.0. See LICENSE.md for more information.

Contact

Daniel Larsen (iyyel) - iyyel.io - hello@iyyel.io

Acknowledgments

Alceste Scalas - alcsc - github

<!-- MARKDOWN LINKS & IMAGES -->