{"id":24013455,"url":"https://github.com/fio-fsharp/fio","last_synced_at":"2025-04-15T09:44:12.706Z","repository":{"id":49685507,"uuid":"445239025","full_name":"fio-fsharp/fio","owner":"fio-fsharp","description":"🪻A type-safe and highly concurrent library for F# based on pure functional programming","archived":false,"fork":false,"pushed_at":"2025-02-19T18:59:10.000Z","size":3836,"stargazers_count":42,"open_issues_count":1,"forks_count":0,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-03-28T09:38:37.215Z","etag":null,"topics":["concurrency","concurrent","concurrent-programming","fiber","fibers","fsharp","functional-programing","green-threads","library","parallel-computing","parallel-programming","programming","programming-library","runtime-system","threads"],"latest_commit_sha":null,"homepage":"https://iyyel.io/projects/fio/","language":"F#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fio-fsharp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-06T16:36:06.000Z","updated_at":"2025-03-19T11:28:12.000Z","dependencies_parsed_at":"2024-10-31T06:30:19.437Z","dependency_job_id":"88b489fd-32ad-462d-99bf-753fe9a3f87f","html_url":"https://github.com/fio-fsharp/fio","commit_stats":null,"previous_names":["fio-fsharp/fio"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fio-fsharp%2Ffio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fio-fsharp%2Ffio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fio-fsharp%2Ffio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fio-fsharp%2Ffio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fio-fsharp","download_url":"https://codeload.github.com/fio-fsharp/fio/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247423513,"owners_count":20936626,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["concurrency","concurrent","concurrent-programming","fiber","fibers","fsharp","functional-programing","green-threads","library","parallel-computing","parallel-programming","programming","programming-library","runtime-system","threads"],"created_at":"2025-01-08T06:54:46.400Z","updated_at":"2025-04-15T09:44:12.690Z","avatar_url":"https://github.com/fio-fsharp.png","language":"F#","readme":"[![Contributors][contributors-shield]][contributors-url]\n[![Forks][forks-shield]][forks-url]\n[![Stargazers][stars-shield]][stars-url]\n[![Issues][issues-shield]][issues-url]\n[![MIT License][license-shield]][license-url]\n[![NuGet][nuget-shield]][nuget-url]\n\n\n\n\u003cbr /\u003e\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://github.com/fio-fsharp/fio\"\u003e\n    \u003cimg src=\"assets/images/fio_logo_wide.png\" width=\"auto\" height=\"300\" alt=\"FIO Logo\"\u003e\n  \u003c/a\u003e\n\n  \u003cp align=\"center\"\u003e\n    \u003cbr /\u003e\n    🪻 A type-safe, highly concurrent and asynchronous library for F# based on pure functional programming\n    \u003cbr /\u003e\n  \u003c/p\u003e\n\u003c/div\u003e\n\n\n\n## Table of Contents\n- [Introduction](#introduction)\n- [Built With](#built-with)\n- [Getting Started](#getting-started)\n- [Usage](#usage)\n- [Benchmarks](#benchmarks)\n- [Performance](#performance)\n- [License](#license)\n- [Contact](#contact)\n- [Acknowledgments](#acknowledgments)\n\n\n\n## Introduction\n**FIO** is a type-safe, highly concurrent and asynchronous library for the [**F#**](https://fsharp.org/) programming language. Based on pure functional programming principles, it serves as an embedded [**domain-specific language (DSL)**](https://martinfowler.com/dsl.html) empowering developers to craft type-safe, concurrent and maintainable programs with ease using functional effects.\n\nHarnessing concepts from functional programming, **FIO** simplifies the creation of scalable and efficient concurrent applications. It introduces the **IO monad** to manage expressions with side effects and employs “green threads” (also known as fibers) for scalable and efficient concurrency. **FIO** aims to provide an environment similar to that of [**ZIO**](https://zio.dev/), drawing inspiration from both [**ZIO**](https://zio.dev/) and [**Cats Effect**](https://typelevel.org/cats-effect/).\n\n**FIO** was initially developed as part of a master's thesis in Computer Science and Engineering at the [**Technical University of Denmark (DTU)**](https://www.dtu.dk/english/). You can read the thesis, which provides more details about **FIO**, [**here**](https://iyyel.io/assets/doc/masters_thesis_daniel_larsen.pdf). Some parts may be outdated as development continues.\n\n**DISCLAIMER:** **FIO** is in early development stages and a lot of improvements and enhancements can be made. If you think the project sounds interesting, do not hesitate to create a PR or contact me for further information or assistance.\n\n\n\n## Built With\n**FIO** is built using the following technologies:\n\n* [**F#**](https://fsharp.org/)\n* [**.NET**](https://dotnet.microsoft.com/en-us/)\n\n\n\n## Getting Started\nIt is easy to get started with **FIO**.\n\n* Download and install [**.NET**](https://dotnet.microsoft.com/en-us/)\n* Download and install a compatible IDE such as [**Visual Studio**](https://visualstudio.microsoft.com/downloads/) or [**Rider**](https://www.jetbrains.com/rider/download/), or a text editor like [**Visual Studio Code**](https://code.visualstudio.com/)\n\n* Download or clone this repository\n* Open it in your IDE or text editor of choice\n* Navigate to the [**FIO.Examples**](https://github.com/fio-fsharp/fio/tree/dev/src/FIO.Examples) project and check out the example programs or create a new F# file to start using **FIO**\n\n\n\n## Usage\n\nThere are currently two ways of using **FIO**. It is possible to create effects directly and execute them using one of **FIO**'s runtime systems. This gives the developer more control over the runtime and how the effect is executed. In addition, the core **FIO** library provides a **FIOApp** type which encapsulates elements such as the runtime which may not be important for the developer.\n\n### Direct usage of effects\nCreate a new F# file and import the library using ```open FIO.Core``` in either the cloned repository or a project with the **FIO** NuGet package installed. To use **FIO**'s advanced runtime, add ```open FIO.Runtime.Advanced``` as well. For example:\n\n```fsharp\nmodule DirectUsage\n\nopen System\n\nopen FIO.Core\nopen FIO.Runtime.Advanced\n\n[\u003cEntryPoint\u003e]\nlet main _ =\n    let askForName = fio {\n        do! !+ printfn(\"Hello! What is your name?\")\n        let! name = !+ Console.ReadLine()\n        do! !+ printfn($\"Hello, %s{name}, welcome to FIO! 🪻💜\")\n    }\n\n    let fiber = AdvancedRuntime().Run askForName\n    let result = fiber.AwaitResult()\n    printfn $\"%A{result}\"\n    exit 0\n```\n\nYou can then execute the program with\n\n```$ dotnet run```\n\nand you'll see\n\n```\nHello! What is your name?\nDaniel\nHello, Daniel, welcome to FIO! 🪻💜\nOk ()\n```\n\n### FIOApp usage\n\nIn general it is recommended to create a type extending the **FIOApp** type. A **FIOApp** is essentially a wrapper around the effect which hides elements such as the runtime system and makes it possible to write cleaner **FIO** programs. For example:\n\n```fsharp\nmodule FIOAppUsage\n\nopen System\n\nopen FIO.Core\n\ntype WelcomeApp() =\n    inherit FIOApp\u003cunit, obj\u003e()\n\n    override this.effect = fio {\n        do! !+ printfn(\"Hello! What is your name?\")\n        let! name = !+ Console.ReadLine()\n        do! !+ printfn($\"Hello, %s{name}, welcome to FIO! 🪻💜\")\n    }\n  \nWelcomeApp().Run()\n```\n\nOnce again, you can execute the **FIOApp** using\n\n```$ dotnet run```\n\nand you'll see the same result as before\n\n```\nHello! What is your name?\nDaniel\nHello, Daniel, welcome to FIO! 🪻💜\nOk ()\n```\n\n**Side note:** It is also possible to avoid using the **FIO** computation expression and instead directly use the **FIO** DSL. The above example would then look like this:\n\n```fsharp\nlet askForName =\n    !+ printfn(\"Hello! What is your name?\") \u003e\u003e= fun _ -\u003e\n    !+ Console.ReadLine() \u003e\u003e= fun name -\u003e\n    !+ printfn($\"Hello, %s{name}, welcome to FIO! 🪻💜\")\n```\n\nwhere ```\u003e\u003e=``` is **FIO**'s bind function.\n\n\n\n## Benchmarks\nThis repository contains five benchmarks that each test an aspect of concurrent computing.\nAll benchmarks reside from the [**Savina - An Actor Benchmark Suite**](http://soft.vub.ac.be/AGERE14/papers/ageresplash2014_submission_19.pdf) paper.\n\n* Pingpong (Message sending and retrieval)\n* ThreadRing (Message sending and retrieval, context switching between fibers)\n* Big (Contention on channel, many-to-many message passing)\n* Bang (Many-to-one messaging)\n* Fork (Spawning time of fibers)\n\nThe benchmarks can be given the following command line options:\n\n```\nUSAGE: FIO.Benchmarks [--help] [--native-runtime] [--intermediate-runtime \u003cevalworkers\u003e \u003cblockingworkers\u003e \u003cevalsteps\u003e]\n                      [--advanced-runtime \u003cevalworkers\u003e \u003cblockingworkers\u003e \u003cevalsteps\u003e]\n                      [--deadlocking-runtime \u003cevalworkers\u003e \u003cblockingworkers\u003e \u003cevalsteps\u003e] --runs \u003cruns\u003e\n                      [--process-increment \u003cactor inc\u003e \u003cinc times\u003e] [--pingpong \u003crounds\u003e]\n                      [--threadring \u003cactors\u003e \u003crounds\u003e] [--big \u003cactors\u003e \u003crounds\u003e] [--bang \u003cactors\u003e \u003crounds\u003e]\n                      [--fork \u003cactors\u003e]\n\nOPTIONS:\n\n    --native-runtime       specify native runtime.\n    --intermediate-runtime \u003cevalworkers\u003e \u003cblockingworkers\u003e \u003cevalsteps\u003e\n                          specify evaluation workers, blocking workers and eval steps for intermediate runtime.\n    --advanced-runtime \u003cevalworkers\u003e \u003cblockingworkers\u003e \u003cevalsteps\u003e\n                          specify evaluation workers, blocking workers and eval steps for advanced runtime.\n    --deadlocking-runtime \u003cevalworkers\u003e \u003cblockingworkers\u003e \u003cevalsteps\u003e\n                          specify evaluation workers, blocking workers and eval steps for deadlocking runtime.\n    --runs \u003cruns\u003e         specify the number of runs for each benchmark.\n    --process-increment \u003cactor inc\u003e \u003cinc times\u003e\n                          specify the value of actor increment and how many times.\n    --pingpong \u003crounds\u003e   specify rounds for pingpong benchmark.\n    --threadring \u003cactors\u003e \u003crounds\u003e\n                          specify actors and rounds for threadring benchmark.\n    --big \u003cactors\u003e \u003crounds\u003e\n                          specify actors and rounds for big benchmark.\n    --bang \u003cactors\u003e \u003crounds\u003e\n                          specify actors and rounds for bang benchmark.\n    --fork \u003cactors\u003e       specify actors for fork benchmark.\n    --help                display this list of options.\n```\n\nFor 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:\n\n```\n--advanced-runtime 7 1 15 --runs 30 --pingpong 120000 --threadring 2000 1 --big 500 1 --bang 3000 1 --fork 3000\n```\n\nAdditionally, **FIO** supports two conditional compilation options:\n\n* **DETECT_DEADLOCK:** Enables a naive deadlock detecting thread that attempts to detect if a deadlock has occurred when running **FIO** programs\n* **MONITOR:** Enables a monitoring thread that prints out data structure content during when running **FIO** programs\n\n**DISCLAIMER:** These features are very experimental and may not work as intended.\n\n\n\n## Performance\nBelow the scalability of each runtime system can be seen for each benchmark. **I** is denoting the intermediate runtime and **A** the advanced. To give some insight into the runtimes, the naive runtime uses operating system threads, the intermediate uses fibers with handling of blocked fibers in linear time, and the advanced uses fibers with constant time handling.\n\n#### **Threadring**\n\u003cimg src=\"assets/images/threadring_scalability_plot.png\" width=\"auto\" height=\"500\" alt=\"Threadring scalability plot\"\u003e\n \n#### **Big**\n\u003cimg src=\"assets/images/big_scalability_plot.png\" width=\"auto\" height=\"500\" alt=\"Big scalability plot\"\u003e\n\n#### **Bang**\n\u003cimg src=\"assets/images/bang_scalability_plot.png\" width=\"auto\" height=\"500\" alt=\"Bang scalability plot\"\u003e\n\n#### **Fork** (previously called Spawn)\n\u003cimg src=\"assets/images/spawn_scalability_plot.png\" width=\"auto\" height=\"500\" alt=\"Fork scalability plot\"\u003e\n\n\n\n## License\nDistributed under the GNU General Public License v3.0. See [**LICENSE.md**](LICENSE.md) for more information.\n\n\n\n## Contact\nDaniel Larsen (iyyel) - [**iyyel.io**](https://iyyel.io) - [**me@iyyel.io**](mailto:me@iyyel.io)\n\n\n\n## Acknowledgments\nAlceste Scalas - [**alcsc**](https://people.compute.dtu.dk/alcsc/) - [**github**](https://github.com/alcestes)\n\n\n\n\u003c!-- MARKDOWN LINKS \u0026 IMAGES --\u003e\n[contributors-shield]: https://img.shields.io/github/contributors/fio-fsharp/fio.svg?style=for-the-badge\n[contributors-url]: https://github.com/fio-fsharp/fio/graphs/contributors\n[forks-shield]: https://img.shields.io/github/forks/fio-fsharp/fio.svg?style=for-the-badge\n[forks-url]: https://github.com/fio-fsharp/fio/network/members\n[stars-shield]: https://img.shields.io/github/stars/fio-fsharp/fio.svg?style=for-the-badge\n[stars-url]: https://github.com/fio-fsharp/fio/stargazers\n[issues-shield]: https://img.shields.io/github/issues/fio-fsharp/fio.svg?style=for-the-badge\n[issues-url]: https://github.com/fio-fsharp/fio/issues\n[license-shield]: https://img.shields.io/github/license/fio-fsharp/fio.svg?style=for-the-badge\n[license-url]: https://github.com/fio-fsharp/fio/blob/main/LICENSE.md\n[nuget-shield]: https://img.shields.io/nuget/v/FIO.svg?style=for-the-badge\n[nuget-url]: https://www.nuget.org/packages/FIO/0.0.9-alpha\n","funding_links":[],"categories":["F#"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffio-fsharp%2Ffio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffio-fsharp%2Ffio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffio-fsharp%2Ffio/lists"}