top | item 36861060

(no title)

davidgrenier | 2 years ago

Note that lightweight threads (even in CSP style concurrency model) can be even lighter and faster. F#'s Hopac library seems to meet such expectations with this simple program:

   #r "nuget:hopac"

   open Hopac
   open Hopac.Infixes
   open Hopac.Extensions

   seq{1..1000000}
   |> Seq.Con.iterJobIgnore (fun _ -> timeOutMillis 1000)
   |> run
Runs in 1.824s real, 17.635s user and 0.088s system time in under 186000KB, hence less around 200 bytes per thread.

10M threads sleeping 10 seconds taxes this machine to:

22s real, 4m user, 0.506s system @ 140 bytes/thread.

discuss

order

No comments yet.