File: paexec.tex

package info (click to toggle)
paexec 1.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 904 kB
  • sloc: sh: 3,435; ansic: 1,959; makefile: 174; pascal: 19
file content (760 lines) | stat: -rw-r--r-- 21,164 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
%%%begin-myprojects
\documentclass[hyperref={colorlinks=true}]{beamer}

\usepackage{fancyvrb,relsize}
\usepackage{graphicx}

\setbeamertemplate{navigation symbols}{}

%\usetheme{Boadilla}
%\usetheme{CambridgeUS}
%\usetheme{Malmoe}
%\usetheme{Singapore}
%\usetheme{boxes}

%\usecolortheme{crane}
%\usecolortheme{dove}
\usecolortheme{seagull} % very cool with \usetheme{default}
%\usefonttheme{professionalfonts}
%\useinnertheme{rectangles}

\mode<presentation>
\title{paexec -- distributes tasks over network or CPUs}
\author{Aleksey Cheusov \\ \texttt{vle@gmx.net}}
\date{Minsk, Belarus, 2013}

\begin{document}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newenvironment{CodeSmall}[1]%
               {\Verbatim[label=\bf{#1},frame=single,%
                   fontsize=\footnotesize,%
                   commandchars=\\\{\}]}%
               {\endVerbatim}
\newenvironment{CodeSmallNoLabel}%
               {\Verbatim[frame=single,%
                   fontsize=\footnotesize,%
                   commandchars=\\\{\}]}%
               {\endVerbatim}

\newenvironment{Code}[1]%
              {\Verbatim[label=\bf{#1},frame=single,%
                  fontsize=\small,%
                  commandchars=\\\{\}]}%
              {\endVerbatim}
\newenvironment{CodeNoLabel}%
               {\Verbatim[frame=single,%
                   fontsize=\small,%
                   commandchars=\\\{\}]}%
               {\endVerbatim}

\newenvironment{CodeLarge}[1]%
               {\Verbatim[label=\bf{#1},frame=single,%
                   fontsize=\large,%
                   commandchars=\\\{\}]}%
               {\endVerbatim}
\newenvironment{CodeLargeNoLabel}%
               {\Verbatim[frame=single,%
                   fontsize=\large,%
                   commandchars=\\\{\}]}%
               {\endVerbatim}

%\newcommand{\prompt}[1]{\textcolor{blue}{#1}}
%\newcommand{\prompt}[1]{\textbf{#1}\textnormal{}}
\newcommand{\prompt}[1]{{\bf{#1}}}
%\newcommand{\h}[1]{\textbf{#1}}
%\newcommand{\h}[1]{\bf{#1}\textnormal{}}
\newcommand{\h}[1]{{\bf{#1}}}
\newcommand{\name}[1]{{\tt{#1}}}
\newcommand{\URL}[1]{\textbf{#1}}
\newcommand{\AutohellFile}[1]{\textcolor{red}{#1}}
\newcommand{\MKCfile}[1]{\textcolor{green}{#1}}
\newcommand{\ModuleName}[1]{\textbf{#1}\textnormal{}}
\newcommand{\ProgName}[1]{\textbf{#1}\textnormal{}}
\newcommand{\ProjectName}[1]{\textbf{#1}\textnormal{}}
\newcommand{\PackageName}[1]{\textbf{#1}\textnormal{}}
\newcommand{\MKC}[1]{\large\textsf{#1}\textnormal{}\normalsize}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% \begin{frame}
%%   \frametitle{qqq}
%%   \begin{code}{files in the directory}
%%     bla bla bla
%%   \end{code}
%% \end{frame}

%%%end-myprojects

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}
  \titlepage
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}{}
  \frametitle{Problem}
  \begin{block}{}
    \begin{itemize}
    \item Huge amount of data to process
    \item Typical desktop machines have more than one CPU
    \item Unlimited resources are available on the Internet
    \item Heterogeneous environment (*BSD, Linux, Windows...)
    \end{itemize}
  \end{block}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]
  \frametitle{Solution}

  \begin{block}{}
      \begin{CodeLarge}{Usage}
paexec [OPTIONS] \textbackslash
  -n 'machines or CPUs' \textbackslash
  -t 'transport program' \textbackslash
  -c 'calculator' < tasks
      \end{CodeLarge}
      \begin{CodeLarge}{example}
ls -1 *.wav | \textbackslash
paexec -x -c 'flac -s' -n +4 > /dev/null
      \end{CodeLarge}
      \begin{CodeLarge}{example}
paexec \textbackslash
  -n 'host1 host2 host3' \textbackslash
  -t /usr/bin/ssh \textbackslash
  -c ~/bin/toupper < tasks
      \end{CodeLarge}
  \end{block}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]
  \frametitle{Example 1: toupper}
  Our goal is to convert strings to upper case in parallel
  \begin{block}{}
      \begin{Code}{\~{}/bin/toupper}
#!/usr/bin/awk -f
\{
   print " ", toupper(\$0)
   print ""  # empty line -- end-of-task marker!
   fflush()  # We must flush stdout!
\}
      \end{Code}
  \end{block}
  \begin{block}{}
      \begin{Code}{\~{}/tmp/tasks}
apple
bananas
orange
      \end{Code}
  \end{block}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]
  \frametitle{Example 1: toupper}
\name{\~{}/bin/toupper} script will be run only once on remote servers
``server1'' and ``server2''.  It takes tasks from stdin (one task per
line). Transport program is \name{ssh(1)}.
  \begin{block}{}
      \begin{CodeLarge}{paexec invocation}
\prompt{\$} paexec \h{-t} ssh \h{-c} ~/bin/toupper \textbackslash
   \h{-n} 'server1 server2' < tasks > results
\prompt{\$} cat results
 BANANAS
 ORANGE
 APPLE
\prompt{\$}
      \end{CodeLarge}
  \end{block}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]
  \frametitle{Example 1: toupper}
Options \h{-l} and \h{-r} add the task number and server where this
task is processed to stdout.
  \begin{block}{}
      \begin{CodeLarge}{paexec -lr invocation}
\prompt{\$} paexec \h{-lr} -t ssh -c ~/bin/toupper \textbackslash
   -n 'server1 server2' < tasks > results
\prompt{\$} cat results
\h{server2 2}  BANANAS
\h{server2 3}  ORANGE
\h{server1 1}  APPLE
\prompt{\$}
      \end{CodeLarge}
  \end{block}
\end{frame}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]
  \frametitle{Example 1: toupper}
The same as above but four instances of \name{\~{}/bin/toupper} are ran locally.
  \begin{block}{}
      \begin{CodeLarge}{paexec invocation}
\prompt{\$} paexec \h{-n} +4 -c ~/bin/toupper
   < tasks > results
\prompt{\$} cat results
BANANAS
ORANGE
APPLE
\prompt{\$}
      \end{CodeLarge}
  \end{block}
\end{frame}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]
  \frametitle{Example 1: toupper}
The same as above but without \name{\~{}/bin/toupper}.  In this example we
run AWK program for each individual task.  At the same time we still
make only one ssh connection to each server regardless of a number of
tasks given on input.
  \begin{block}{}
      \begin{CodeLarge}{paexec invocation}
\prompt{\$} paexec \h{-x} -t ssh -n 'server1 server2' \textbackslash
\h{-c} "awk 'BEGIN \{print toupper(ARGV[1])\}' " \textbackslash
    < tasks > results
\prompt{\$} cat results
ORANGE
BANANAS
APPLE
\prompt{\$}
      \end{CodeLarge}
  \end{block}
\end{frame}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]
  \frametitle{Example 1: toupper}
If we want to "shquate" less one can use option \h{-C} instead of \h{-c}
and specify command after options.
  \begin{block}{}
      \begin{CodeLarge}{paexec invocation}
\prompt{\$} paexec -x \h{-C} -t ssh -n 'server1 server2' \textbackslash
awk 'BEGIN \{print toupper(ARGV[1])\}' \textbackslash
    < tasks > results
\prompt{\$} cat results
ORANGE
BANANAS
APPLE
\prompt{\$}
      \end{CodeLarge}
  \end{block}
\end{frame}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]
  \frametitle{Example 1: toupper}
With options \h{-z} or \h{-Z} we can easily run our tasks on
unreliable hosts. If we cannot connect or lost connection to the
server, paexec will redistribute failed tasks to another server.
  \begin{block}{}
      \begin{CodeLarge}{paexec invocation}
\prompt{\$} paexec \h{-Z}240 -x -t ssh \textbackslash
-n 'server1 badhostname server2' \textbackslash
-c "awk 'BEGIN \{print toupper(ARGV[1])\}' " \textbackslash
    < tasks > results
{\it ssh: Could not resolve hostname badhostname:}
{\it  No address associated with hostname}
{\it  badhostname 1 fatal}
\prompt{\$} cat results
ORANGE
BANANAS
APPLE
\prompt{\$}
      \end{CodeLarge}
  \end{block}
\end{frame}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\linespread{0.5}
\begin{frame}[fragile]
  \frametitle{Example 2: parallel banner(1)}

  \begin{block}{}
      \begin{CodeLarge}{what is banner(1)?}
\prompt{\$} banner -f @ NetBSD

@     @                 @@@@@@   @@@@@  @@@@@@
@@    @  @@@@@@   @@@@@ @     @ @     @ @     @
@ @   @  @          @   @     @ @       @     @
@  @  @  @@@@@      @   @@@@@@   @@@@@  @     @
@   @ @  @          @   @     @       @ @     @
@    @@  @          @   @     @ @     @ @     @
@     @  @@@@@@     @   @@@@@@   @@@@@  @@@@@@


\prompt{\$}
      \end{CodeLarge}
  \end{block}
\end{frame}
\linespread{1}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]
  \frametitle{Example 2: parallel banner(1)}
\name{\~{}/bin/pbanner} is wrapper for \name{banner(1)} for reading tasks line by line.
Magic line is used instead empty line as an end-of-task marker.
  \begin{block}{}
      \begin{Code}{\~{}/bin/pbanner}
#!/usr/bin/env sh

while read task; do
   banner -f M "\$task" |
   echo \h{"\$PAEXEC\_EOT"} # end-of-task marker
done
      \end{Code}
      \begin{Code}{tasks}
pae
xec
      \end{Code}

      \begin{Code}{paexec invocation}
\prompt{\$} paexec -l \h{-mt='SE@X-L0S0!&'} -c ~/bin/pbanner \textbackslash
   -n +2 < tasks > result
\prompt{\$}
      \end{Code}
  \end{block}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\linespread{0.5}
\begin{frame}[fragile]
  \frametitle{Example 2: parallel banner(1)}
\name{paexec(1)} reads calculator's output asynchronously.
So, its output is sliced.
  \begin{block}{}
      \begin{CodeSmall}{Sliced result}
\prompt{\$} cat result
2 
2 
2  M    M  MMMMMM   MMMM
2   M  M   M       M    M
1 
1 
1  MMMMM     MM    MMMMMM
1  M    M   M  M   M
1  M    M  M    M  MMMMM
1  MMMMM   MMMMMM  M
2    MM    MMMMM   M
2    MM    M       M
2   M  M   M       M    M
2  M    M  MMMMMM   MMMM
2 
1  M       M    M  M
1  M       M    M  MMMMMM
1 
\prompt{\$}
      \end{CodeSmall}
  \end{block}
\end{frame}
\linespread{1}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\linespread{0.5}
\begin{frame}[fragile]
  \frametitle{Example 2: parallel banner(1)}
\name{paexec\_reorder(1)} normalizes \name{paexec(1)}'s output.
  \begin{block}{}
      \begin{CodeSmall}{Ordered result}
\prompt{\$} paexec_reorder \h{-mt='SE@X-L0S0!&'} results


MMMMM     MM    MMMMMM
M    M   M  M   M
M    M  M    M  MMMMM
MMMMM   MMMMMM  M
M       M    M  M
M       M    M  MMMMMM



M    M  MMMMMM   MMMM
 M  M   M       M    M
  MM    MMMMM   M
  MM    M       M
 M  M   M       M    M
M    M  MMMMMM   MMMM


\prompt{\$}
      \end{CodeSmall}
  \end{block}
\end{frame}
\linespread{1}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\linespread{0.5}
\begin{frame}[fragile]
  \frametitle{Example 2: parallel banner(1)}
The same as above but using magic end-of-task marker provided by \name{paexec(1)}.
  \begin{block}{}
      \begin{CodeSmall}{Ordered result}
\prompt{\$} paexec \h{-y} -lc ~/bin/pbanner -n+2 < tasks | paexec_reorder \h{-y}


MMMMM     MM    MMMMMM
M    M   M  M   M
M    M  M    M  MMMMM
MMMMM   MMMMMM  M
M       M    M  M
M       M    M  MMMMMM



M    M  MMMMMM   MMMM
 M  M   M       M    M
  MM    MMMMM   M
  MM    M       M
 M  M   M       M    M
M    M  MMMMMM   MMMM


\prompt{\$}
      \end{CodeSmall}
  \end{block}
\end{frame}
\linespread{1}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\linespread{0.5}
\begin{frame}[fragile]
  \frametitle{Example 2: parallel banner(1)}
For this trivial task wrapper like \name{\~{}/bin/pbanner} is not needed.
We can easily run \name{banner(1)} directly.
  \begin{block}{}
      \begin{CodeSmall}{Sliced result}
\prompt{\$} paexec -l \h{-x} -c banner -n+2 < tasks
2 
2 
2  M    M  MMMMMM   MMMM
2   M  M   M       M    M
2    MM    MMMMM   M
2    MM    M       M
2   M  M   M       M    M
1 
1 
1  MMMMM     MM    MMMMMM
1  M    M   M  M   M
1  M    M  M    M  MMMMM
1  MMMMM   MMMMMM  M
2  M    M  MMMMMM   MMMM
2 
1  M       M    M  M
1  M       M    M  MMMMMM
1 
\prompt{\$}
      \end{CodeSmall}
  \end{block}
\end{frame}
\linespread{1}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]
  \frametitle{Example 3: dependency graph of tasks}
\name{paexec(1)} is able to build tasks taking into account their ``dependencies''.
Here ``devel/gmake'' and others are pkgsrc packages. Our goal in this example
is to build pkgsrc package audio/abcde and all its build-time and compile-time
dependencies.
  \begin{block}{}
    \begin{figure}
      \includegraphics[width=\textwidth, height=\textheight, keepaspectratio=true]{dep-graph.eps}
    \end{figure}
  \end{block}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]
  \frametitle{Example 3: dependency graph of tasks}
\name{``paexec \h{-g}''} takes a dependency graph on input (in \name{tsort(1)} format).
Tasks are separated by space (\name{paexec -md=}).
  \begin{block}{}
      \begin{CodeSmall}{\~{}/tmp/packages\_to\_build}
audio/cd-discid audio/abcde
textproc/gsed audio/abcde
audio/cdparanoia audio/abcde
audio/id3v2 audio/abcde
audio/id3 audio/abcde
misc/mkcue audio/abcde
shells/bash audio/abcde
devel/libtool-base audio/cdparanoia
devel/gmake audio/cdparanoia
devel/libtool-base audio/id3lib
devel/gmake audio/id3v2
audio/id3lib audio/id3v2
devel/m4 devel/bison
lang/f2c devel/libtool-base
devel/gmake misc/mkcue
devel/bison shells/bash
      \end{CodeSmall}
  \end{block}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]
  \frametitle{Example 3: dependency graph of tasks}
If option -g is applied, every task may succeed or fail. In case of failure
all dependants fail recursively.
For this to work we have to slightly adapt ``calculator''.
  \begin{block}{}
      \begin{CodeSmall}{\~{}/bin/pkg\_builder}
#!/usr/bin/awk -f

\{
   print "build " \$0
   \h{print "success"} # build succeeded! (paexec -ms=)
   print ""        # end-of-task marker
   fflush()        # we must flush stdout
\}
      \end{CodeSmall}
  \end{block}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]
  \frametitle{Example 3: dependency graph of tasks}

  \begin{block}{}
      \begin{CodeSmall}{paexec -g invocation (no failures)}
\prompt{\$} paexec \h{-g} -l -c ~/bin/pkg_builder -n 'server2 server1' \textbackslash
    -t ssh < ~/tmp/packages_to_build | paexec_reorder > result
\prompt{\$} cat result
build textproc/gsed
\h{success}
build devel/gmake
success
build misc/mkcue
success
build devel/m4
success
build devel/bison
success
...
build audio/id3v2
success
build audio/abcde
success
\prompt{\$}
      \end{CodeSmall}
  \end{block}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]
  \frametitle{Example 3: dependency graph of tasks}
Let's suppose that ``devel/gmake'' fails to build.

  \begin{block}{}
      \begin{CodeSmall}{\~{}/bin/pkg\_builder}
#!/usr/bin/awk -f

\{
   print "build " \$0
   if (\$0 == "devel/gmake")
      \h{print "failure"} # Oh no...
   else
      print "success" # build succeeded!

   print ""        # end-of-task marker
   fflush()        # we must flush stdout
\}
      \end{CodeSmall}
  \end{block}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]
  \frametitle{Example 3: dependency graph of tasks}
Package ``devel/gmake'' and all dependants are marked as failed.
Even if failures happen, the build continues.
  \begin{block}{}
      \begin{CodeSmall}{paexec -g invocation (with failures)}
\prompt{\$} paexec -gl -c ~/bin/pkg_builder -n 'server2 server1' \textbackslash
    -t ssh < ~/tmp/packages_to_build | paexec_reorder > result
\prompt{\$} cat result
build audio/cd-discid
success
build audio/id3
success
build devel/gmake
\h{failure}
\h{devel/gmake audio/cdparanoia audio/abcde audio/id3v2 misc/mkcue}
build devel/m4
success
build textproc/gsed
success
...
\prompt{\$}
      \end{CodeSmall}
  \end{block}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]
  \frametitle{Example 3: dependency graph of tasks}
paexec is resistant not only to network failures but also to
\h{unexpected} calculator \h{exits or crashes}.
  \begin{block}{}
      \begin{CodeSmall}{\~{}/bin/pkg\_builder}
#!/usr/bin/awk -f

\{
   "hostname -s" | getline hostname
   print "build " \$0 " on " hostname

   if (hostname == "server1" && \$0 == "textproc/gsed")
      \h{exit 139}
      # Damn it, I'm dying...
      # Take a note that exit status doesn't matter.
   else
      print "success" # Yes! :-)

   print ""        # end-of-task marker
   fflush()        # we must flush stdout
\}
      \end{CodeSmall}
  \end{block}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]
  \frametitle{Example 3: dependency graph of tasks}
``textproc/gsed'' failed on ``server1'' but then succeeded on ``server2''.
Every 300 seconds we try to reconnect to ``server1''. Keywords ``success'',
``failure'' and ``fatal'' may be changed with a help of -ms=, -mf= and
-mF= options respectively.
  \begin{block}{}
      \begin{CodeSmall}{paexec -Z300 invocation (with failure)}
\prompt{\$} paexec -gl -Z300 -t ssh -c ~/bin/pkg_builder \textbackslash
      -n 'server2 server1' < ~/tmp/packages_to_build \textbackslash
      | paexec_reorder > result
\prompt{\$} cat result
build audio/cd-discid on server2
success
\h{build textproc/gsed on server1}
\h{fatal}
\h{build textproc/gsed on server2}
\h{success}
build audio/id3 on server2
success
...
\prompt{\$}
      \end{CodeSmall}
  \end{block}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]
  \frametitle{Example 4: Converting .wav files to .flac or .ogg}
In trivial cases we don't need relatively complex ``calculator''.
Running a trivial command may be enough.
Below we run three .wav to .flac/.ogg convertors in parallel.
If \h{-x} is applied, task is passed to calculator as an argument.
\begin{block}{}
  \begin{CodeSmall}{paexec -x invocation}
\prompt{\$} ls -1 *.wav | paexec \h{-x} -c 'flac -s' -n+3 >/dev/null
\prompt{\$}
  \end{CodeSmall}
\end{block}
\begin{block}{}
  \begin{CodeSmall}{paexec -x invocation}
\prompt{\$} ls -1 *.wav | paexec -ixC -n+3 oggenc -Q | grep .
01-Crying_Wolf.wav
02-Autumn.wav
03-Time_Heals.wav
04-Alice_(Letting_Go).wav
05-This_Side_Of_The_Looking_Glass.wav
...
\prompt{\$}
  \end{CodeSmall}
\end{block}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]
  \frametitle{Example 5: paexec -W}
If different tasks take different amount of time to process, than it
makes sense to process ``heavier'' ones earlier in order to minimize
total calculation time. For this to work one can weigh each tasks.
Note that this mode enables ``graph'' mode automatically.
\begin{block}{}
  \begin{CodeSmall}{\~{}/bin/calc}
#!/bin/sh
# \$1 -- task given on input
if test \$1 = huge; then
    sleep 6
else
    sleep 1
fi

echo "task \$1 done"
  \end{CodeSmall}
\end{block}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]
  \frametitle{Example 5: paexec -W}
This is how we run unweighted tasks. The whole process takes 8 seconds.
\begin{block}{}
  \begin{CodeSmall}{paexec invocation}
\prompt{\$} printf 'small1\textbackslash{nsmall2}\textbackslash{nsmall3}\textbackslash{nsmall4}\textbackslash{nsmall5}\textbackslash{nhuge}\textbackslash{n}' |
time -p paexec -c \~{}/bin/calc -n +2 -xg | grep -v success
task small2 done
task small1 done
task small3 done
task small4 done
task small5 done
task huge done
real         8.04
user         0.03
sys          0.03
\prompt{\$}
  \end{CodeSmall}
\end{block}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]
  \frametitle{Example 5: paexec -W}
If we say paexec that the task ``huge'' is performed 6 times longer than others,
it starts``huge'' first and then others. In total we spend 6 seconds for all tasks.
\begin{block}{}
  \begin{CodeSmall}{paexec -W1 invocation}
\prompt{\$} printf 'small1\textbackslash{nsmall2}\textbackslash{nsmall3}\textbackslash{nsmall4}\textbackslash{nweight: huge 6}\textbackslash{n}' |
time -p paexec -c \~{}/bin/calc -n +2 -x \h{-W1} | grep -v success
task small1 done
task small2 done
task small3 done
task small4 done
task small5 done
task huge done
real         6.02
user         0.03
sys          0.02
\prompt{\$}
  \end{CodeSmall}
\end{block}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]
  \frametitle{}
  For details see the manual page.
  \begin{center}
    \huge
    The End
  \end{center}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\end{document}