Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration guide to 1.3.x #805

Closed
Thorium opened this issue Oct 19, 2023 · 3 comments
Closed

Migration guide to 1.3.x #805

Thorium opened this issue Oct 19, 2023 · 3 comments

Comments

@Thorium
Copy link
Member

Thorium commented Oct 19, 2023

The migration is not as bad as initial code red lines may show.

  1. The static parameter of UseOptionTypes: bool changed to FSharp.Data.Sql.Common.NullableColumnType enum where the items are listed below. For easiest migration just select value corresponding your old value.

    • NO_OPTION - old "false"
    • OPTION - old "true"
    • VALUE_OPTION - totally new option using voption type, which has benefits of option but with lighter weight object-capsuling.
  2. Async changed to task. So basically if you don't want to migrate too much and used async before, just use |> Async.AwaitTask after each call. Later you can consider should you change your asyncs to tasks or not (i.e. are they just small operations (task) or workflows (async) with timeouts, cancellations, etc).

@jimfoye
Copy link
Contributor

jimfoye commented Apr 6, 2024

What was the rationale for number 2?

@Thorium
Copy link
Member Author

Thorium commented Apr 7, 2024

Async and task are designed from a bit separate point of view: Async is good when you have many complex parallel workflows. Task is good when you want to execute a small thing now. Task is performance-wise way more faster. Most of SQLProvider things are "please execute me this query now", so the new task computation fits to SQLProvider scenario better.

All the database drivers that SQLProvider is using, are using tasks. Most of the APIs that SQLProvider is used in, are also now task-based. So there was no point of converting task->async->task.

That been said I cannot blindly recommend converting everything to task. I'd say as a rule of thumb: if you have a function that is less than 30 F# lines, then convert it to task. But if you have functions over e.g. 150 lines capsulated to task, they probably will just break runtime unless you break them to multiple separate non-nested-functions, to keep your tasks small. So keep them as async and just do Async.AwaitTask. Best indication is that if you compile in release mode and it gives you this warning warning FS3511: This state machine is not statically compilable. A resumable code invocation at '(...-...)' could not be reduced. that means the task might not be working runtime as it should.

@jimfoye
Copy link
Contributor

jimfoye commented Apr 7, 2024

I prefer async for the usual reasons (especially just that it's easier to reason about), but I see why you did it, thanks for the great explanation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants