xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/testsuite/gdb.perf/README (revision ed8eb4c2d4cb3dac3dc6123dae57e5931483a099)
1*ed8eb4c2SchristosThe GDB Performance Testsuite
2*ed8eb4c2Schristos=============================
3*ed8eb4c2Schristos
4*ed8eb4c2SchristosThis README contains notes on hacking on GDB's performance testsuite.
5*ed8eb4c2SchristosFor notes on GDB's regular testsuite or how to run the performance testsuite,
6*ed8eb4c2Schristossee ../README.
7*ed8eb4c2Schristos
8*ed8eb4c2SchristosGenerated tests
9*ed8eb4c2Schristos***************
10*ed8eb4c2Schristos
11*ed8eb4c2SchristosThe testcase generator lets us easily test GDB on large programs.
12*ed8eb4c2SchristosThe "monster" tests are mocks of real programs where GDB's
13*ed8eb4c2Schristosperformance has been a problem.  Often it is difficult to build
14*ed8eb4c2Schristosthese monster programs, but when measuring performance one doesn't
15*ed8eb4c2Schristosneed the "real" program, all one needs is something that looks like
16*ed8eb4c2Schristosthe real program along the axis one is measuring; for example, the
17*ed8eb4c2Schristosnumber of CUs (compilation units).
18*ed8eb4c2Schristos
19*ed8eb4c2SchristosStructure of generated tests
20*ed8eb4c2Schristos****************************
21*ed8eb4c2Schristos
22*ed8eb4c2SchristosGenerated tests consist of a binary and potentially any number of
23*ed8eb4c2Schristosshared libraries.  One of these shared libraries, called "tail", is
24*ed8eb4c2Schristosspecial.  It is used to provide mocks of system provided code, and
25*ed8eb4c2Schristoscontains no generated code.  Typically system-provided libraries
26*ed8eb4c2Schristosare searched last which can have significant performance consequences,
27*ed8eb4c2Schristosso we provide a means to exercise that.
28*ed8eb4c2Schristos
29*ed8eb4c2SchristosThe binary and the generated shared libraries can have a mix of
30*ed8eb4c2Schristosmanually written and generated code.  Manually written code is
31*ed8eb4c2Schristosspecified with the {binary,gen_shlib}_extra_sources config parameters,
32*ed8eb4c2Schristoswhich are lists of source files in testsuite/gdb.perf.  Generated
33*ed8eb4c2Schristosfiles are controlled with various configuration knobs.
34*ed8eb4c2Schristos
35*ed8eb4c2SchristosOnce a large test program is built, it makes sense to use it as much
36*ed8eb4c2Schristosas possible (i.e., with multiple tests).  Therefore perf data collection
37*ed8eb4c2Schristosfor generated tests is split into two passes: the first pass builds
38*ed8eb4c2Schristosall the generated tests, and the second pass runs all the performance
39*ed8eb4c2Schristostests.  The first pass is called "build-perf" and the second pass is
40*ed8eb4c2Schristoscalled "check-perf".  See ../README for instructions on running the tests.
41*ed8eb4c2Schristos
42*ed8eb4c2SchristosGenerated test directory layout
43*ed8eb4c2Schristos*******************************
44*ed8eb4c2Schristos
45*ed8eb4c2SchristosAll output lives under testsuite/gdb.perf in the build directory.
46*ed8eb4c2Schristos
47*ed8eb4c2SchristosBecause some of the tests can get really large (and take potentially
48*ed8eb4c2Schristosminutes to compile), parallelism is built into their compilation.
49*ed8eb4c2SchristosNote however that we don't run the tests in parallel as it can skew
50*ed8eb4c2Schristosthe results.
51*ed8eb4c2Schristos
52*ed8eb4c2SchristosTo keep things simple and stay consistent, we use the same
53*ed8eb4c2Schristosmechanism used by "make check-parallel".  There is one catch: we need
54*ed8eb4c2Schristosone .exp for each "worker" but the .exp file must come from the source
55*ed8eb4c2Schristostree.  To avoid generating .exp files for each worker we invoke
56*ed8eb4c2Schristoslib/build-piece.exp for each worker with different arguments.
57*ed8eb4c2SchristosThe file build.piece.exp lives in "lib" to prevent dejagnu from finding
58*ed8eb4c2Schristosit when it goes to look for .exp scripts to run.
59*ed8eb4c2Schristos
60*ed8eb4c2SchristosAnother catch is that each parallel build worker needs its own directory
61*ed8eb4c2Schristosso that their gdb.{log,sum} files don't collide.  On the other hand
62*ed8eb4c2Schristosits easier if their output (all the object files and shared libraries)
63*ed8eb4c2Schristosare in the same directory.
64*ed8eb4c2Schristos
65*ed8eb4c2SchristosThe above considerations yield the resulting layout:
66*ed8eb4c2Schristos
67*ed8eb4c2Schristos$objdir/testsuite/gdb.perf/
68*ed8eb4c2Schristos
69*ed8eb4c2Schristos	gdb.log, gdb.sum: result of doing final link and running tests
70*ed8eb4c2Schristos
71*ed8eb4c2Schristos	workers/
72*ed8eb4c2Schristos
73*ed8eb4c2Schristos		gdb.log, gdb.sum: result of gen-workers step
74*ed8eb4c2Schristos
75*ed8eb4c2Schristos		$program_name/
76*ed8eb4c2Schristos
77*ed8eb4c2Schristos			${program_name}-0.worker
78*ed8eb4c2Schristos			...
79*ed8eb4c2Schristos			${program_name}-N.worker: input to build-pieces step
80*ed8eb4c2Schristos
81*ed8eb4c2Schristos	outputs/
82*ed8eb4c2Schristos
83*ed8eb4c2Schristos		${program_name}/
84*ed8eb4c2Schristos
85*ed8eb4c2Schristos			${program_name}-0/
86*ed8eb4c2Schristos			...
87*ed8eb4c2Schristos			${program_name}-N/
88*ed8eb4c2Schristos
89*ed8eb4c2Schristos				gdb.log, gdb.sum: for each build-piece worker
90*ed8eb4c2Schristos
91*ed8eb4c2Schristos			pieces/
92*ed8eb4c2Schristos
93*ed8eb4c2Schristos				generated sources, object files, shlibs
94*ed8eb4c2Schristos
95*ed8eb4c2Schristos			${run_name_1}: binary for test config #1
96*ed8eb4c2Schristos			...
97*ed8eb4c2Schristos			${run_name_N}: binary for test config #N
98*ed8eb4c2Schristos
99*ed8eb4c2SchristosGenerated test configuration knobs
100*ed8eb4c2Schristos**********************************
101*ed8eb4c2Schristos
102*ed8eb4c2SchristosThe monster program generator provides various knobs for building various
103*ed8eb4c2Schristoskinds of monster programs.  For a list of the knobs see function
104*ed8eb4c2SchristosGenPerfTest::init_testcase in testsuite/lib/perftest.exp.
105*ed8eb4c2SchristosMost knobs are self-explanatory.
106*ed8eb4c2SchristosHere is a description of the less obvious ones.
107*ed8eb4c2Schristos
108*ed8eb4c2Schristosbinary_extra_sources
109*ed8eb4c2Schristos
110*ed8eb4c2Schristos	This is the list of non-machine generated sources that go
111*ed8eb4c2Schristos	into the test binary.  There must be at least one: the one
112*ed8eb4c2Schristos	with main.
113*ed8eb4c2Schristos
114*ed8eb4c2Schristosclass_specs
115*ed8eb4c2Schristos
116*ed8eb4c2Schristos	List of pairs of keys and values.
117*ed8eb4c2Schristos	Supported keys are:
118*ed8eb4c2Schristos	count: number of classes
119*ed8eb4c2Schristos	  Default: 1
120*ed8eb4c2Schristos	name: list of namespaces and class name prefix
121*ed8eb4c2Schristos	  E.g., { ns0 ns1 foo } -> ns0::ns1::foo_<cu#>_{0,1,...}
122*ed8eb4c2Schristos	  There is no default, this value must be specified.
123*ed8eb4c2Schristos	nr_members: number of members
124*ed8eb4c2Schristos	  Default: 0
125*ed8eb4c2Schristos	nr_static_members: number of static members
126*ed8eb4c2Schristos	  Default: 0
127*ed8eb4c2Schristos	nr_methods: number of methods
128*ed8eb4c2Schristos	  Default: 0
129*ed8eb4c2Schristos	nr_inline_methods: number of inline methods
130*ed8eb4c2Schristos	  Default: 0
131*ed8eb4c2Schristos	nr_static_methods: number of static methods
132*ed8eb4c2Schristos	  Default: 0
133*ed8eb4c2Schristos	nr_static_inline_methods: number of static inline methods
134*ed8eb4c2Schristos	  Default: 0
135*ed8eb4c2Schristos
136*ed8eb4c2Schristos	E.g.,
137*ed8eb4c2Schristos	class foo {};
138*ed8eb4c2Schristos	namespace ns1 { class bar {}; }
139*ed8eb4c2Schristos	would be represented as:
140*ed8eb4c2Schristos	{
141*ed8eb4c2Schristos	  { count 1 name { foo } }
142*ed8eb4c2Schristos	  { count 1 name { ns1 bar } }
143*ed8eb4c2Schristos	}
144*ed8eb4c2Schristos
145*ed8eb4c2Schristos	The naming of each class is "class_<cu_nr>_<class_nr>",
146*ed8eb4c2Schristos	where <cu_nr> is the number of the compilation unit the
147*ed8eb4c2Schristos	class is defined in.
148*ed8eb4c2Schristos
149*ed8eb4c2Schristos	There's currently no support for nesting classes in classes,
150*ed8eb4c2Schristos	or for specifying baseclasses or templates.
151*ed8eb4c2Schristos
152*ed8eb4c2SchristosMisc. configuration knobs
153*ed8eb4c2Schristos*************************
154*ed8eb4c2Schristos
155*ed8eb4c2SchristosThese knobs control building or running of the test and are specified
156*ed8eb4c2Schristoslike any global Tcl variable.
157*ed8eb4c2Schristos
158*ed8eb4c2SchristosCAT_PROGRAM
159*ed8eb4c2Schristos
160*ed8eb4c2Schristos	Default is /bin/cat, you shouldn't need to change this.
161*ed8eb4c2Schristos
162*ed8eb4c2SchristosSHA1SUM_PROGRAM
163*ed8eb4c2Schristos
164*ed8eb4c2Schristos	Default is /usr/bin/sha1sum.
165*ed8eb4c2Schristos
166*ed8eb4c2SchristosPERF_TEST_COMPILE_PARALLELISM
167*ed8eb4c2Schristos
168*ed8eb4c2Schristos	An integer, specifies the amount of parallelism in the builds.
169*ed8eb4c2Schristos	Akin to make's -j flag.  The default is 10.
170*ed8eb4c2Schristos
171*ed8eb4c2SchristosWriting a generated test program
172*ed8eb4c2Schristos********************************
173*ed8eb4c2Schristos
174*ed8eb4c2SchristosThe best way to write a generated test program is to take an existing
175*ed8eb4c2Schristosone as boilerplate.  Two good examples are gmonster1.exp and gmonster2.exp.
176*ed8eb4c2Schristosgmonster1.exp builds a big binary with various custom manually written
177*ed8eb4c2Schristoscode, and gmonster2 is (essentially) the equivalent binary split up over
178*ed8eb4c2Schristosseveral shared libraries.
179*ed8eb4c2Schristos
180*ed8eb4c2SchristosWriting a performance test that uses a generated program
181*ed8eb4c2Schristos********************************************************
182*ed8eb4c2Schristos
183*ed8eb4c2SchristosThe best way to write a test is to take an existing one as boilerplate.
184*ed8eb4c2SchristosGood examples are gmonster1-*.exp and gmonster2-*.exp.
185*ed8eb4c2Schristos
186*ed8eb4c2SchristosThe naming used thus far is that "foo.exp" builds the test program
187*ed8eb4c2Schristosand there is one "foo-bar.exp" file for each performance test
188*ed8eb4c2Schristosthat uses test program "foo".
189*ed8eb4c2Schristos
190*ed8eb4c2SchristosIn addition to writing the test driver .exp script, one must also
191*ed8eb4c2Schristoswrite a python script that is used to run the test.
192*ed8eb4c2SchristosThis contents of this script is defined by the performance testsuite
193*ed8eb4c2Schristosharness.  It defines a class, which is a subclass of one of the
194*ed8eb4c2Schristosclasses in gdb.perf/lib/perftest/perftest.py.
195*ed8eb4c2SchristosSee gmonster-null-lookup.py for an example.
196*ed8eb4c2Schristos
197*ed8eb4c2SchristosNote: Since gmonster1 and gmonster2 are treated as being variations of
198*ed8eb4c2Schristosthe same program, each test shares the same python script.
199*ed8eb4c2SchristosE.g., gmonster1-null-lookup.exp and gmonster2-null-lookup.exp
200*ed8eb4c2Schristosboth use gmonster-null-lookup.py.
201*ed8eb4c2Schristos
202*ed8eb4c2SchristosRunning performance tests for generated programs
203*ed8eb4c2Schristos************************************************
204*ed8eb4c2Schristos
205*ed8eb4c2SchristosThere are two steps: build and run.
206*ed8eb4c2Schristos
207*ed8eb4c2SchristosExample:
208*ed8eb4c2Schristos
209*ed8eb4c2Schristosbash$ make -j10 build-perf RUNTESTFLAGS="gmonster1.exp"
210*ed8eb4c2Schristosbash$ make -j10 check-perf RUNTESTFLAGS="gmonster1-null-lookup.exp" \
211*ed8eb4c2Schristos    GDB_PERFTEST_MODE=run
212