• Stars
    star
    32
  • Rank 801,539 (Top 16 %)
  • Language
    F#
  • License
    GNU General Publi...
  • Created almost 3 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

πŸ”§ A type-safe, highly concurrent library for F# based on pure functional programming

Contributors Forks Stargazers Issues MIT License


FIO Logo


πŸ”§ 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 for Scala. FIO is both inspired by ZIO and 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:

(back to top)

Getting Started

It is easy to get started with FIO.

Prerequisites

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:

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}"

(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 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 <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:

  • 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 for more information.

(back to top)

Contact

Daniel Larsen (iyyel) - iyyel.io - [email protected]

(back to top)

Acknowledgments

(back to top)