-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamic pool implementation and process separation per worker id #10
Conversation
server/app/Server.hs
Outdated
open f = E.bracketOnError (socket AF_UNIX Stream 0) close $ \sock -> do | ||
bind sock (SockAddrUnix f) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
open f = E.bracketOnError (socket AF_UNIX Stream 0) close $ \sock -> do | |
bind sock (SockAddrUnix f) | |
open = E.bracketOnError (socket AF_UNIX Stream 0) close $ \sock -> do | |
bind sock (SockAddrUnix fp) |
😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed. thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh I meant that you can use the top-level fp
without passing it to open
😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hah! right 🤣 !
hFlush stdout | ||
|
||
getAssignableWorker :: IntMap (Bool, Maybe Id) -> Maybe Id -> Maybe (Int, (Bool, Maybe Id)) | ||
getAssignableWorker workers mid' = List.find (isAssignable . snd) . IM.toAscList $ workers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, Foldable.find @IntMap
searches in ascending key order 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Unfortunately, in this case, we need to get Key (= Int) as well, so I couldn't use find directly on the map. toAscList was simply to fuse that key as element.
server/app/Pool.hs
Outdated
writeTVar ref (pool {poolStatus = workers'}) | ||
|
||
removeWorker :: TVar Pool -> Id -> IO () | ||
removeWorker ref id' = do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe mask
this function? not sure if these processes get cleaned up reliably on interrupt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the suggestion. now wrapped it minimally.
GHC compilation for different package modules needs to be separated to different GHC process for various reasons, such as safe dynamic linking / symbol finding and safe interface loading etc. So now each worker status is tagged with worker id and so jobs are distributed with the tag. Once done, the worker needs to be removed from the pool.
Therefore, this intrinsically introduces dynamic pool, spawning and terminating processes as demanded.
This PR implements such dynamic mechanism and worker-id based job distribution. Worker-id assignment per different haskell target is assumed from the build system rules.