Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Sep 30 01:35
    jart commented #945
  • Sep 28 07:20

    raphael-proust on master

    Fix broken discuss link Merge pull request #962 from cu… (compare)

  • Sep 28 07:20
    raphael-proust closed #962
  • Sep 28 07:20
    raphael-proust commented #962
  • Sep 28 06:46
    cuihtlauac opened #962
  • Sep 09 10:11
    raphael-proust synchronize #961
  • Sep 09 10:11

    raphael-proust on lwt-effects

    Remove CI (CI only tests <5 whi… More effects, including calling… (compare)

  • Sep 09 08:26
    raphael-proust opened #961
  • Sep 09 08:21

    raphael-proust on lwt-effects

    Scheduler reinstalling handlers… (compare)

  • Sep 05 14:46
    raphael-proust commented #960
  • Sep 02 18:17
    kit-ty-kate commented #960
  • Sep 02 18:15
    kit-ty-kate opened #960
  • Aug 22 07:39
    jeremiedimino unassigned #20
  • Aug 22 07:39
    jeremiedimino unassigned #5
  • Aug 22 07:39
    jeremiedimino unassigned #4
  • Aug 16 05:58
    raphael-proust commented #951
  • Jul 29 12:58
    c-cube closed #931
  • Jul 22 07:17
    MisterDA commented #951
  • Jul 20 14:24
    mroch commented #956
  • Jul 20 14:23
    mroch commented #956
Anton Bachin
@aantron
Lwt_main.yield () btw is just the most trivial I/O promise possible. yield creates a pending promise, then puts a function into the back of Lwt_main.run's queue to resolve it right away. this allows Lwt_main.run to first run any code in callbacks associated with other I/O promises that have resolved recently, then Lwt_main.run resolves the yield () promise, after draining the rest of the queue
(btw dont worry about asking questions, the more i have to explain this, the easier it is to write the properly grammatical version for the manual later :p)
Varun Gandhi
@theindigamer

I haven't followed the tutorial, I thought I'll just jump in and pick it up as I go :sweat_smile: , clearly a suboptimal approach. I was too fixated on solving the problem at hand rather than looking at the bigger picture.

I'll go through the tutorial now.

I think I follow most of your explanation. That said,

puts the process to sleep. the real underlying I/O is meanwhile still running, in parallel

has me a bit confused. Are there multiple OS processes here, with one sleeping and another one doing IO?

Anton Bachin
@aantron
nope, there is one process (for your program)
the I/O is running in parallel because thats how system I/O works :) when you do a normal blocking read, for instance, the kernel puts your process to sleep, while doing the read. so the read is running in parallel (well not, because your process is asleep)
but if you pair read with select, epoll, kqueue, or run it in a worker thread, then the read is running in parallel, because the kernel either notifies you through select, epoll, kqueue when the read completes, or puts to sleep only the worker thread
thats basically exactly how lwt_main.run works on the inside
the I/O parts of lwt are basically a big wrapper around select (or whatever non-blocking I/O API exists on the system) plus worker threads, that (1) runs as much code as possible, and puts the process to sleep when all remaining code is waiting for I/O (2) resolves promises when some I/O completes
Varun Gandhi
@theindigamer
By worker threads, do you mean OS threads here?
Anton Bachin
@aantron
yes
after clarifying the manual, "threads" will always refer to OS threads :) right now the manual misleadingly uses that word for lwt promises as well
Varun Gandhi
@theindigamer
:+1: thanks :smile:. I think I'm good for now, but I'll have a look at the tutorial soon-ish.
Anton Bachin
@aantron
getting an accurate mental model for Lwt is no easy task. it took me some weeks or months of sporadic improvements to get it. its good to go through this process again. hopefully it can be condensed into helpful docs :)
sure :) good luck :)
the lwt.mli tutorial is kind of a draft for exercising just that module, i probably will take it out into a broader main tutorial later, that can be more conceptual
also for your question about inserting Lwt_yield automatically into g, the answer is yes, you have to do it manually. however, ideally, this should be very rare
also you shouldn't open Lwt. the operators are provided by Lwt.Infix
it's typical to write open Lwt.Infix or let open Lwt.Infix in ...
Varun Gandhi
@theindigamer
:+1:
matrixbot
@matrixbot
Orbifx Anton what CPU was your test for the performance of the variants ran an on?
Anton Bachin
@aantron
Orbifx: core i7-2720QM sandy bridge, 2.2 GHz
matrixbot
@matrixbot
Orbifx a beasty one :P
Anton Bachin
@aantron
:)
matrixbot
@matrixbot
Orbifx Are you on Mastodon btw?
Anton Bachin
@aantron
nope. never heard of it. should i be?
Anton Bachin
@aantron
Orbifx: now i am :)
Anton Bachin
@aantron
let me know if i should join some specific instances
matrixbot
@matrixbot
Orbifx trying to get an ocaml scene going
Orbifx what's your address?
Anton Bachin
@aantron
matrixbot
@matrixbot
Orbifx Welcome :)
Orbifx Added
Anton Bachin
@aantron
great. is there any ocaml-specific community, or for now it's just some scattered ocamlers? :)
matrixbot
@matrixbot
Orbifx scattered for now. Search for #ocaml to follow other ocamlers
Anton Bachin
@aantron
@theindigamer i rewrote the introduction, updated the tutorial, added an execution model section, and properly wrote the guide to rest of lwt in the new manual draft. rendered it to html, take a look here https://ocsigen.github.io/lwt/manual-draft/Lwt.html
would be interested to see if this is helpful, and in any other feedback you may have :)
Varun Gandhi
@theindigamer
@aantron the first couple of sections look good to me :smile:. I'll probably go through the rest over the weekend and get back to you then.
matrixbot
@matrixbot
Orbifx Any bloggers here? Want an opinion on something
Anton Bachin
@aantron
not me. im just a wannabe :p
Varun Gandhi
@theindigamer

I finished reading the sections before Sec. Rejection. Comments:

  1. Links to lwt functions are dead.
  2. In Sec. Execution Model, the word "resolution" is used as a noun but it isn't mentioned before. Do you intend to use I/O promise instead?
  3. In Sec. Waiting, should

    If p1 is fulfilled now or later with value v, f v is called. f v might be called immediately, or after some time.

    instead have something like "f v will be called when p1 is fulfilled"?

  4. "Actual promises are read-only.", it's not fully clear what that means ... it can't mean that promises are immutable (because you can resolve them through the resolver). Are they read-only modulo resolvers (which are typically hidden away and not used directly)? It might be better to have a few more words here :smile:.

Apart from these, I think the rest of it is a good read.

Also, for some reason, the deprecated section is not linked to in the sidebar.

Romain Slootmaekers
@toolslive
We tried to move our dependency from lwt.3.0.0 to lwt.3.1.0, but we noticed some of our tls related testcases started failing. Before I start digging: Did anybody else witness problem with tls and lwt3.1.0 as well ?
Anton Bachin
@aantron
@toolslive: i'm not aware of any reports, or any other problems with lwt 3.1.0, at this point
@theindigamer: thanks. the links to anything outside this module are dead, because it's just one file uploaded for now. i suppose i should put the rest of the current manual in the same directory. also, ive since rewritten most of the function docs. i'll incorporate your feedback :) i hid the deprecated section on purpose, but ive since also put it back, without linking its subsections in the sidebar
basically, as suggested, only the intro parts of that were ready for consumption :)
Anton Bachin
@aantron
the new module Lwt docs are now a PR ocsigen/lwt#469
matrixbot
@matrixbot
Orbifx Anton Bachin (Gitter): is this how Lwt implements Lwt exceptions? https://hal.inria.fr/inria-00432575/document
Anton Bachin
@aantron
Orbifx: sort of. the "basic" Lwt is an I/O monad combine with an error monad (something we might later undo)
(and separate the monads)
this basic error monad carries around exn for errors, an open variant type
there is also Lwt_result, which provides a separate error monad