Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up
for free
Solid Ground
Saša Jurić
March 06, 2017
Programming
2
560
Solid Ground
ElixirDaze 2017
Video available at
https://www.youtube.com/watch?v=5SbWapbXhKo
Saša Jurić
March 06, 2017
Tweet
Share
More Decks by Saša Jurić
See All by Saša Jurić
sasajuric
0
120
sasajuric
3
380
sasajuric
3
510
sasajuric
3
230
sasajuric
16
1k
sasajuric
0
92
sasajuric
3
740
sasajuric
1
160
sasajuric
0
76
Other Decks in Programming
See All in Programming
ryosukes
0
1.3k
konstantin_diener
0
130
grapecity_dev
0
170
meemeelab
0
280
neripark
3
620
joergneumann
0
120
afilina
PRO
0
120
kentatada
0
400
christianliebel
PRO
0
130
amaotone
15
7.8k
numeroanddev
1
220
naokioouchi
1
190
Featured
See All Featured
frogandcode
128
20k
keathley
20
700
bkeepers
52
4.2k
denniskardys
219
120k
chrislema
173
14k
tammielis
237
23k
62gerente
587
200k
qrush
285
19k
malarkey
393
61k
jlugia
217
16k
holman
288
130k
aarron
257
36k
Transcript
Solid ground @sasajuric aircloak.com
None
long-running system many tasks soft real-time finite time program all-or-nothing
hard real-time
NIFs
scheduler scheduler scheduler scheduler BEAM CPU CPU CPU CPU
frequent context switches
t1 t2 t3 t4 t5 10 s 1 ms 1
ms 1 ms 1 ms
t1 t2 t3 t4 t5 t1 BEAM scheduler
t2 t3 t4 t5 t1 cooperative scheduler
thread 1 thread n … long running task long running
task blocked cooperative scheduler
thread 1 thread n … long running task long running
task not blocked :-) BEAM scheduler
activities as runtime citizens
send(pid, :please_stop)
mref = Process.monitor(pid) send(pid, :please_stop) receive do {:DOWN, ^mref, :process,
^pid, _reason} -> :ok end
mref = Process.monitor(pid) send(pid, :please_stop) receive do {:DOWN, ^mref, :process,
^pid, _reason} -> :ok after :timer.seconds(5) -> Process.exit(pid, :kill) receive do {:DOWN, ^mref, :process, ^pid, _reason} -> :ok end end
task = Task.async(fn -> ... end) case Task.yield(task, :timer.seconds(5)) do
{:ok, result} -> do_something(result) nil -> Task.shutdown(task, :brutal_kill) end
shared-nothing concurrency
Process heap resources
process-owned “stuff” is released
supervision tree
system backend frontend chat history repo cache endpoint
system backend chat history repo
supervisor foundations frequent context switching activities as runtime citizens observable
process termination stoppable processes shared-nothing concurrency
runtime guarantees syntax developer friendliness ecosystem
Image credit Scales of Justice