Open namin opened 6 months ago
This is almost certainly not a linear "slowdown", but rather a polynomial growth in overhead. The overhead also appears to grow with the amount of work done in thunk
(based on running some more tests with an extra zero in the loop condition), which I would expect if the work in thunk
included some contention for a shared resource. That could easily happen in non-contrived code, since there are internal mutexes for allocation and garbage collection. In this case, however, it looks like the code inside thunk
performs no allocation, and the results of time
show that no GC occurred. I haven't quite managed to figure out whether the "trap check" happening in each thread that determines whether to fire a GC is a synchronization point if no allocation is being done. That would explain the extra overhead, but seems like it shouldn't be necessary when no allocation has happened.
Hi,
I defined
pcall
like Kent Dybvig on slide 10 of https://web.archive.org/web/20170626072601/http://www.ccs.neu.edu/events/wand-symposium/talks/mitchfest-09-dybvig.pdf and was surprised by how it seems to have a linear slowdown with the number of expressions in parallel.I am using a modified version which executes expressions in parallel and returns the first value that succeeds, stopping the others (each thunk is wrapped in an engine). https://github.com/metareflection/synthesis-scheme/blob/main/threads.scm It also suffers from this linear slowdown.
Is this linear slowdown for parallel execution expected?
Thanks. Best wishes, ~n