/
tlb-intro.tex
638 lines (565 loc) · 19.2 KB
/
tlb-intro.tex
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
\documentclass{beamer}
\mode<presentation>
{
\usetheme{Warsaw}
\setbeamercovered{transparent}
}
\usepackage[english]{babel}
\usepackage[latin1]{inputenc}
\usepackage{times}
\usepackage[T1]{fontenc}
\usepackage{multicol}
\title[TLB - http://test-load-balancer.github.com]
{TLB}
\subtitle
{rocket booster for your build}
\author[Pavan, Janmejay]
{Pavan KS\inst{1} \and Janmejay Singh\inst{2}}
\institute[ThoughtWorks Studios]
{
\inst{1}%
mail: itspanzi@gmail.com\\
blog: http://itspanzi.blogspot.com
\and
\inst{2}%
mail: singh.janmejay@gmail.com\\
blog: http://codehunk.wordpress.com
}
\date[GIDS]
{\pgfimage[height=1.2cm]{images/GIDS.jpg}}
\subject{Introduction to internals of TLB, and its usage}
\AtBeginSubsection[]
{
\begin{frame}<beamer>{Outline}
\tableofcontents[currentsection,currentsubsection]
\end{frame}
}
\begin{document}
\begin{frame}
\titlepage
\end{frame}
\begin{frame}{TLB what?}
\begin{itemize}
\item A Free and Open Source software: \emph{BSD licensed}
\item Cuts your build time by executing tests parallely on a grid
\item Supports multiple build tools
\item Supports multiple testing tools
\item Supports multiple languages
\end{itemize}
\end{frame}
\begin{frame}{Whats in it for me?}
\begin{centering}
{\large What can I expect out of this session?}\\
\quad\\
\begin{itemize}
\item A small, hopefully interesting, story that describes \emph{a problem}
\item How we solved \emph{that problem}
\item How we can help you solve it
\item How you can help us, help others solve it!
\end{itemize}
\end{centering}
\end{frame}
\begin{frame}{Outline}
\tableofcontents
\end{frame}
\section{Motivation}
\subsection{Problem that we solved}
\begin{frame}
\begin{center}
{\huge The Story}
\end{center}
\end{frame}
\begin{frame}{This is the story of how we went from...}
\begin{centering}
\pgfimage[width=10cm]{images/no-balance-go.png}
\par
\pause
\begin{center}
What is it doing that takes more than {\color{red}2 hours and 7 minutes}?
\end{center}
\end{centering}
\end{frame}
\begin{frame}{to...}
\begin{centering}
\pgfimage[width=10cm]{images/count-balance-go.png}
\par
\end{centering}
\end{frame}
\begin{frame}{to...}
\begin{centering}
\pgfimage[width=10cm]{images/time-balance-go.png}
\par
\end{centering}
\end{frame}
\begin{frame}
\begin{centering}
\begin{itemize}
\item With just a few lines changed in the build script \& executing tests parallely.
\pause
\item The longish build 'firefox' split into 16 partitions to executed parallely on 16 virtual machines.
\end{itemize}
\end{centering}
\end{frame}
\subsection{Dream: Fast Builds}
\begin{frame}
\begin{centering}
\begin{itemize}
\item Fast build = Rapid development
\pause
\item Devs spend less time waiting to checkin
\begin{itemize}
\item Need not be limited to unit/integration tests
\item Functional/Acceptance tests
\end{itemize}
\pause
\item Easier for devs to run precommit builds - Results in pulling upstream changes often and running builds frequently
\end{itemize}
\end{centering}
\end{frame}
\begin{frame}{Also we know that...}
\begin{centering}
\begin{itemize}
\item Major part of build time is spent in running tests
\pause
\item Speeding up builds is non trivial
\pause
\item Most teams have a dev task for this don\text{'}t they??
\end{itemize}
\end{centering}
\end{frame}
\begin{frame}{Common solutions...}
\begin{centering}
\begin{itemize}
\item Split applications into modules
\pause
\begin{itemize}
\item Difficult to model (typically end up in diamond dependencies)
\pause
\item Pipelines (unit -> integration -> smoke -> functional) (serial process)
\pause
\item BUT, if downstream dependencies fail, turn around time to fix is huge
\end{itemize}
\pause
\item Throw more hardware at it - Slice and dice
\pause
\begin{itemize}
\item Hand written partitioning using directories/tags etc (unequal partitions)
\end{itemize}
\end{itemize}
\end{centering}
\pause
Logical! but Suboptimal :-(\\
\pause
Nither too efficient nor effective.
\end{frame}
\begin{frame}{Optimal solution}
\begin{center}
Optimal solution can be obtained by minimizing, the following expression.\\
\quad
\begin{alignat}{3}
D ( A_1, A_2, ... A_n) = max \left \{ \sum_{x \in A_i} x \right \} - min \left \{ \sum_{x \in A_j} x \right \}
\end{alignat}\\
\quad \\
Its ideal when global minima for this function is reached.
\end{center}
\end{frame}
\section{TLB}
\subsection{Introducing TLB}
\begin{frame}{What if partitioning can be off-loaded?}
What does TLB do?
\begin{itemize}
\item Makes \texttt{n} partitions
\pause
\item Understands which partition the \emph{current test runner process} is
\pause
\item Each partition runs only \texttt{one} of the \texttt{n} \emph{mutually exclusive \& collectively exhaustive} sets
\end{itemize}
\end{frame}
\begin{frame}{For example:}
Some potential balancing strategies could be
\pause
\begin{itemize}
\item Partition tests to make every set have equal number of tests
\pause
\item Or to have every set take about the same time to finish
\end{itemize}
\pause
Some of these strategies require a central place to store and retrive test-data(running-time, result etc)
\end{frame}
\begin{frame}{Setup}{Typical Setup}
\begin{centering}
\pgfimage[width=9.5cm]{images/typical-setup.png}
\end{centering}
\end{frame}
\begin{frame}{Setup}{Alien Environment Setup}
\begin{centering}
\pgfimage[width=9.5cm]{images/alien-env-setup.png}
\end{centering}
\end{frame}
\begin{frame}{Communication}{Server-Client-Runner Talk}
\begin{multicols}{2}
\begin{centering}
\pgfimage[height=6cm]{images/server-client-timeline-1.png}
\end{centering}
\begin{center}
{\huge Step 1}\\
\quad\\
{\large Receive list of to-be-run tests from the testing-framework}
\end{center}
\end{multicols}
\end{frame}
\begin{frame}{Communication}{Server-Client-Runner Talk}
\begin{multicols}{2}
\begin{centering}
\pgfimage[height=6cm]{images/server-client-timeline-2.png}
\end{centering}
\begin{center}
{\huge Step 2}\\
\quad\\
{\large Fetch historical test data from TLB server(tests that failed in the previous run/time taken by each test)}
\end{center}
\end{multicols}
\end{frame}
\begin{frame}{Communication}{Server-Client-Runner Talk}
\begin{multicols}{2}
\begin{centering}
\pgfimage[height=6cm]{images/server-client-timeline-3.png}
\end{centering}
\begin{center}
{\huge Step 3}\\
\begin{itemize}
\item {\large Prune the list of to-be-run tests to get tests to be actually executed(other partitions take care of pruned items)}
\item {\large Re-order the pruned list,for instance \emph{pull tests that failed in the previous run to execute first}}
\end{itemize}
\end{center}
\end{multicols}
\end{frame}
\begin{frame}{Communication}{Server-Client-Runner Talk}
\begin{multicols}{2}
\begin{centering}
\pgfimage[height=6cm]{images/server-client-timeline-4.png}
\end{centering}
\begin{center}
{\huge Step 4}\\
\begin{itemize}
\item {\large Let the party begin, \emph{execute the pruned tests}}
\item {\large Continue capturing test-result/test-time as the suites run}
\end{itemize}
\end{center}
\end{multicols}
\end{frame}
\begin{frame}{Communication}{Server-Client-Runner Talk}
\begin{multicols}{2}
\begin{centering}
\pgfimage[height=6cm]{images/server-client-timeline-5.png}
\end{centering}
\begin{center}
{\huge Step 5}\\
\quad\\
{\large Some feedback to the server; post test-run-time/test-results back, seeding data for future runs}
\end{center}
\end{multicols}
\end{frame}
\begin{frame}{Communication}{Server-Client-Runner Talk}
\begin{multicols}{2}
\begin{centering}
\pgfimage[height=6cm]{images/server-client-timeline-6.png}
\end{centering}
\begin{center}
{\huge Step 6}\\
\quad\\
{\large Terminate gracefully; build task returns}
\end{center}
\end{multicols}
\end{frame}
\begin{frame}{Ok enough of handwaving!}
\begin{center}
Well, that was all too abstract, lets see what TLB has to offer in terms of concrete features.
\end{center}
\end{frame}
\subsection{Concepts in TLB}
\begin{frame}{TLB Client}{the workhorse}
TLB client has two major sub-units.
\pause
\quad\\
\begin{itemize}
\item Balancer - \emph{the pruner guy} ({\small chosen by setting an environment variable \text{TLB\_CRITERIA}})
\quad\\
\pause
\item Orderer - \emph{the shuffler guy} ({\small chosen by setting an environment variable \text{TLB\_ORDERER}})
\end{itemize}
{\tiny both environment variables require fully qualified java class-names}
\end{frame}
\begin{frame}{TLB Client}{Balancer}
\begin{center}
{\large Count-based Balancing}\\
\quad\\
\quad\\
20 tests / 4 splits = 5 tests on each\\
\quad\\
\quad\\
\begin{itemize}
\item Conceptually straight-forward
\item Inefficient in practice
\item TLB uses this as a fallback, not recomended as preffered algorithm
\end{itemize}
\end{center}
\end{frame}
\begin{frame}{TLB Client}{Balancer}
\begin{center}
{\large Time-based Balancing}\\
{\tiny (inspired by Amdahl`s law)}\\
\quad\\
\quad\\
N tests / 4 splits $\approx$ 4 splits that take equal time
\quad\\
\quad\\
\begin{itemize}
\item Much better, yields fairly close to ideal solution
\item One slow machine can not only slow down the current run, but skew balancing on the next one too
\end{itemize}
\end{center}
\end{frame}
\begin{frame}{TLB Client}{Balancer}
\begin{center}
{\large Smoothened Time-based Balancing}\\
{\tiny (Ensures no outliers, builds on top of time based balancing)}\\
\quad\\
{\small N tests / 4 splits $\approx$ 4 splits which take equal time based on history over past few/several runs \\
While exponential smoothing, every test-time entry $ S_t \quad \forall t > 0 $ is recorded as:}
\begin{alignat}{3}
S_1 & = x_o\\
S_t & = \alpha x_{t-1} + (1 - \alpha)S_{t-1} \quad
\forall
\begin{cases}
t > 1\\
0 < \alpha < 1
\end{cases}
\end{alignat}
{\tiny Where $\alpha$ is the factor of smoothing, which can be tuned externally for every partition and \texttt{x} is unsmoothed reading.}
\end{center}
\end{frame}
\begin{frame}{TLB Client}{Balancer}
\begin{center}
{\large Default-chain Balancing}\\
\quad\\
\begin{itemize}
\item Allows users to define \emph{criteria chain}, which is a COLON(\text{:}) seperated list of algorithms
\item The chain may include some custom balancer recepies of your own
\item Used to ensure build doesn't fail when no data available to do advanced algorithms like Time-balance
\item Allows defaulting to simpler algorithms like Count-balancing
\end{itemize}
\end{center}
\end{frame}
\begin{frame}{TLB Client}{Balancer}
\begin{center}
{\large *XYZ* Balancing}\\
{\tiny (This is not a canned algorithm, its something you can create)}\\
\quad\\
\begin{itemize}
\item You can create your custom balancing algorithm, and use it with TLB
\item The contract is enforced by a java \text{abstract class} called \emph{TestSplitterCriteria}
\item If it can potentially fail in some situations and you want a fallback, you can use \emph{DefaultingTestSplitterCriteria} with your balancer in chain
\item Note: Algorithm need to be repeatable, since its executed on every partition. \emph{Mutual-exclusion \& Collective-exhausion} are imparative.
\end{itemize}
\end{center}
\end{frame}
\begin{frame}{TLB Client}{Orderer}
\begin{center}
{\large Failed First Orderer}\\
{\tiny (Runs tests that failed last time around, first)}\\
\begin{itemize}
\item Perfect for fixing builds that have a tendency to break after 6 in the evening
\item You don\text{'}t need to wait for the entire build, just watch the console log for a few minutes, as you see the test you fixed pass and scroll by
\end{itemize}
\end{center}
\end{frame}
\begin{frame}{TLB Client}{Orderer}
\begin{center}
{\large *ABC* Orderer}\\
{\tiny (This is not a canned algorithm, its something you can create)}\\
\quad\\
\begin{itemize}
\item You can create your custom ordering algorithm, and use it with TLB
\item The contract is enforced by a java \text{abstract class} called \emph{TestOrderer}
\item Ordering tests to ensure execution-order/side-effects is a slippery slope and is considered an \emph{ANTI PATTERN}, so we strongly recomend not abusing Ordering facility
\end{itemize}
\end{center}
\end{frame}
\begin{frame}{TLB Client}{Correctness Checking}
\begin{center}
{\large Correctness Checking}\\
{\tiny (Optional extension that allows you to check correctness of partitioning algorithm and/or your build configuration.)}\\
{\small Asserts correctness of...}
\quad\\
\begin{itemize}
\item new partitioning/ordering algoritms, \emph{ensures mutual exclusion/collective exhaustion}
\item build configuration, testing framework configuration
\item and TLB configuration in your environment
\end{itemize}
\end{center}
\end{frame}
\subsection{Show me the code honey!}
\begin{frame}
\begin{centering}
{\small TLB Client needs to embed in build environment and interact with a testing-framework}
\quad\\
\quad\\
\pause
\begin{itemize}
\item Balancing JUnit test-suite using Apache-Ant
\pause
\item Balancing Cucumber test-suite using Rake
\end{itemize}
\end{centering}
\end{frame}
\subsection{Hooking TLB up with your build process}
\begin{frame}{Leverage parallel execution capabilities of}{tools like...}
\begin{center}
\pgfimage[height=1.5cm]{images/go-logo.png}
\end{center}
\end{frame}
\begin{frame}{or for that matter}
\begin{center}
{\huge Hudson, Bamboo, TeamCity, Ant Hill Pro}(if you are rich enough),{\huge or even Capistrano/Shell script fork}(if you are a poor dev like us).\\
\end{center}
\end{frame}
\begin{frame}{Supported Setup(s)}
\begin{centering}
When we say Ruby, we mean both 1.9 and 1.8
\quad\\
\begin{itemize}
\item {\color{green}Junit} using {\color{red}Ant} or {\color{red}Buildr} for {\color{blue}Java}
\pause
\item {\color{green}Rspec 1.x \& 2.x} using {\color{red}Rake} on {\color{blue}MRI} and {\color{blue}JRuby}
\pause
\item {\color{green}Test::Unit} using {\color{red}Rake} on {\color{blue}MRI} and {\color{blue}JRuby}
\pause
\item {\color{green}Cucumber} using {\color{red}Rake} on {\color{blue}MRI} and {\color{blue}JRuby}
\pause
\item {\color{green}Twist} using {\color{red}Ant} or {\color{red}Buildr} for {\color{blue}Java}
\end{itemize}
\end{centering}
\end{frame}
\begin{frame}{Working on...}
\begin{centering}
{\color{green}Junit} using {\color{red}Maven} on {\color{blue}Java}
\quad\\
\quad\\
\begin{centering}
Waiting on \emph{http://jira.codehaus.org/browse/SUREFIRE-726}
\quad\\
\quad\\
\quad\\
Check out \emph{http://tinyurl.com/ceal2uy} (google groups thread and patchset)
\end{centering}
\end{centering}
\end{frame}
\begin{frame}{We plan to support...}
\begin{centering}
\begin{multicols}{2}
\begin{itemize}
\item {\color{green}TestNG} on {\color{blue}Java}
\item {\color{green}JBehave} on {\color{blue}Java}
\item {\color{green}NUnit} on {\color{blue}.Net}
\item {\color{green}MS Test} on {\color{blue}.Net}
\item {\color{green}PyUnit} on {\color{blue}Python}
\item {\color{green}CPPUnit} on {\color{blue} C++}
\item {\color{green}5am (fiveam)} on {\color{blue} CommonLisp}
\item {\color{green} ...} on {\color{blue} ...}
\end{itemize}
\begin{itemize}
\item {\color{red}NAnt} on {\color{blue}.Net}
\item {\color{red}MS Build} on {\color{blue}.Net}
\item {\color{red}...} on {\color{blue}...}
\end{itemize}
\end{multicols}
\end{centering}
\end{frame}
\begin{frame}{While thats our wish-list}
\begin{center}
\begin{itemize}
\item Bad news is, we haven't started work on most of these yet.\\
\pause
\item Good news is, we have good hackers, like yourself, listening to us here, who can help!
\end{itemize}
\pause
\quad\\
We'd love to support anything else that you can make time to contribute :-)
\end{center}
\end{frame}
\section{Dev Adrenaline}
\subsection{Polynomial Time Set-Partitioning}
\begin{frame}{Partitioning Approaches}
\begin{itemize}
\item Greedy Algorithm (time-balancing-criteria uses this one)
\item Differencing Algorithm (half done, not upstrem yet)
\item GA spike, terrifingly good (upstream as a spike, written in CommonLisp, needs some more tuning)
\end{itemize}
\end{frame}
\begin{frame}{GA spike for set-partitioning}
\begin{center}
{\large TLB doesn't have it yet; coming soon! }\\
\quad\\
{\small Check details @ http://github.com/test-load-balancer/set-part }
\end{center}
\end{frame}
\begin{frame}{Keep children when..}{fitness function}
\begin{center}
The new generation
\begin{alignat}{2}
A_x' =x_1...x_{i} + y_j...y_{j + \delta'} + x_{j+\delta+1}...x_n\\
A_y' =y_1...y_{j} + x_i...x_{i + \delta} + y_{j+\delta'+1}...y_m
\end{alignat}
Can be considered better than parents $$A_x\quad and\quad A_y\quad iff:$$
\begin{alignat}{2}
SD(A_x,A_y) > SD(A_x', A_y')
\begin{cases}
\bar{A} = \frac{\sum_{i=1}^XU_{x_i}}{k}\quad :\quad k = no.\quad of\quad bags
\end{cases}
\end{alignat}
This is just one way to mesure the evolution of the new generation.\\
\end{center}
\end{frame}
\begin{frame}{Random numbers}{0 < n < 10000; 10 generations}
\begin{centering}
\pgfimage[width=11cm]{images/under-10000-random-nos-10.png}
\end{centering}
\end{frame}
\begin{frame}{Random numbers}{0 < n < 10000; 100 generations}
\begin{centering}
\pgfimage[width=11cm]{images/under-10000-random-nos-100.png}
\end{centering}
\end{frame}
\begin{frame}{Random numbers}{0 < n < 10000; 1000 generations}
\begin{centering}
\pgfimage[width=11cm]{images/under-10000-random-nos-1000.png}
\end{centering}
\end{frame}
\begin{frame}{Random numbers}{0 < n < 10000; 10000 generations}
\begin{centering}
\pgfimage[width=11cm]{images/under-10000-random-nos-10000.png}
\end{centering}
\end{frame}
\begin{frame}{Band distribution of numbers}{0 < 60\%X'es < 20\%; 60\% < 20\%X'es < 80\%; 80\% < 20\%X'es; 10000 generations}
\begin{centering}
\pgfimage[width=11cm]{images/band-nos-10000-iter.png}
\end{centering}
\end{frame}
\section*{Thank you}
\begin{frame}{Thank you}
\begin{centering}
{\huge We are patch hungry*.\\Please Contribute.\\}
(its BSD 2 clause)\\
\quad\\
{\huge Thank you.}\\
\quad\\
References:\\
http://test-load-balancer.github.com
\quad\\
http://goo.gl/39t20 [{\color{blue}TLB how to} YouTube playlist]\\
\quad\\
* http://code.google.com/p/tlb/issues/list\\
\end{centering}
\end{frame}
\end{document}