7

Github [RFC FS-1087, FS-1097, FS-1098] tasks, resumable state machines, inline o...

 3 years ago
source link: https://github.com/dotnet/fsharp/pull/6811
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Copy link

Contributor

dsyme commented on May 22, 2019

edited

Continuation of #6634 from a feature branch

RFC FS-1087 resumable code

RFC FS-1097 task builder

RFC FS-1098 inline if lambda

F# Tooling RFC FST-1034 – additional lambda optimizations

Overview

This adds task support to F#. Task code is compiled to "state machines" via a general capability to write resumable code (i.e. here state machines means resumable code in a "MoveNext" method or similar).

The state machine mechanism can be applied to give more efficient stringBuilder, list, array, asynchronous sequences and other generative computations.

  • library support for Task task { ... }

  • state machine compilation for computation expressions

  • support for using task-like tasks (value tasks etc.)

  • support for configurable tasks (half done)

  • lift limitations on sequence and task state machines for match and other constructs

  • support for defining value tasks

  • establish what to do about reflective invocations of task code

  • check applicability of state machine mechanism for sync { ... }

  • check applicability of state machine mechanism for list { ... }

  • check applicability of state machine mechanism for option { ... }

  • check applicability of state machine mechanism for taskOption { ... }

  • check applicability of state machine mechanism for taskSeq { ... }

  • validity checks for well-formed state machine code (first part)

  • check performance of state machine mechanism for sync { ... }

  • check performance of state machine mechanism for option { ... }

  • check performance of state machine mechanism for list { ... }

  • RFC is drafted (early draft)

  • Implementation matches the updates in the RFC

  • diff minimized and cleanup factored out

  • Implementation is green

  • Systematic testing done for resumable state machines and tasks

  • Performance checked, still looking good.

  • check performance of state machine mechanism for taskSeq { ... }

  • add LanguageFeature and Experimental

  • validity checks for well-formed state machine code (testing and more needed)

Testing:

  • test we have proper debug support (stack, breakpoints, stepping) equivalent to C#
  • add test for the "TODO" case for sequence expressions that has been lifted as part of this PR

We won't add the support until all of the above are done. We are starting with TaskBuilder.fs as a reference library implementation to help define semantics.

Performance Status

Systematic perf testing of task { ... } is required.

Some benchmarks are at tests\fsharp\perf\tasks in the PR. Please help improve this.

Currently compile and run with:

msbuild tests\fsharp\perf\tasks\FS\TaskPerf.fsproj /p:Configuration=Release 
dotnet artifacts\bin\TaskPerf\Release\netcoreapp3.1\TaskPerf.dll

After building a new Debug compiler can run with

msbuild tests\fsharp\perf\tasks\FS\TaskPerf.fsproj /p:Configuration=Release /p:FscToolPath=C:\GitHub\dsyme\fsharp\artifacts\bin\fsc\Debug\net472

Here are results at last run

https://github.com/dotnet/fsharp/blob/feature/tasks/BenchmarkDotNet.Artifacts/results/TaskPerf.Benchmarks-report-github.md


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK