jepst / cloudhaskell Goto Github PK
View Code? Open in Web Editor NEWA distributed computing framework for Haskell
Home Page: http://hackage.haskell.org/package/remote
License: BSD 3-Clause "New" or "Revised" License
A distributed computing framework for Haskell
Home Page: http://hackage.haskell.org/package/remote
License: BSD 3-Clause "New" or "Revised" License
Documentation mentions ProcessDownException but I can not find such type in the source code.
BTW Don't you have examples of project linking?
The ability to serialize closures has use beyond remote. Would it be possible to move this functionality into a sub-package?
These types are used so commonly in message types, it would be nice if they had Data instances so we could use genericGet, genericPut on them. It's a trivial change, but it can't be done by users because the constructors are not exported. Alternatively, export the constructors so we can just add a deriving instance
.
Hi again.
I'm writing a Chord DHT using your Cloud Haskell.
When doing this each node in the DHT needs a local state that all processes can access. (even those spawned from remote processes.)
Right now, this is implemented by a hack of mine exploiting the fact that the pid of the first process you run in
Cloud Haskell is static. That way I store state in that process and all spawned processes can get/put the state
using custom messages. You can see an example implementation in my fork in examples/Chord/Test.hs
You need to export the ProcessId data constructor to make it work.
This hack works quite well and has never failed on my tests, there's just two bugs as I see it now.
Do you have any idea about how one would add state for each node. I've taken a look at the code in Process.hs and
functions like getSelfPid already access a state-like structure. Would it be possible to add inn a MVar there that's inherited from
the node state each time a new process is spawned? I tried to do this but that would have broken the signatures of several
top level functions in Cloud Haskell. Both spawnLocalAnd, startLocalRegistry and initNode etc. This because one would have
to have a initial node state all these places. I also got a problem with polymorphism, because the state type had to have a
defined type at compile time. I ended up concluding I was "doing it wrong" and needed some help from someone that knows
the code. What's your thoughts on this problem?
This is not an urgent issue for me in any way, just putting forth the idea. Afterall I have working state ;)
I have an embarassingly parallel computing task implemented in a CloudHaskell:
runTask $ do mapM (newPromise ยท mapper) inputs
mapResult โ mapM readPromise pmapResult
This works ok, as long as there are as many WORKER processes, as (length inputs - 1),
but if I have fewer, I get:
2012-08-23 10:57:06.030153 CEST 2 pid://localhost:57840/11/ SYS Process got unhandled exception TaskException "Failed promise redemption"
2012-08-23 10:57:06.030586 CEST 2 pid://localhost:57840/8/ SYS Process got unhandled exception ProcessMonitorException: pid://localhost:57840/11/ has terminated because SrException "TaskException "Failed promise redemption""
As tutorials are rather sparse, I wonder how may I fix it? (And why?)
Interestingly enough the exception doesn't appear on Linux, and everything completes okay.
Mac OS X also shows another exception for each node:
2012-08-23 10:56:57.86235 CEST 2 pid://localhost:57837/5/ SYS Process got unhandled exception bind: resource busy (Address already in use)
I've been digging through the sources of Cloud Haskell trying to
understand what it is about - it looks nice.
On the Picky-details side of things, it looks like the ProcessM Monad
is set up similar to a State monad, but it could almost be a Reader
Monad, except for the functions 'setLogConfig' and 'buildPid'. If it
weren't for these functions, ProcessM could be defined as:
newtype ProcessM a = ProcessM {runProcessM :: Process -> IO a} deriving Typeable
which would simplify the implementation (and perhaps improve the
performance of (>>=) and friends).
It looks like 'buildPid' is only called when a process doesn't know
which port it is listening on. It's a bit hard for me to follow the
process creation code - if there was a way for the parent process
which creates the child to calculate the port before-hand instead of
after the fact the monad stack could be trimmed down.
For 'setLogConfig', we could just put the local log config in an MVar
and be done with it.
This would change the semantics of 'forkProcessWeak' - changes to the
log config after calling 'forkProcessWeak' would be seen in both
threads.
Since 'forkProcessWeak' is only used in one place which doesn't this
shouldn't be a problem.
Anyway I'm probably missing something about how process creation
works, so there might e a reason this isn't a good approach.
Right now spawned processes can't spawn new proceses. Is this something that will be possible when the Static is implemented or is it something I'm doing wrong?
Here's an example:
{-# LANGUAGE TemplateHaskell,BangPatterns,PatternGuards,DeriveDataTypeable #-}
module RecSpawn where
import Remote.Call
import Remote.Channel
import Remote.Peer
import Remote.Process
import Remote.Init
import Remote.Encoding
import System.Random(randomRIO)
import Control.Monad.Trans(liftIO)
spawner :: ProcessM ()
spawner = do
thisNode <- getSelfNode -- This could also be a remote node
flag <- liftIO $ randomRIO (0,1) :: ProcessM Int
case flag of
0 -> spawn thisNode (spawner__closure)
1 -> say "Got one"
remotable ['spawner]
initial _ = do spawnLocal spawner
return ()
main = remoteInit Nothing [RecSpawn.__remoteCallMetaData] initial
Would it be possible to expose a config type instead of requiring a file?
Also, allowing some sort of option to use a different transport for connections (use case i have in mind right now is TLS).
In some examples I've been writing, I've been trying to use StateT MyState ProcessM (). Generally the issue with this is that all of the ProcessM stuff has to be lifted. So there are two solutions.
Make ProcessM a transformer so I can use MonadState.
Add a MonadProcessM class I can instance my monad stack with so I can lift the stuff up automatically.
Or, you know, both.
Could CloudHaskell's API also apply to OpenCL so the code same code could run on the GPU?
A parallel algorithms library https://github.com/thrust/thrust would be nice to have it for CloudHaskell and OpenCL.
I wrote some demo's with Cloud Haskell, I'll attach them here, they might interest you as easier to understand examples for the examples/ folder.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.