ego
2020-7-23 12:58:04

@ego has joined the channel


richo
2020-7-23 19:19:16

@richo has joined the channel


ego
2020-7-23 20:52:37

I have questions about parallelism in Racket… I understand that Racket threads are like green threads (?) and provide concurrency but not parallelism And places provide sub-vms which do provide parallelism (and communicate via shared memory)

Then there are futures… they can provide parallelism as long as the code in them is “future safe” otherwise they get blocked, I guess have to synchronise with the main thread?


ego
2020-7-23 20:54:16

I found the following: “As a general guideline, any operation that is inlined by the https://docs.racket-lang.org/guide/performance.html#%28tech._jit%29\|JIT compiler runs safely in parallel, while other operations that are not inlined (including all operations if the JIT compiler is disabled) are considered unsafe.”

generally it seems hard to say exactly what things are future safe but various tools are provided to profile and check your code to identify when it blocks (“unsafe”)


ego
2020-7-23 20:55:18

My question is how all this changes if you are compiling code under Racket CS

it was my understanding that was no longer a bytecode vm… does that mean all code is then “future safe”?


ego
2020-7-23 20:57:03

found this thread from 2 years ago, not sure if info is still current https://groups.google.com/g/racket-users/c/Vj22-WodBVg/m/O1anoRO1BwAJ

> the “cs” variant of Racket will map Racket futures onto Chez > pthreads, and many more operations are future-safe in that variant. > However, Racket threads still do not run in parallel in the “cs” > variant — you need to use futures or places to make use of more than > one hardware core from Racket.


samth
2020-7-23 21:04:06

That information is still correct. Many more things are now future-safe (such as accessing an eq-based mutable hash table, or operations on immutable hash tables). But many operations are not future safe, including all things that interact with Racket’s threads or IO.


ego
2020-7-23 21:05:19

thanks!


ego
2020-7-23 21:06:38

is there a rule of thumb to know which things are not future safe? “threads and IO” are the main ones?


samth
2020-7-23 21:11:40

“things that seem like they might need a lock to be thread-safe”


ego
2020-7-23 21:12:23

makes sense, cheers


samth
2020-7-23 21:14:29

it is unfortunate that there isn’t real documentation of this


moe
2020-7-24 06:56:37

@moe has joined the channel