Replies: 1 comment
-
HVM works by constructing a graph that represents your program, where different parts of the graph can be reduced incrementally, without effecting other parts of the graph. This means that all of these independent pieces of your program can be evaluated in parallel automatically. Comparing that to locks, you no longer have to deal with deadlocks or manually locking and unlocking anything. There is a fully deterministic way to evaluate your program's graph and it will be parallelized as much as possible automatically. This avoids a lot of head-aches, and can make it easier to use very large numbers of CPU cores, because using more cores doesn't mean doing more complicated locking, etc. in your program. If you want to make your program more parallelizable in HVM, you would try to break your program into smaller pieces that can be evaluated without effecting other pieces of your program. One way to do this , for example, would be to operate on tree-structures, where each sub-tree can be evaluated without effecting other sub-trees, instead of what might be more common in procedural programming, where you operate on list structures, which must be processed in a sequence, and can't be parallelized, because of the sequential nature of the process. Comparing to an actor framework, it doesn't share a lot of similarities. An actor framework makes you split your app into actors that each manage their own state and are only allowed to mutate only their own state. This makes the program easier to think about and can allow parallelism between actors, but it isn't fully automatic, so there's still more thinking and reasoning about the actors. With actors, you also can't get automatic parallelism for the processing that is done inside one actor. For example, if an actor needed to do parallel processing over some data it owned, it would have to be done manually with locks/threads/coroutines or something, but in HVM you can just automatically get parallelism wherever one part of your program doesn't affect another. For kind of a deep dive explanation on how interaction nets work, you can checkout my blog post Interaction Nets, Combinators, and Calculus and/or the Abstract Algorithm Explanation which might give you a better intuition for how some of the computation graph works. |
Beta Was this translation helpful? Give feedback.
-
As a programmer who's not from the FP camp, I'd like to know if there's some model that models the way HVM work so we can reason about it's pros/cons over other concurrency model?
Like how will HVM's model be compared to Locks/STM/Actor models?
Beta Was this translation helpful? Give feedback.
All reactions