Comments (9)
Sure thing
from unison.
I'll take this on, if no one else is working on it
from unison.
Sure, though can you prioritize finishing up the key-value store bindings,
at least when you aren't bottlenecked by me needing to review/merge stuff?
On Fri, Apr 15, 2016 at 1:28 PM sfultong [email protected] wrote:
I'll take this on, if no one else is working on it
—
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#24 (comment)
from unison.
I started looking into this and have a few questions:
- Why does the
evaluate
function take aMaxProcesses
? I would thinkMaxProcesses
would be an attribute of aPool
and therefore be a parameter of thepool
function. - How does a client of
Pool
get access to process IDs (which are needed byevaluate
andkill
)? Seems to me that process IDs should be internal to aPool
.
I think it would help me to see how some client code would use a Pool
. In particular, I'd like to see the interaction between a Pool
and its worker processes.
from unison.
Why does the evaluate function take a MaxProcesses? I would think MaxProcesses would be an attribute of a Pool and therefore be a parameter of the pool function.
I think you're right. Not sure what I was thinking there. Let's go with that.
How does a client of Pool get access to process IDs (which are needed by evaluate and kill)? Seems to me that process IDs should be internal to a Pool.
With the API I gave, the client of Pool
just makes them up before calling evaluate
. But now that you mention it I think it would be simpler for Pool
to just invent them itself and return the ID
it picks immediately:
evaluate :: Budget -> a -> IO (ID, IO (Either Err b)),
So the outer IO (ID, ..)
completes immediately, and the inner IO (Either Err b)
completes whenever the worker finishes.
I think it would help me to see how some client code would use a Pool. In particular, I'd like to see the interaction between a Pool and its worker processes.
I'm a bit hazy on this myself, but client code would just call the evaluate
function, and maybe kill
if a computation was taking too long. What the evaluate
function computes is going to be determined by whatever the worker processes do.
The worker process would just read a stream of Packet a
from standard in (you could use some other IPC mechanism but using standard in / standard out seems reasonable), using deserialize
, call its evaluate function, catching any exceptions, and writing results incrementally to standard out using serialize
. Packet
might look something like:
data Packet a = Kill | Done | Eval a deriving (Generic)
instance Serial a => Serial (Packet a)
Kill
would indicate that the most recently started computation should be killed, Done
indicates the overall process should be shut down following completion of any outstanding evaluation, and Eval a
is a new computation to evaluate. Within a worker process, only one thing will ever be getting evaluated at a time.
So the implementation of Pool
is going to spin up several worker processes using the provided action, keep track of their state (whether busy or idle), and send them work to do over their standard in. The workers will receive a stream of work to do / control messages, will do work, and serialize results to standard out where they'll be read by the process where the Pool
lives.
Do you think that gives you enough to go on, or do you have more questions? Obviously as stuff comes up we can talk more. :)
from unison.
@pchiusano Thanks for elaborating. I've started a branch in my fork for this work (there's no implementation yet): https://github.com/tmciver/unison/tree/process-pool.
A few more questions:
-
You've changed the return type of
evaluate
to contain the ID of the process being used for the evaluation but what should be returned for the ID in the case where previously we would have failed fast with anInsufficientProcesses
error? -
In the description of the API at the top of the page you say
When evaluate gets called, serialize the thunk using the argument passed to pool.
What is the thunk? Is it the value of type
a
? Isn't a thunk a function? -
Probably related to the above question: what is the function
a -> IO b
passed to theworker
function? At first I thought it would be a function given to us by the client that we would then evaluate. But then I thoughtworker
s were an implementation detail of aPool
.
from unison.
@tmciver Okay, I have been giving this some thought, and realized that sandboxing can be done in a way that is more elegant and makes this process pool unneeded. So I'm going to close this issue. Really sorry to pull the rug out from under you. :( I'll be on the lookout for other bite-sized projects.
Briefly, the new design (which I'll write up in a post) is that nodes are much lighter weight things (many nodes can be running on a single machine), and you can even spawn nodes dynamically, using a new primitive like:
-- | Create a new local node, running in the specified sandbox
spawn : Budget -> Sandbox -> Remote! Node
Where Budget
specifies an amount of compute resources (memory and/or time) and Sandbox
is some description of the capabilities the returned Node is allowed access to. Some details to be worked out but you get the idea.
I think this is a more elegant approach. Any pooling of nodes can be done just using pure Unison code. And when sharing node references with others, you can choose to share a sandboxed node that has more limited capabilities.
For the implementation, each node will be backed by a single OS process if it's 'awake', or if it's 'asleep' it will just be backed by some bits on disk.
I'm going to do some prototyping of this architecture before committing to it, but once it is more solid I think there will be some good bite-sized pieces for others to work on.
from unison.
OK, no problem. Let me know when there's more work to do; I'm eager to contribute to this project and hone my skills!
from unison.
Cool. :)
from unison.
Related Issues (20)
- `ucm` wrapper breaks when called from a path with spaces in it
- history command and nondeterministic transcripts
- `merge.preview` shows hashes even if the definitions have names
- design and implementation for pack files / pull bundles HOT 1
- Possible unimplemented functions in JIT's TCP HOT 3
- switch should clear last scratch save
- `push`/`pull` don't accept `project/branch:path` args like `fork` does
- add proper `libb2` dependency to `unison-runtime` HOT 6
- chore: eliminate the use of loose code in transcripts
- remove `update.old`
- (possibly) LSP missing type names from scratch file? HOT 4
- run command: should threads be able to keep themselves running after interrupt? HOT 3
- delete.term with numbered arg fails and with a cryptic message HOT 1
- structured numbered args megaticket
- Allow `Debug.toText` builtin to be called in sandboxed code
- redesign `add`/`update`/`commit`
- migration to reset user's current path to the root of their current project
- improve error message for run.native tests.jit.only HOT 1
- new `update` doesn't really do the right thing when updating a term to a constructor
- create transcript creation guide for submitting tickets
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from unison.