feat(docs): Add Methodology
[csit.git] / docs / content / methodology / root_cause_analysis / perpatch_performance_tests.md
1 ---
2 bookToc: false
3 title: "Per-patch performance tests"
4 weight: 1
5 ---
6
7 # Per-patch performance tests
8
9 Updated for CSIT git commit id: 72b45cfe662107c8e1bb549df71ba51352a898ee.
10
11 A methodology similar to trending analysis is used for comparing performance
12 before a DUT code change is merged. This can act as a verify job to disallow
13 changes which would decrease performance without a good reason.
14
15 ## Existing jobs
16
17 VPP is the only project currently using such jobs.
18 They are not started automatically, must be triggered on demand.
19 They allow full tag expressions, but some tags are enforced (such as MRR).
20
21 There are jobs available for multiple types of testbeds,
22 based on various processors.
23 Their Gerrit triggers words are of the form "perftest-{node_arch}"
24 where the node_arch combinations currently supported are:
25 2n-clx, 2n-tx2, 2n-zn2, 3n-tsh.
26
27 ## Test selection
28
29 Gerrit trigger line without any additional arguments selects
30 a small set of test cases to run.
31 If additional arguments are added to the Gerrit trigger, they are treated
32 as Robot tag expressions to select tests to run.
33 While very flexible, this method of test selection also allows the user
34 to accidentally select too high number of tests, blocking the testbed for days.
35
36 What follows is a list of explanations and recommendations
37 to help users to select the minimal set of tests cases.
38
39 ### Verify cycles
40
41 When Gerrit schedules multiple jobs to run for the same patch set,
42 it waits until all runs are complete.
43 While it is waiting, it is possible to trigger more jobs
44 (adding runs to the set Gerrit is waiting for), but it is not possible
45 to trigger more runs for the same job, until Gerrit is done waiting.
46 After Gerrit is done waiting, it becames possible to trigger
47 the same job again.
48
49 Example. User triggers one set of tests on 2n-icx and immediately
50 also triggers other set of tests on 3n-icx. Then the user notices
51 2n-icx run end early because of a typo in tag expression.
52 When the user tries to re-trigger 2n-icx (with fixed tag expression),
53 that comment gets ignored by Jenkins.
54 Only when 3n-icx job finishes, the user can trigger 2n-icx.
55
56 ### One comment many jobs
57
58 In the past, the CSIT code which parses for perftest trigger comments
59 was buggy, which lead to bad behavior (as in selection all performance test,
60 because "perftest" is also a robot tag) when user included multiple
61 perftest trigger words in the same comment.
62
63 The worst bugs were fixed since then, but it is still recommended
64 to use just one trigger word per Gerrit comment, just to be safe.
65
66 ### Multiple test cases in run
67
68 While Robot supports OR operator, it does not support parentheses,
69 so the OR operator is not very useful. It is recommended
70 to use space instead of OR operator.
71
72 Example template:
73 perftest-2n-icx {tag_expression_1} {tag_expression_2}
74
75 See below for more concrete examples.
76
77 ### Suite tags
78
79 Traditionally, CSIT maintains broad Robot tags that can be used to select tests.
80
81 But it is not recommended to use them for test selection,
82 as it is not that easy to determine how many test cases are selected.
83
84 The recommended way is to look into CSIT repository first,
85 and locate a specific suite the user is interested in,
86 and use its suite tag. For example, "ethip4-ip4base" is a suite tag
87 selecting just one suite in CSIT git repository,
88 avoiding all scale, container, and other simialr variants.
89
90 Note that CSIT uses "autogen" code generator,
91 so the robot running in Jenkins has access to more suites
92 than visible just by looking into CSIT git repository,
93 so suite tag is not enough to select even the intended suite,
94 and user still probably wants to narrow down
95 to a single test case within a suite.
96
97 ### Fully specified tag expressions
98
99 Here is one template to select a single test case:
100 {test_type}AND{nic_model}AND{nic_driver}AND{cores}AND{frame_size}AND{suite_tag}
101 where the variables are all lower case (so AND operator stands out).
102
103 Currently only one test type is supported by the performance comparison jobs:
104 "mrr".
105 The nic_driver options depend on nic_model. For Intel cards "drv_avf" (AVF plugin)
106 and "drv_vfio_pci" (DPDK plugin) are popular, for Mellanox "drv_rdma_core".
107 Currently, the performance using "drv_af_xdp" is not reliable enough, so do not use it
108 unless you are specifically testing for AF_XDP.
109
110 The most popular nic_model is "nic_intel-xxv710", but that is not available
111 on all testbed types.
112 It is safe to use "1c" for cores (unless you are suspection multi-core performance
113 is affected differently) and "64b" for frame size ("78b" for ip6
114 and more for dot1q and other encapsulated traffic;
115 "1518b" is popular for ipsec and other payload-bound tests).
116
117 As there are more test cases than CSIT can periodically test,
118 it is possible to encounter an old test case that currently fails.
119 To avoid that, you can look at "job spec" files we use for periodic testing,
120 for example
121 [this one](https://github.com/FDio/csit/blob/master/resources/job_specs/report_iterative/2n-icx/vpp-mrr-00.md).
122
123 ### Shortening triggers
124
125 Advanced users may use the following tricks to avoid writing long trigger comments.
126
127 Robot supports glob matching, which can be used to select multiple suite tags at once.
128
129 Not specifying one of 6 parts of the recommended expression pattern
130 will select all available options. For example not specifying nic_driver
131 for nic_intel-xxv710 will select all 3 applicable drivers.
132 You can use NOT operator to reject some options (e.g. NOTdrv_af_xdp),
133 but beware, with NOT the order matters:
134 tag1ANDtag2NOTtag3 is not the same as tag1NOTtag3ANDtag2,
135 the latter is evaluated as tag1AND(NOT(tag3ANDtag2)).
136
137 Beware when not specifying nic_model. As a precaution,
138 CSIT code will insert the defailt NIC model for the tetsbed used.
139 Example: Specifying drv_rdma_core without specifying nic_model
140 will fail, as the default nic_model is nic_intel-xxv710
141 which does not support RDMA core driver.
142
143 ### Complete example
144
145 A user wants to test a VPP change which may affect load balance whith bonding.
146 Searching tag documentation for "bonding" finds LBOND tag and its variants.
147 Searching CSIT git repository (directory tests/) finds 8 suite files,
148 all suited only for 3-node testbeds.
149 All suites are using vhost, but differ by the forwarding app inside VM
150 (DPDK or VPP), by the forwarding mode of VPP acting as host level vswitch
151 (MAC learning or cross connect), and by the number of DUT1-DUT2 links
152 available (1 or 2).
153
154 As not all NICs and testbeds offer enogh ports for 2 parallel DUT-DUT links,
155 the user looks at
156 [testbed specifications](https://github.com/FDio/csit/tree/master/topologies/available)
157 and finds that only xxv710 NIC on 3n-icx testbed matches the requirements.
158 Quick look into the suites confirm the smallest frame size is 64 bytes
159 (despite DOT1Q robot tag, as the encapsulation does not happen on TG-DUT links).
160 It is ok to use just 1 physical core, as 3n-icx has hyperthreading enabled,
161 so VPP vswitch will use 2 worker threads.
162
163 The user decides the vswitch forwarding mode is not important
164 (so choses cross connect as that has less CPU overhead),
165 but wants to test both NIC drivers (not AF_XDP), both apps in VM,
166 and both 1 and 2 parallel links.
167
168 After shortening, this is the trigger comment fianlly used:
169 perftest-3n-icx mrrANDnic_intel-x710AND1cAND64bAND?lbvpplacp-dot1q-l2xcbase-eth-2vhostvr1024-1vm*NOTdrv_af_xdp
170
171 ## Basic operation
172
173 The job builds VPP .deb packages for both the patch under test
174 (called "current") and its parent patch (called "parent").
175
176 For each test (from a set defined by tag expression),
177 both builds are subjected to several trial measurements (BMRR).
178 Measured samples are grouped to "parent" sequence,
179 followed by "current" sequence. The same Minimal Description Length
180 algorithm as in trending is used to decide whether it is one big group,
181 or two smaller gropus. If it is one group, a "normal" result
182 is declared for the test. If it is two groups, and current average
183 is less then parent average, the test is declared a regression.
184 If it is two groups and current average is larger or equal,
185 the test is declared a progression.
186
187 The whole job fails (giving -1) if some trial measurement failed,
188 or if any test was declared a regression.
189
190 ## Temporary specifics
191
192 The Minimal Description Length analysis is performed by
193 CSIT code equivalent to jumpavg-0.1.3 library available on PyPI.
194
195 In hopes of strengthening of signal (code performance) compared to noise
196 (all other factors influencing the measured values), several workarounds
197 are applied.
198
199 In contrast to trending, trial duration is set to 10 seconds,
200 and only 5 samples are measured for each build.
201 Both parameters are set in ci-management.
202
203 This decreases sensitivity to regressions, but also decreases
204 probability of false positives.
205
206 ## Console output
207
208 The following information as visible towards the end of Jenkins console output,
209 repeated for each analyzed test.
210
211 The original 5 values are visible in order they were measured.
212 The 5 values after processing are also visible in output,
213 this time sorted by value (so people can see minimum and maximum).
214
215 The next output is difference of averages. It is the current average
216 minus the parent average, expressed as percentage of the parent average.
217
218 The next three outputs contain the jumpavg representation
219 of the two groups and a combined group.
220 Here, "bits" is the description length; for "current" sequence
221 it includes effect from "parent" average value
222 (jumpavg-0.1.3 penalizes sequences with too close averages).
223
224 Next, a sentence describing which grouping description is shorter,
225 and by how much bits.
226 Finally, the test result classification is visible.
227
228 The algorithm does not track test case names,
229 so test cases are indexed (from 0).