monadic c nadic compos mpositio ition
play

Monadic C nadic Compos mpositio ition for or De Deter ermini - PowerPoint PPT Presentation

Monadic C nadic Compos mpositio ition for or De Deter ermini inistic, P c, Par aral allel el Bat Batch ch Pr Proc oces essing ng Ryan Scott 1 Omar Navarro Leija 2 Ryan Newton 1 Joe Devietti 2 1 Indiana University 2 University of


  1. Monadic C nadic Compos mpositio ition for or De Deter ermini inistic, P c, Par aral allel el Bat Batch ch Pr Proc oces essing ng Ryan Scott 1 Omar Navarro Leija 2 Ryan Newton 1 Joe Devietti 2 1 Indiana University 2 University of Pennsylvania rgscott@indiana.edu github.com/RyanGlScott

  2. Non Nondet deter ermini inism Arguments Output fjles Ideal Program Ideal Program Input fjles

  3. Non Nondet deter ermini inism Output fjles v1 Arguments Nondeterministic Nondeterministic Output fjles v2 Program Program Input fjles ...

  4. Non Nondet deter ermini inism Output fjles v1 Arguments Nondeterministic Nondeterministic Output fjles v2 Program Program Input fjles ... Thread scheduling

  5. Non Nondet deter ermini inism Output fjles v1 Arguments Nondeterministic Nondeterministic Output fjles v2 Program Program Input fjles ... Thread scheduling Environment leaks

  6. Nondet Non deter ermini inism Output fjles v1 Arguments Nondeterministic Nondeterministic Output fjles v2 Program Program Input fjles ... Thread scheduling Environment leaks Nondet. system calls/CPU instructions

  7. Wh Where nondet nondetermi minism nism hur hurts

  8. Wh Where nondet nondetermi minism nism hur hurts Continuous integration

  9. Wh Where nondet nondetermi minism nism hur hurts Parallel workfmows all: a b c a b c: @for n in 1 2 ; do \ echo $@-$$n && sleep 1 ; \ done

  10. Serial execution Parallel execution $ make a-1 a-2 b-1 b-2 c-1 c-2

  11. Serial execution Parallel execution $ make $ make -j2 a-1 a-1 a-2 a-2 b-1 b-1 b-2 b-2 c-1 c-1 c-2 c-2

  12. Serial execution Parallel execution $ make $ make -j2 a-1 a-1 a-2 b-1 b-1 b-2 b-2 a-2 c-1 c-1 c-2 c-2

  13. Serial execution Parallel execution $ make $ make -j2 a-1 a-1 a-2 b-1 b-1 a-2 b-2 b-2 c-1 c-1 c-2 c-2

  14. detflow detflow Static Low determinism overall enforcement overhead Dynamic runtime sandboxing

  15. detflow detflow Static Low determinism overall enforcement overhead Dynamic runtime sandboxing

  16. Entrypoi Entrypoints ts main :: IO ()

  17. Entrypoi Entrypoints ts main :: IO () main = do Parallel.mapM_ putStrLn [1..10]

  18. Entrypoi Entrypoints ts main :: IO () main = do Parallel.mapM_ putStrLn [1..10] -- Already nondeterministic!

  19. DetIO DetIO newtype DetIO a = MkDetIO (IO a)

  20. DetIO DetIO newtype DetIO a = MkDetIO (IO a) -- Expose only deterministic API calls getLine :: DetIO String putStrLn :: String -> DetIO () -- etc.

  21. DetIO DetIO newtype DetIO a = MkDetIO (IO a) -- Expose only deterministic API calls getLine :: DetIO String putStrLn :: String -> DetIO () -- etc. Key idea: Only expose deterministic operations that can be composed in a deterministic fashion

  22. DetIO DetIO newtype DetIO a = MkDetIO (IO a) -- Expose only deterministic API calls getLine :: DetIO String putStrLn :: String -> DetIO () -- etc. main :: DetIO () main = do x <- getLine putStrLn x

  23. Par arall lleli lism ● detflow uses the fjlesystem for shared-memory parallelism ● Should this be allowed? readFile :: FilePath -> DetIO String writeFile :: FilePath -> String -> DetIO String

  24. Par arall lleli lism Thread 1 Thread 2 do writeFile “foo.txt” do foo <- readFile “foo.txt” “Hello, World” if foo == “Hello, World” then ... else ...

  25. Par arall lleli lism Thread 1 Thread 2 do writeFile “foo.txt” do foo <- readFile “foo.txt” “Hello, World” if foo == “Hello, World” then ... else ...

  26. Solu Solution: per tion: permis issions ons ● Every thread holds separate permissions on system fjlepaths

  27. Solu Solution: per tion: permis issions ons ● Every thread holds separate permissions on system fjlepaths /abcdef/ghijkl/mnopqr R 0.5 R 0.5 RW 1.0 Thread 1 Thread 2 R 0.5 R 0.5

  28. Par arall lleli lism, r , revi visited data Perm -- (R/RW) + path + fraction forkWPerms :: [PathPerm] -> DetIO a -> DetIO (Thread a) joinThread :: Thread a -> DetIO () ● readFile and writeFile must respect the permissions in a thread’s local state

  29. Perm rmissions chec ions checkout ut pgm :: DetIO () pgm :: do -- Assume parent starts with R 1.0 on /a th1 <- forkWPerms [R “/a”] computation1 th2 <- forkWPerms [R “/b”] computation2 joinThread t1 joinThread t2

  30. Perm rmissions chec ions checkout ut pgm :: DetIO () pgm :: do -- Assume parent starts with R 1.0 on /a th1 <- forkWPerms [R “/a”] computation1 -- Parent has R 0.5 on /a th2 <- forkWPerms [R “/a”] computation2 joinThread t1 joinThread t2

  31. Perm rmissions chec ions checkout ut pgm :: DetIO () pgm :: do -- Assume parent starts with R 1.0 on /a th1 <- forkWPerms [R “/a”] computation1 -- Parent has R 0.5 on /a th2 <- forkWPerms [R “/a”] computation2 -- Parent has R 0.25 on /a joinThread t1 joinThread t2

  32. Perm rmissions chec ions checkout ut pgm :: DetIO () pgm :: do -- Assume parent starts with R 1.0 on /a th1 <- forkWPerms [R “/a”] computation1 -- Parent has R 0.5 on /a th2 <- forkWPerms [R “/a”] computation2 -- Parent has R 0.25 on /a joinThread t1 -- Parent has R 0.75 on /a joinThread t2

  33. Perm rmissions chec ions checkout ut pgm :: DetIO () pgm :: do -- Assume parent starts with R 1.0 on /a th1 <- forkWPerms [R “/a”] computation1 -- Parent has R 0.5 on /a th2 <- forkWPerms [R “/a”] computation2 -- Parent has R 0.25 on /a joinThread t1 -- Parent has R 0.75 on /a joinThread t2 -- Parent has R 1.0 on /a

  34. e detflow detflow Mor ore ● Replace nondeterministic IO operations with deterministic alternatives ● Reading system time ● putStrLn ● Full lattice of permissions, and formalization of permission checkout (see paper)

  35. detflow detflow Static Low determinism overall enforcement overhead Dynamic runtime sandboxing

  36. system system cal calls ls system :: String -> DetIO () main :: DetIO () main = system “gcc foo.c -o foo”

  37. system system cal calls ls system :: String -> DetIO () main :: DetIO () main = system “gcc foo.c -o foo” ● How can we make shelling out to arbitrary programs (not written in DetIO ) deterministic?

  38. system system cal calls ls system :: String -> DetIO () main :: DetIO () main = system “gcc foo.c -o foo” ● How can we make shelling out to arbitrary programs (not written in DetIO ) deterministic? ● Answer: run them in a deterministic runtime .

  39. libdet libdet

  40. libdet libdet libdet must intercept potential sources of nondeterminism at runtime.

  41. libdet libdet libdet must intercept potential sources of nondeterminism at runtime. Reading from “banned” directories ● /dev/urandom ● /proc

  42. libdet libdet libdet must intercept potential sources of nondeterminism at runtime. Reading from “banned” Solution directories ● /dev/urandom ● Intercept calls to fopen() (with ● /proc LD_PRELOAD ), error if they read anything blacklisted

  43. libdet libdet libdet must intercept potential sources of nondeterminism at runtime. Uncontrolled concurrency ● e.g., with pthreads

  44. libdet libdet libdet must intercept potential sources of nondeterminism at runtime. Uncontrolled concurrency Solution ● e.g., with pthreads ● Intercept calls to pthread_create() (with LD_PRELOAD ) to run everything sequentially

  45. libdet libdet libdet must intercept potential sources of nondeterminism at runtime. Nondeterministic OS properties ● e.g., reading addresses returned by mmap()

  46. libdet libdet libdet must intercept potential sources of nondeterminism at runtime. Nondeterministic OS Solution properties ● e.g., reading addresses ● Disable address-space layout returned by mmap() randomization (ASLR)

  47. detflow detflow Static Low determinism overall enforcement overhead Dynamic runtime sandboxing

  48. Case Case studies es ● Ran a deterministic version of make against SPLASH2 benchmarks ● Performance is essentially identical to that of GNU make ● Ported various bioinformatics scripts to defmow and measured parallel speedup ● Overall performance overhead for determinism enforcement is less than 1%

  49. Sel Select ected SPL ed SPLASH ASH2 benchmark benchma rks barnes raytrace 2.4 6 DetIO-Det DetIO-Det 2.2 Median time in seconds GNU make Median time in seconds GNU make 5 2 DetIO-NonDet DetIO-NonDet 1.8 4 1.6 3 1.4 1.2 2 1 1 0.8 0.6 0 0 2 4 6 8 10 12 14 16 0 2 4 6 8 10 12 14 16 Threads Threads (Lower is better)

  50. Bioi Bioinf nfor ormat atics apps cs apps, par parall llel el spee peedup 16 16 bwa-Det bwa-NonDet Parallel speedup over sequential NonDet bwa-Det 14 clustal-Det bwa-NonDet Parallel speedup over sequential NonDet clustal-NonDet 14 mothur-Det 12 clustal-Det mothur-NonDet raxml-Det clustal-NonDet 10 raxml-NonDet mothur-Det 12 mothur-NonDet 8 raxml-Det 6 10 raxml-NonDet 4 8 2 0 0 2 4 6 8 10 12 14 16 6 Threads 4 2 0 0 2 4 6 8 10 12 14 16 Threads (Higher is better)

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend