Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/iyyel/fio

:wrench: A type-safe, highly concurrent library for F# based on pure functional programming
https://github.com/iyyel/fio

concurrency concurrent concurrent-programming fiber fibers fsharp functional-programing green-threads library parallel-computing parallel-programming programming programming-library runtime-system threads

Last synced: 4 months ago
JSON representation

:wrench: A type-safe, highly concurrent library for F# based on pure functional programming

Lists

README

        

[![Contributors][contributors-shield]][contributors-url]
[![Forks][forks-shield]][forks-url]
[![Stargazers][stars-shield]][stars-url]
[![Issues][issues-shield]][issues-url]
[![MIT License][license-shield]][license-url]





FIO Logo




:wrench: A type-safe, highly concurrent and asynchronous library for F# based on pure functional programming




Table of Contents



  1. About FIO



  2. Getting Started



  3. Usage


  4. Performance

  5. License

  6. Contact

  7. Acknowledgments

## About The Project

**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](https://zio.dev/) for Scala. **FIO** is both inspired by
[ZIO](https://zio.dev/) and [Cats Effect](https://typelevel.org/cats-effect/).

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

(back to top)

### Built With

**FIO** is built using the following technologies:

* [F#](https://fsharp.org/)
* [.NET 6.0](https://docs.microsoft.com/en-us/dotnet/core/whats-new/dotnet-6)

(back to top)

## Getting Started

It is easy to get started with **FIO**.

### Prerequisites

* Download and install [.NET 6.0](https://dotnet.microsoft.com/en-us/download/dotnet/6.0)
* Download and install a compatible IDE such as [Visual Studio](https://visualstudio.microsoft.com/downloads/) or [Rider](https://www.jetbrains.com/rider/download/)

### Installation

* Download or clone this repository
* Open it in your IDE of choice
* Navigate to the _Examples_ project and check out the example programs or create a new file to start using **FIO**

(back to top)

## Usage

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

```fsharp
open FSharp.FIO

[]
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}"
```

(back to top)

## Benchmarks

This repository contains five benchmarks that each tests an aspect of concurrent computing.
All benchmarks reside from the [Savina - An Actor Benchmark Suite](http://soft.vub.ac.be/AGERE14/papers/ageresplash2014_submission_19.pdf) paper.

* Pingpong (Message sending and retrieval)
* ThreadRing (Message sending and retrieval, context switching between fibers)
* Big (Contention on channel, many-to-many message passing)
* Bang (Many-to-one messaging)
* Spawn (Spawning time of fibers)

The benchmarks can be through the following command line options:

```
OPTIONS:

--naive-runtime specify naive runtime. (specify only one runtime)
--intermediate-runtime
specify eval worker count, blocking worker count and eval step count for intermediate
runtime. (specify only one runtime)
--advanced-runtime
specify eval worker count, blocking worker count and eval step count for advanced runtime.
(specify only one runtime)
--deadlocking-runtime
specify eval worker count, blocking worker count and eval step count for deadlocking
runtime. (specify only one runtime)
--runs specify the number of runs for each benchmark.
--process-increment
specify the value of process count increment and how many times.
--pingpong
specify round count for pingpong benchmark.
--threadring
specify process count and round count for threadring benchmark.
--big
specify process count and round count for big benchmark.
--bang
specify process count and round count for bang benchmark.
--spawn
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:

* **DETECT_DEADLOCK:** Enables a naive deadlock detecting thread that attempts to detect if a deadlock has occurred when running FIO programs
* **MONITOR:** Enables a monitoring thread that prints out data structure content during when running FIO programs

(back to top)

## 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**

Threadring scalability plot

* **Big**

Threadring scalability plot

* **Bang**

Threadring scalability plot

* **Spawn**

Threadring scalability plot

(back to top)

## License

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

(back to top)

## Contact

Daniel Larsen (iyyel) - [iyyel.io](https://iyyel.io) - [[email protected]](mailto:[email protected])

(back to top)

## Acknowledgments

* Alceste Scalas - [alcsc](https://people.compute.dtu.dk/alcsc/) - [github](https://github.com/alcestes)

(back to top)

[contributors-shield]: https://img.shields.io/github/contributors/iyyel/fio.svg?style=for-the-badge
[contributors-url]: https://github.com/iyyel/fio/graphs/contributors
[forks-shield]: https://img.shields.io/github/forks/iyyel/fio.svg?style=for-the-badge
[forks-url]: https://github.com/iyyel/fio/network/members
[stars-shield]: https://img.shields.io/github/stars/iyyel/fio.svg?style=for-the-badge
[stars-url]: https://github.com/iyyel/fio/stargazers
[issues-shield]: https://img.shields.io/github/issues/iyyel/fio.svg?style=for-the-badge
[issues-url]: https://github.com/iyyel/fio/issues
[license-shield]: https://img.shields.io/github/license/iyyel/fio.svg?style=for-the-badge
[license-url]: https://github.com/iyyel/fio/blob/main/LICENSE.md