# Shared data structures between parallel workers in racket?

**URL:** <https://racket.discourse.group/t/shared-data-structures-between-parallel-workers-in-racket/909>\
**Category:** Questions & Answers\
**Tags:** question\
**Created:** [April 21, 2022, 5:28pm UTC](https://racket.discourse.group/t/shared-data-structures-between-parallel-workers-in-racket/909 "2022-04-21T17:28:47Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![simonls](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/simonls/32/170_2.png) [@simonls](https://racket.discourse.group/u/simonls)\
**Post date:** [April 21, 2022, 10:31pm UTC](https://racket.discourse.group/t/shared-data-structures-between-parallel-workers-in-racket/909/2 "2022-04-21T22:31:37Z")

</div>

It is really difficult to say something general, so if you can describe more about the data and the dependencies between different units of work, it is more likely that somebody can give you hints on potential tweaks.

> [@yak](#):
>
> To parallelize the computation we have created a controller function, which spawns a place for each parallel worker.

Do you have a worker per core or a worker per task?  
The former is what I would expect, the latter could waste a lot of resources if you have say 20000 tasks but only 8 / 16 / 64 cores (whatever it is).  
If you can tell us some numbers (e.g. core counts and amount of tasks, how much is shared between tasks) and how the tasks could be described with a graph that would make the whole discussion more useful.

If you have high core counts you should take a look at [loci](https://docs.racket-lang.org/loci/index.html) as a replacement to places that works better in that scenario.

I also made a topic about something related that might be of interest:

> [@Multi Process Racket (or even distributed)](https://racket.discourse.group/t/multi-process-racket-or-even-distributed/785):
>
> I wrote this in response to [another question](https://racket.discourse.group/t/logging-to-a-single-file-from-multiple-loggers/781), but also to get these things out of my head and written down. I am also curious about other interesting similar or related tools. Personally I don't have done a lot of multi process racket in a practical sense, but I have looked into the options in the past, because it was interesting to me and I thought I could mention them here, to make this a sort-of overview. rackety multi process [Parallelism with Places](https://docs.racket-lang.org/guide/parallelism.html#(part._effective-places)) describes places, there are also dist…

My biggest question however is: does every task need to access one single data structure?  
If so, then that seems like a problem that isn't very parallelize-able.  
In a better case szenario you want to be able to cluster tasks into groups that are tightly coupled and then figure out how those get one part done and then send their results to groups that are later down in the "pipeline".

Also this topic kind of screams for a shout-out of [Amdahl's law - Wikipedia](https://en.wikipedia.org/wiki/Amdahl's_law)

---

_[View the full topic](https://racket.discourse.group/t/shared-data-structures-between-parallel-workers-in-racket/909)._
