--
You received this message because you are subscribed to the Google Groups "Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to racket-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/bb36e50a-a77b-4c5b-b144-71ce647069b7%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to racket-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/02b4c456-2af1-4306-b749-b7d54173c7dc%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to racket-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/59c68f8e-b668-f08e-55ae-a977084f5bb1%40gmail.com.
I don't think places are a good example for good support of parallelism.
It is difficult to get a flexible multi processing implementation done, without hard-coding the lambdas, that run in each place, because we cannot send serializable lambdas (which also are not core, but only exist in the web server package) over channels. That means, that one needs to define ones lambdas ahead of time before even starting a place and sending it the data to process. That means, that we cannot have something like a process pool.
The other problem is, that using places means using multiple Racket VMs, if I remember correctly, which uses some RAM. It is not like places are super lightweight at least.
Racket threads run on a single core, I think.
I know there is a tutorial about using futures somewhere, where it depends on the number type one uses, whether the code can be automatically run in parallel or not, so there is also some issue there, or at least it did not look to me like one could use futures everywhere and have neat parallelism.
Correct any of the things I wrote above, if they are not true, but I think Racket definitely needs a better multi processing story.
I would love to see something like Guile Fibers. Andy Wingo even mentioned in his video, that some of the Racket greats advised him to look at Concurrent ML and that that is where he got some ideas from, when implementing Guile Fibers as a library. Shouldn't Racket then be able to have a similar library? I don't understand how Fibers really works, but that is a thought I had many times, since I heard about the Fibers library.
Regards, Zelphir
True. However, here comes the big "but": What about capturing the environment of expressions? For example I might have identifiers in my S-expressions bound to potentially a lot of data, which must also be send through the channel. It would be painful (if not impossibly at the time of writing the code) to have to copy the whole representation (of a creating expression) for that data into an expression to send it.
Hi George!
I was wrongly under the impression, that serializable-lambda are
supposed to work out of the box, when sending them over channels,
without needing to do any further work ("are serialized
automatically" instead of "can be serialized"). This is what I
would have expected, as it seems to be the case in other
programming languages, where one can simply send lambdas to other
actors, which can, but don't have to, run on other cores or other
machines. A year ago or so there was an Racket event in Berlin
(Racket Summerfest), where people also tried to use
serializable-lambda to send them over channels, but did not
succeed. I do not know what the problems there were, as I did not
attend that specific workshop. However, I think some of the more
knowledgeable people of the Racket community might remember that
workshop. Maybe there also was some code from that event. If you
know how to serialize those serializable-lambdas, it is possible,
that you could solve the problems they faced.
I have a question regarding what you wrote: Is there a generic way to serialize such lambdas, no matter what they look like?
I think that would be kind of necessary to abstract away the painful points of coming up with a way of serializing the lambdas. It also seems to be necessary for eventually creating a library, which provides a process pool, as such library possibly should be easy to use and not force the user to think about difficult thing, when the intention the user has seems so simple "just do that on another core".
I have not read CSP and I know, that it is considered to be _the_ standard for multi processing, that much I have to admit. I am also not trying to argue the concept away : ) Just saying, that in Racket it is quite difficult (at least for me, although I have tried many hours, when I was working on my project) to get multi processing done. I believe in Python at least superficially one faces a similar situation: Threads on same core, processes can go on other core, which is the parallel to starting a new Racket VM, because it also starts a new Python process. However, somehow it is easily possible to give a reference or a lambda to a process pool in Python. I don't know the implementation details of course.
Best regards,
Zelphir
I was wrongly under the impression, that serializable-lambda are supposed to work out of the box, when sending them over channels, without needing to do any further work ("are serialized automatically" instead of "can be serialized"). … If you know how to serialize those serializable-lambdas, it is possible, that you could solve the problems they faced.
… Is there a generic way to serialize such lambdas, no matter what they look like?
… it seems to be the case in other programming languages, where one can simply send lambdas to other actors, which can, but don't have to, run on other cores or other machines. … It also seems to be necessary for eventually creating a library, which provides a process pool, as such library possibly should be easy to use and not force the user to think about difficult thing, when the intention the user has seems so simple "just do that on another core".
Hi!
Hmmm, that code example looks simple enough. If that works for arbitrary serializable-lambda with only serializable parts, I could continue my process pool project. The only issue would then be, that any user of it would have to know in advance, that they cannot define their lambdas as usual, but have to use serializable-lambda, potentially through their entire code (as there might be references to things which contain references to things, which ...). The abstraction is in this way leaky, but it would make a working library then.
`n` does not need to be serializable, because it is defined in the module and will be defined in the module "on the other side" as well? If I understand this correctly.
When saying, that in other languages it is possible to simply define a lambda and send it to another actor, I meant of course with immutable data, or at least with data, which is not actually mutated. I assumed that already, but yes, of course you are right about that. I was thinking of Erlang, Elixir and maybe Pony.
When hearing actors, then Threads could be thought of a means of implementing them, but I think might not be useful to do so when thinking about performance. Architecturally yes, maybe. That is, why I would think of places as a means of implementing an actor model kind of thing.
When you say, that loci extends the idea of places to multiple machines, what do you mean? I thought places can already run on multiple machines.
I might try to use your example code to finally finish the process pool implementation I started. If everything works like that, then I probably have to retract any statements about parallelism being too hard in Racket : ) It would be nice however, to not have to use a different construct to define serializable lambdas and to be able to go to any program and simply use existing lambdas to send them to a process pool to make use of multiple cores, instead of having to refactor many things into serializable things.
Regards,
Zelphir
… If that works for arbitrary serializable-lambda with only serializable parts, I could continue my process pool project.
The only issue would then be, that any user of it would have to know in advance, that they cannot define their lambdas as usual, but have to use serializable-lambda, potentially through their entire code (as there might be references to things which contain references to things, which ...). The abstraction is in this way leaky, but it would make a working library then.`n` does not need to be serializable, because it is defined in the module and will be defined in the module "on the other side" as well? If I understand this correctly.
When hearing actors, then Threads could be thought of a means of implementing them, but I think might not be useful to do so when thinking about performance. Architecturally yes, maybe. That is, why I would think of places as a means of implementing an actor model kind of thing.
When you say, that loci extends the idea of places to multiple machines, what do you mean? I thought places can already run on multiple machines.
It would be nice however, to not have to use a different construct to define serializable lambdas and to be able to go to any program and simply use existing lambdas to send them to a process pool to make use of multiple cores, instead of having to refactor many things into serializable things.