lwt icon indicating copy to clipboard operation
lwt copied to clipboard

Deprecate Lwt_main.yield and Lwt_unix.yield?

Open favonia opened this issue 3 years ago • 6 comments

This is a suggestion. After talking to @aantron on Discourse, I feel we should officially deprecate yield and related functions using [@@alert deprecate], in hope that one day we will merge the two pools into one.

favonia avatar May 20 '21 17:05 favonia

How do you yield then? 🤔

cyberhuman avatar May 21 '21 06:05 cyberhuman

Lwt.pause () will do the job. There are currently two pools in the codebase due to the two almost identical mechanisms, but I believe they can be safely merged once every Lwt_unix.yield () and Lwt_main.yield () is replaced by Lwt.pause ().

favonia avatar May 21 '21 07:05 favonia

See

https://github.com/ocsigen/lwt/blob/9cbf3a9c21f181dcd78dabf2117f87a62a2d65cc/src/unix/lwt_main.mli#L45-L52

and https://discuss.ocaml.org/t/lwt-pause-versus-yield/7875.

aantron avatar May 21 '21 23:05 aantron

See https://github.com/ocsigen/lwt/pull/784 for some earlier discussion of this.

TL;DR:

  • Lwt_main.run treats paused and yielded promises differently: it resolves paused promises twice as often as yielded promises.
  • This is not an intended difference, but it's a significant difference and it may be significant for several binaries.

I think that, before we release this we should:

  • run the tests of all the opam packages that depend on lwt with the modified lwt (I think this is possible through the opam CI in some way)
  • notify packages that we break or even give them some patches
  • advertise the possibility of the change on discuss (and maybe other channels)

Then if all of that goes well, we can release. It'll need a "breaking change" mention in the changelog.

Maybe we could leverage the opam infrastructure to test if we break some of the tests of the opam packages. I think we should do this (if possible), make upstream commits to all possibly broken packages, and we should make a special mention of this in the changelog (and advertise it in advance on discuss too).

raphael-proust avatar May 25 '21 09:05 raphael-proust

I just updated CHANGES in the #858 but need help in all other actionable items.

favonia avatar May 25 '21 14:05 favonia

I'll ask some opam wizards about the general test of all dependencies.

raphael-proust avatar May 25 '21 15:05 raphael-proust

Closing this as #917 will complete every actionable items in this issue.

favonia avatar Nov 27 '22 08:11 favonia