2 ms·
For the sake of pitching an analog to go's concurrency model. Hopac is a concurrency library for F# (partly written in C#) delivering an informal implementation
by davidgrenier 3y ago
For the sake of pitching an analog to go's concurrency model. Hopac is a concurrency library for F# (partly written in C#) delivering an informal implementation of CSP (similar to Go's goroutine and Clojure Core.async). Since the job does nothing but wait for 10 seconds, the code is:
seq{1..1000000}
|> Seq.Con.iterJobIgnore (fun _ -> timeOutMillis 10000)
|> run
I'm not sure how to calculate total memory usage but instrumenting the following way:
GC.Collect()
GC.Collect()
GC.WaitForPendingFinalizers()
GC.TryStartNoGCRegion 3000000000L
let before = GC.GetTotalMemory false
seq{1..1000000}
|> Seq.Con.iterJobIgnore (fun _ -> timeOutMillis 10000)
|> run
GC.GetTotalMemory false - before |> printfn "%d"
GC.EndNoGCRegion()
Gives the following output, I'm reading 144MB for 1M lightweight thread (in the REPL) unless I did something dumb:
144449024
Real: 00:00:10.902, CPU: 00:00:18.570, GC gen0: 3, gen1: 3, gen2: 3
val before: int64 = 53902280L
- davidgrenier 3y agoThis is on .net core 7.0.5, Debian 11, Server GC (which is expected by Hopac). I removed all GC code and ran it as an executable using @compumike's `ps ax -o pid,rss,args' command. I think the only one that triggered a GC was the execution with 10M concurrent jobs. N Real(s) User(s) RSS(kiB) RSS(MiB) ================================================== 1 10.08 00.04 42660 41 1000 10.07 00.06 40736 39 10000 10.09 00.20 44176 43 100000 10.15 01.85 58532 57 1000000 10.88 18.18 182024 177 10000000 22.28 4m04.84 1452224 1418