xref: /aosp_15_r20/test/dittosuite/README.md (revision 6fa2df46f119dce7527f5beb2814eca0e6f886ac)
1*6fa2df46SAndroid Build Coastguard Worker# Dittosuite
2*6fa2df46SAndroid Build Coastguard Worker
3*6fa2df46SAndroid Build Coastguard WorkerDittosuite is a collection of tools that simplifies writing and running complex
4*6fa2df46SAndroid Build Coastguard Workerworkloads.
5*6fa2df46SAndroid Build Coastguard Worker
6*6fa2df46SAndroid Build Coastguard WorkerThese workloads are defined by a set of instructions including, but not limited
7*6fa2df46SAndroid Build Coastguard Workerto, CPU load, memory allocations, file system operations, Binder IPC, that can
8*6fa2df46SAndroid Build Coastguard Workerbe combined to run sequentially or in parallel.
9*6fa2df46SAndroid Build Coastguard Worker
10*6fa2df46SAndroid Build Coastguard WorkerA new high-level language, Dittolang, defines the workload in the form of a
11*6fa2df46SAndroid Build Coastguard Workertextual representation of Protocol Buffers (aka .ditto files).
12*6fa2df46SAndroid Build Coastguard Worker
13*6fa2df46SAndroid Build Coastguard WorkerThe operations defined in the .ditto files are interpreted and executed by
14*6fa2df46SAndroid Build Coastguard WorkerDittobench on the target device.
15*6fa2df46SAndroid Build Coastguard Worker
16*6fa2df46SAndroid Build Coastguard Worker## Benchmarking
17*6fa2df46SAndroid Build Coastguard Worker
18*6fa2df46SAndroid Build Coastguard WorkerDuring the Dittobench execution of the instructions defined in the .ditto file,
19*6fa2df46SAndroid Build Coastguard Workerthe tool tracks performance metrics such as execution time and I/O bandwidth
20*6fa2df46SAndroid Build Coastguard Worker(more in the [Sampling](#sampling) section).
21*6fa2df46SAndroid Build Coastguard Worker
22*6fa2df46SAndroid Build Coastguard Worker# Doxygen documentation
23*6fa2df46SAndroid Build Coastguard Worker
24*6fa2df46SAndroid Build Coastguard WorkerIn addition to this readme, the project includes a Doxygen configuration, which
25*6fa2df46SAndroid Build Coastguard Workercan be generated with the following command:
26*6fa2df46SAndroid Build Coastguard Worker
27*6fa2df46SAndroid Build Coastguard Worker```
28*6fa2df46SAndroid Build Coastguard Worker$ doxygen
29*6fa2df46SAndroid Build Coastguard Worker```
30*6fa2df46SAndroid Build Coastguard Worker
31*6fa2df46SAndroid Build Coastguard Worker# How to run
32*6fa2df46SAndroid Build Coastguard Worker
33*6fa2df46SAndroid Build Coastguard Worker```
34*6fa2df46SAndroid Build Coastguard Worker$ ./dittobench [options] [.ditto file]
35*6fa2df46SAndroid Build Coastguard Worker```
36*6fa2df46SAndroid Build Coastguard Worker
37*6fa2df46SAndroid Build Coastguard WorkerTo run a benchmark, a well formed .ditto file must be provided, see section
38*6fa2df46SAndroid Build Coastguard Worker[How to write .ditto files](#writing-ditto-files)
39*6fa2df46SAndroid Build Coastguard WorkerIn addition, these options can be set:
40*6fa2df46SAndroid Build Coastguard Worker
41*6fa2df46SAndroid Build Coastguard Worker- `--results-output=<string>` (default: report). Select the results output
42*6fa2df46SAndroid Build Coastguard Worker  format. Options: report, csv.
43*6fa2df46SAndroid Build Coastguard Worker- `--log-stream=<string>` (default: stdout). Select the output stream for
44*6fa2df46SAndroid Build Coastguard Worker  the log messages. Options: stdout, logcat.
45*6fa2df46SAndroid Build Coastguard Worker- `--log-level=<string>` (default: INFO). Select to output messages which are
46*6fa2df46SAndroid Build Coastguard Worker  at or below the set level. Options: VERBOSE, DEBUG, INFO , WARNING, ERROR,
47*6fa2df46SAndroid Build Coastguard Worker  FATAL.
48*6fa2df46SAndroid Build Coastguard Worker- `--parameters=string`. If the benchmark takes parameters, they can be passed
49*6fa2df46SAndroid Build Coastguard Worker  through this option, separated by commas.
50*6fa2df46SAndroid Build Coastguard Worker
51*6fa2df46SAndroid Build Coastguard Worker# Writing .ditto files {#writing-ditto-files}
52*6fa2df46SAndroid Build Coastguard Worker
53*6fa2df46SAndroid Build Coastguard Worker## Sections
54*6fa2df46SAndroid Build Coastguard Worker
55*6fa2df46SAndroid Build Coastguard WorkerEvery .ditto file should begin with this skeleton:
56*6fa2df46SAndroid Build Coastguard Worker
57*6fa2df46SAndroid Build Coastguard Worker```
58*6fa2df46SAndroid Build Coastguard Workermain: {},
59*6fa2df46SAndroid Build Coastguard Workerglobal {}
60*6fa2df46SAndroid Build Coastguard Worker```
61*6fa2df46SAndroid Build Coastguard Worker
62*6fa2df46SAndroid Build Coastguard WorkerOptionally, it can contain `init` and `clean_up` sections:
63*6fa2df46SAndroid Build Coastguard Worker
64*6fa2df46SAndroid Build Coastguard Worker```
65*6fa2df46SAndroid Build Coastguard Workermain: {},
66*6fa2df46SAndroid Build Coastguard Workerinit: {},
67*6fa2df46SAndroid Build Coastguard Workerclean_up: {},
68*6fa2df46SAndroid Build Coastguard Workerglobal {}
69*6fa2df46SAndroid Build Coastguard Worker```
70*6fa2df46SAndroid Build Coastguard Worker
71*6fa2df46SAndroid Build Coastguard Worker### `global`
72*6fa2df46SAndroid Build Coastguard Worker
73*6fa2df46SAndroid Build Coastguard WorkerThe `global` section contains general benchmark parameters.
74*6fa2df46SAndroid Build Coastguard WorkerAvailable options:
75*6fa2df46SAndroid Build Coastguard Worker
76*6fa2df46SAndroid Build Coastguard Worker- (optional) `string absolute_path` (`default = ""`). Specifies the absolute
77*6fa2df46SAndroid Build Coastguard Worker  path for files created by benchmarks. This parameter simplifies the
78*6fa2df46SAndroid Build Coastguard Worker  definition of paths among different file system `Instruction`s, for example,
79*6fa2df46SAndroid Build Coastguard Worker  when different benchmarks should be run in different paths with different
80*6fa2df46SAndroid Build Coastguard Worker  file systems.
81*6fa2df46SAndroid Build Coastguard Worker
82*6fa2df46SAndroid Build Coastguard Worker### `main`
83*6fa2df46SAndroid Build Coastguard Worker
84*6fa2df46SAndroid Build Coastguard Worker`main` is the entry point for the benchmark.
85*6fa2df46SAndroid Build Coastguard Worker
86*6fa2df46SAndroid Build Coastguard WorkerIt contains a single `instruction`.
87*6fa2df46SAndroid Build Coastguard Worker
88*6fa2df46SAndroid Build Coastguard WorkerHaving a single instruction does not mean that the tool is limited to one
89*6fa2df46SAndroid Build Coastguard Workerinstruction. In fact, as will be explained later, multiple instances of the
90*6fa2df46SAndroid Build Coastguard Workersame instruction can be executed with the parameter `repeat`, or a series of
91*6fa2df46SAndroid Build Coastguard Workerdifferent instructions can be execute using the special instruction
92*6fa2df46SAndroid Build Coastguard Worker`instruction_set`.
93*6fa2df46SAndroid Build Coastguard Worker
94*6fa2df46SAndroid Build Coastguard Worker### `init` (optional)
95*6fa2df46SAndroid Build Coastguard Worker
96*6fa2df46SAndroid Build Coastguard Worker`init` initializes the benchmarking environment.
97*6fa2df46SAndroid Build Coastguard Worker
98*6fa2df46SAndroid Build Coastguard WorkerIt executes instructions similar to `main`, but the results are not collected
99*6fa2df46SAndroid Build Coastguard Workerat the end of the execution.
100*6fa2df46SAndroid Build Coastguard Worker
101*6fa2df46SAndroid Build Coastguard Worker### `clean_up` (optional)
102*6fa2df46SAndroid Build Coastguard Worker
103*6fa2df46SAndroid Build Coastguard Worker`clean_up` is optional and can be used to reset the benchmarking environment to
104*6fa2df46SAndroid Build Coastguard Workerthe initial state, e.g, delete benchmark files. Similar to `init`, it executes
105*6fa2df46SAndroid Build Coastguard Workerinstructions like `main`, but results are not collected in the end.
106*6fa2df46SAndroid Build Coastguard Worker
107*6fa2df46SAndroid Build Coastguard Worker## Instructions
108*6fa2df46SAndroid Build Coastguard Worker
109*6fa2df46SAndroid Build Coastguard WorkerEvery workload is composed of one or more instructions.
110*6fa2df46SAndroid Build Coastguard Worker
111*6fa2df46SAndroid Build Coastguard WorkerAlmost everything in Ditto `main` itself is an instruction!
112*6fa2df46SAndroid Build Coastguard Worker
113*6fa2df46SAndroid Build Coastguard WorkerHere is an example of a .ditto file.
114*6fa2df46SAndroid Build Coastguard Worker
115*6fa2df46SAndroid Build Coastguard Worker```
116*6fa2df46SAndroid Build Coastguard Workermain: {
117*6fa2df46SAndroid Build Coastguard Worker  instruction_set: {
118*6fa2df46SAndroid Build Coastguard Worker    instructions: [
119*6fa2df46SAndroid Build Coastguard Worker      {
120*6fa2df46SAndroid Build Coastguard Worker        open_file: {
121*6fa2df46SAndroid Build Coastguard Worker          path_name: "newfile2.txt",
122*6fa2df46SAndroid Build Coastguard Worker          output_fd: "test_file"
123*6fa2df46SAndroid Build Coastguard Worker        }
124*6fa2df46SAndroid Build Coastguard Worker      },
125*6fa2df46SAndroid Build Coastguard Worker      {
126*6fa2df46SAndroid Build Coastguard Worker        close_file: {
127*6fa2df46SAndroid Build Coastguard Worker          input_fd: "test_file"
128*6fa2df46SAndroid Build Coastguard Worker        }
129*6fa2df46SAndroid Build Coastguard Worker      }
130*6fa2df46SAndroid Build Coastguard Worker    ]
131*6fa2df46SAndroid Build Coastguard Worker  },
132*6fa2df46SAndroid Build Coastguard Worker  repeat: 10
133*6fa2df46SAndroid Build Coastguard Worker},
134*6fa2df46SAndroid Build Coastguard Workerglobal {
135*6fa2df46SAndroid Build Coastguard Worker  absolute_path: "/data/local/tmp/";
136*6fa2df46SAndroid Build Coastguard Worker}
137*6fa2df46SAndroid Build Coastguard Worker```
138*6fa2df46SAndroid Build Coastguard Worker
139*6fa2df46SAndroid Build Coastguard WorkerSee more examples in `example/`.
140*6fa2df46SAndroid Build Coastguard Worker
141*6fa2df46SAndroid Build Coastguard Worker### `instruction`
142*6fa2df46SAndroid Build Coastguard Worker
143*6fa2df46SAndroid Build Coastguard Worker```
144*6fa2df46SAndroid Build Coastguard Worker{
145*6fa2df46SAndroid Build Coastguard Worker  <name of the instruction>: {
146*6fa2df46SAndroid Build Coastguard Worker    <first argument>,
147*6fa2df46SAndroid Build Coastguard Worker    <second argument>,
148*6fa2df46SAndroid Build Coastguard Worker    ...
149*6fa2df46SAndroid Build Coastguard Worker  },
150*6fa2df46SAndroid Build Coastguard Worker  <general instruction options>
151*6fa2df46SAndroid Build Coastguard Worker}
152*6fa2df46SAndroid Build Coastguard Worker```
153*6fa2df46SAndroid Build Coastguard Worker
154*6fa2df46SAndroid Build Coastguard WorkerCurrently available options:
155*6fa2df46SAndroid Build Coastguard Worker
156*6fa2df46SAndroid Build Coastguard Worker- (optional) `int repeat` (`default = 1`). Specifies how many times the
157*6fa2df46SAndroid Build Coastguard Worker  instruction should be repeated.
158*6fa2df46SAndroid Build Coastguard Worker
159*6fa2df46SAndroid Build Coastguard Worker### `instruction_set`
160*6fa2df46SAndroid Build Coastguard Worker
161*6fa2df46SAndroid Build Coastguard Worker```
162*6fa2df46SAndroid Build Coastguard Worker{
163*6fa2df46SAndroid Build Coastguard Worker  instruction_set: {
164*6fa2df46SAndroid Build Coastguard Worker    instructions: {
165*6fa2df46SAndroid Build Coastguard Worker      {
166*6fa2df46SAndroid Build Coastguard Worker        <name of the first instruction>: {
167*6fa2df46SAndroid Build Coastguard Worker          <first argument>,
168*6fa2df46SAndroid Build Coastguard Worker          <second argument>,
169*6fa2df46SAndroid Build Coastguard Worker          ...
170*6fa2df46SAndroid Build Coastguard Worker        },
171*6fa2df46SAndroid Build Coastguard Worker        <general instruction options>
172*6fa2df46SAndroid Build Coastguard Worker      },
173*6fa2df46SAndroid Build Coastguard Worker      {
174*6fa2df46SAndroid Build Coastguard Worker        <name of the second instruction>: {
175*6fa2df46SAndroid Build Coastguard Worker          <first argument>,
176*6fa2df46SAndroid Build Coastguard Worker          <second argument>,
177*6fa2df46SAndroid Build Coastguard Worker          ...
178*6fa2df46SAndroid Build Coastguard Worker        },
179*6fa2df46SAndroid Build Coastguard Worker        <general instruction options>
180*6fa2df46SAndroid Build Coastguard Worker      },
181*6fa2df46SAndroid Build Coastguard Worker      ...
182*6fa2df46SAndroid Build Coastguard Worker    },
183*6fa2df46SAndroid Build Coastguard Worker    iterate_options: {...}
184*6fa2df46SAndroid Build Coastguard Worker  },
185*6fa2df46SAndroid Build Coastguard Worker  <general instruction options>
186*6fa2df46SAndroid Build Coastguard Worker}
187*6fa2df46SAndroid Build Coastguard Worker```
188*6fa2df46SAndroid Build Coastguard Worker
189*6fa2df46SAndroid Build Coastguard WorkerInstruction set is an Instruction container that executes the contained
190*6fa2df46SAndroid Build Coastguard Workerinstructions sequentially.
191*6fa2df46SAndroid Build Coastguard Worker
192*6fa2df46SAndroid Build Coastguard WorkerInstruction set can optionally iterate over a list and execute the provided set
193*6fa2df46SAndroid Build Coastguard Workerof instructions on each item from the list. To use it, `iterate_options` should
194*6fa2df46SAndroid Build Coastguard Workerbe set with these options:
195*6fa2df46SAndroid Build Coastguard Worker
196*6fa2df46SAndroid Build Coastguard Worker- `string list_name` - Shared variable name pointing to a list of values.
197*6fa2df46SAndroid Build Coastguard Worker- `string item_name` - Shared variable name to which a selected value should be
198*6fa2df46SAndroid Build Coastguard Worker  stored.
199*6fa2df46SAndroid Build Coastguard Worker- (optional) `Order order` (`default = SEQUENTIAL`) - Specifies if
200*6fa2df46SAndroid Build Coastguard Worker  the elements of the list should be accessed sequentially or randomly. Options:
201*6fa2df46SAndroid Build Coastguard Worker  `SEQUENTIAL`, `RANDOM`.
202*6fa2df46SAndroid Build Coastguard Worker- (optional) `Reseeding reseeding` (`default = ONCE`) - Specifies how often the
203*6fa2df46SAndroid Build Coastguard Worker  random number generator should be reseeded with the same provided (or
204*6fa2df46SAndroid Build Coastguard Worker  generated) seed.  Options: `ONCE`, `EACH_ROUND_OF_CYCLES`, `EACH_CYCLE`.
205*6fa2df46SAndroid Build Coastguard Worker- (optional) `uint32 seed` - Seed for the random number generator. If the seed
206*6fa2df46SAndroid Build Coastguard Worker  is not provided,
207*6fa2df46SAndroid Build Coastguard Worker  current system time is used as the seed.
208*6fa2df46SAndroid Build Coastguard Worker
209*6fa2df46SAndroid Build Coastguard Worker### `multithreading`
210*6fa2df46SAndroid Build Coastguard Worker
211*6fa2df46SAndroid Build Coastguard Worker```
212*6fa2df46SAndroid Build Coastguard Workermultithreading: {
213*6fa2df46SAndroid Build Coastguard Worker  threads: [
214*6fa2df46SAndroid Build Coastguard Worker    {
215*6fa2df46SAndroid Build Coastguard Worker      instruction: {...},
216*6fa2df46SAndroid Build Coastguard Worker      spawn: <number of threads to spawn with the provided instruction>
217*6fa2df46SAndroid Build Coastguard Worker    },
218*6fa2df46SAndroid Build Coastguard Worker    ...
219*6fa2df46SAndroid Build Coastguard Worker  ]
220*6fa2df46SAndroid Build Coastguard Worker}
221*6fa2df46SAndroid Build Coastguard Worker```
222*6fa2df46SAndroid Build Coastguard Worker
223*6fa2df46SAndroid Build Coastguard WorkerMultithreading is another instruction container that executes the specified
224*6fa2df46SAndroid Build Coastguard Workerinstructions (or instruction sets) in different threads. If the optional
225*6fa2df46SAndroid Build Coastguard Worker`spawn` option for a specific instruction (or instruction set) is provided,
226*6fa2df46SAndroid Build Coastguard Workerthen the provided number of threads will be created for it.
227*6fa2df46SAndroid Build Coastguard Worker
228*6fa2df46SAndroid Build Coastguard WorkerArguments:
229*6fa2df46SAndroid Build Coastguard Worker
230*6fa2df46SAndroid Build Coastguard Worker- `Thread threads`: an array of `Thread`s that will be executed in parallel.
231*6fa2df46SAndroid Build Coastguard Worker  Each `Thread` specifies:
232*6fa2df46SAndroid Build Coastguard Worker  - the `Instruction` to run.
233*6fa2df46SAndroid Build Coastguard Worker  - (optional, default 1) `int32 spawn`: number of threads/processes to be
234*6fa2df46SAndroid Build Coastguard Worker    created for this instruction.
235*6fa2df46SAndroid Build Coastguard Worker  - (optional) `string name`: alias name to be assigned to the thread/process.
236*6fa2df46SAndroid Build Coastguard Worker  - (optional) `SchedAttr sched_attr`: scheduling parameters.
237*6fa2df46SAndroid Build Coastguard Worker  - (optional, default -1) `int64 sched_affinity`: bitmask that defines what
238*6fa2df46SAndroid Build Coastguard Worker    CPUs the thread/process can run on.
239*6fa2df46SAndroid Build Coastguard Worker- (optional, default false) `bool fork`: if true, creates processes, otherwise
240*6fa2df46SAndroid Build Coastguard Worker  creates threads.
241*6fa2df46SAndroid Build Coastguard Worker
242*6fa2df46SAndroid Build Coastguard Worker### `open_file`
243*6fa2df46SAndroid Build Coastguard Worker
244*6fa2df46SAndroid Build Coastguard WorkerOpens the file specified by the given path or by a shared variable name
245*6fa2df46SAndroid Build Coastguard Workerpointing to a file path. If neither of those are provided, a random 9-digit
246*6fa2df46SAndroid Build Coastguard Workername is generated.  Optionally saves the file descriptor which can then be used
247*6fa2df46SAndroid Build Coastguard Workerby subsequent instructions. Also, can optionally create the file if it does not
248*6fa2df46SAndroid Build Coastguard Workeralready exist.
249*6fa2df46SAndroid Build Coastguard Worker
250*6fa2df46SAndroid Build Coastguard WorkerArguments:
251*6fa2df46SAndroid Build Coastguard Worker
252*6fa2df46SAndroid Build Coastguard Worker- (optional) `string path_name` - Specifies the file path.
253*6fa2df46SAndroid Build Coastguard Worker- (OR, optional) `string input` - Shared variable name pointing to a file path.
254*6fa2df46SAndroid Build Coastguard Worker- (optional) `string output_fd` - Shared variable name to which output file
255*6fa2df46SAndroid Build Coastguard Worker  descriptor should be saved.
256*6fa2df46SAndroid Build Coastguard Worker- (optional) `bool create` (`default = true`) - Specifies if the file should be
257*6fa2df46SAndroid Build Coastguard Worker  created if it does not already exist. If the file exists, nothing happens.
258*6fa2df46SAndroid Build Coastguard Worker
259*6fa2df46SAndroid Build Coastguard Worker### `delete_file`
260*6fa2df46SAndroid Build Coastguard Worker
261*6fa2df46SAndroid Build Coastguard WorkerDeletes the file with a file path or a shared variable name pointing to a file
262*6fa2df46SAndroid Build Coastguard Workerpath.  Uses `unlink(2)`.
263*6fa2df46SAndroid Build Coastguard Worker
264*6fa2df46SAndroid Build Coastguard WorkerArguments:
265*6fa2df46SAndroid Build Coastguard Worker
266*6fa2df46SAndroid Build Coastguard Worker- `string path_name` - Specifies the file path.<br/>
267*6fa2df46SAndroid Build Coastguard Worker  OR<br/>
268*6fa2df46SAndroid Build Coastguard Worker  `string input` - Shared variable name pointing to a file path.
269*6fa2df46SAndroid Build Coastguard Worker
270*6fa2df46SAndroid Build Coastguard Worker### `close_file`
271*6fa2df46SAndroid Build Coastguard Worker
272*6fa2df46SAndroid Build Coastguard WorkerCloses the file with the provided file descriptor.
273*6fa2df46SAndroid Build Coastguard WorkerUses `close(2)`.
274*6fa2df46SAndroid Build Coastguard Worker
275*6fa2df46SAndroid Build Coastguard WorkerArguments:
276*6fa2df46SAndroid Build Coastguard Worker
277*6fa2df46SAndroid Build Coastguard Worker- `string input_fd` - Shared variable name pointing to a file descriptor.
278*6fa2df46SAndroid Build Coastguard Worker
279*6fa2df46SAndroid Build Coastguard Worker### `resize_file`
280*6fa2df46SAndroid Build Coastguard Worker
281*6fa2df46SAndroid Build Coastguard WorkerResizes the file with the provided file descriptor and new size.  If the
282*6fa2df46SAndroid Build Coastguard Workerprovided size is greater than the current file size, `fallocate(2)` is used,
283*6fa2df46SAndroid Build Coastguard Workerotherwise `ftruncate(2)` is used.
284*6fa2df46SAndroid Build Coastguard Worker
285*6fa2df46SAndroid Build Coastguard WorkerArguments:
286*6fa2df46SAndroid Build Coastguard Worker
287*6fa2df46SAndroid Build Coastguard Worker- `string input_fd` - Shared variable name pointing to a file descriptor.
288*6fa2df46SAndroid Build Coastguard Worker- `int64 size` - New file size (in bytes).
289*6fa2df46SAndroid Build Coastguard Worker
290*6fa2df46SAndroid Build Coastguard Worker### `resize_file_random`
291*6fa2df46SAndroid Build Coastguard Worker
292*6fa2df46SAndroid Build Coastguard WorkerResizes the file with the provided file descriptor and a range for the new
293*6fa2df46SAndroid Build Coastguard Workersize. The new file size is randomly generated in the provided range and if the
294*6fa2df46SAndroid Build Coastguard Workergenerated size is greater than the current file size, `fallocate(2)` is used,
295*6fa2df46SAndroid Build Coastguard Workerotherwise `ftruncate(2)` is used.
296*6fa2df46SAndroid Build Coastguard Worker
297*6fa2df46SAndroid Build Coastguard WorkerArguments:
298*6fa2df46SAndroid Build Coastguard Worker
299*6fa2df46SAndroid Build Coastguard Worker- `string input_fd` - Shared variable name pointing to a file descriptor.
300*6fa2df46SAndroid Build Coastguard Worker- `int64 min` - Minimum value (in bytes)
301*6fa2df46SAndroid Build Coastguard Worker- `int64 max` - Maximum value (in bytes)
302*6fa2df46SAndroid Build Coastguard Worker- (optional) `uint32 seed` - Seed for the random number generator. If the seed
303*6fa2df46SAndroid Build Coastguard Worker  is not provided, current system time is used as the seed.
304*6fa2df46SAndroid Build Coastguard Worker- (optional) `Reseeding reseeding` (`default = ONCE`). How often the random
305*6fa2df46SAndroid Build Coastguard Worker  number generator should be reseeded with the provided (or generated) seed.
306*6fa2df46SAndroid Build Coastguard Worker  Options: `ONCE`, `EACH_ROUND_OF_CYCLES`, `EACH_CYCLE`.
307*6fa2df46SAndroid Build Coastguard Worker
308*6fa2df46SAndroid Build Coastguard Worker### `write_file`
309*6fa2df46SAndroid Build Coastguard Worker
310*6fa2df46SAndroid Build Coastguard WorkerWrites to file with the provided file descriptor. For `SEQUENTIAL` access, the
311*6fa2df46SAndroid Build Coastguard Workerblocks of data will be written sequentially and if the end of the file is
312*6fa2df46SAndroid Build Coastguard Workerreached, new blocks will start from the beginning of the file. For `RANDOM`
313*6fa2df46SAndroid Build Coastguard Workeraccess, the block offset, to which data should be written, will be randomly
314*6fa2df46SAndroid Build Coastguard Workerchosen with uniform distribution. `10101010` byte is used for the write
315*6fa2df46SAndroid Build Coastguard Workeroperation to fill the memory with alternating ones and zeroes. Uses
316*6fa2df46SAndroid Build Coastguard Worker`pwrite64(2)`.
317*6fa2df46SAndroid Build Coastguard Worker
318*6fa2df46SAndroid Build Coastguard WorkerArguments:
319*6fa2df46SAndroid Build Coastguard Worker
320*6fa2df46SAndroid Build Coastguard Worker- `string input_fd` - Shared variable name pointing to a file descriptor.
321*6fa2df46SAndroid Build Coastguard Worker- (optional) `int64 size` (`default = -1`) - How much data (in bytes) should be
322*6fa2df46SAndroid Build Coastguard Worker  written in total.  If it is set to `-1`, then file size is used.
323*6fa2df46SAndroid Build Coastguard Worker- (optional) `int64 block_size` (`default = 4096`) - How much data (in bytes)
324*6fa2df46SAndroid Build Coastguard Worker  should be written at once. If it is set to `-1`, then file size is used.
325*6fa2df46SAndroid Build Coastguard Worker- (optional) `int64 starting_offset` (`default = 0`) - If `access_order` is set
326*6fa2df46SAndroid Build Coastguard Worker  to `SEQUENTIAL`, then the blocks, to which the data should be written, will
327*6fa2df46SAndroid Build Coastguard Worker  start from this starting offset (in bytes).
328*6fa2df46SAndroid Build Coastguard Worker- (optional) `Order access_order` (`default = SEQUENTIAL`) - Order of the
329*6fa2df46SAndroid Build Coastguard Worker  write. Options: `SEQUENTIAL` and `RANDOM`.
330*6fa2df46SAndroid Build Coastguard Worker- (optional) `uint32 seed` - Seed for the random number generator. If the seed
331*6fa2df46SAndroid Build Coastguard Worker  is not provided, current system time is used as the seed.
332*6fa2df46SAndroid Build Coastguard Worker- (optional) `bool fsync` (`default = false`) - If set, `fsync(2)` will be
333*6fa2df46SAndroid Build Coastguard Worker  called after the execution of all write operations.
334*6fa2df46SAndroid Build Coastguard Worker- (optional) `Reseeding reseeding` (`default = ONCE`) - How often the random
335*6fa2df46SAndroid Build Coastguard Worker  number generator should be reseeded with the provided (or generated) seed.
336*6fa2df46SAndroid Build Coastguard Worker  Options: `ONCE`, `EACH_ROUND_OF_CYCLES`, `EACH_CYCLE`.
337*6fa2df46SAndroid Build Coastguard Worker
338*6fa2df46SAndroid Build Coastguard Worker### `read_file`
339*6fa2df46SAndroid Build Coastguard Worker
340*6fa2df46SAndroid Build Coastguard WorkerReads from file with the provided file descriptor. For `SEQUENTIAL`
341*6fa2df46SAndroid Build Coastguard Workeraccess, the blocks of data will be read sequentially and if the end of
342*6fa2df46SAndroid Build Coastguard Workerthe file is reached, new blocks will start from the beginning of the file. For
343*6fa2df46SAndroid Build Coastguard Worker`RANDOM` access, the block offset, from which data should be read, will
344*6fa2df46SAndroid Build Coastguard Workerbe randomly chosen with uniform distribution. Calls `posix_fadvise(2)` before
345*6fa2df46SAndroid Build Coastguard Workerthe read operations. Uses `pread64(2)`.
346*6fa2df46SAndroid Build Coastguard Worker
347*6fa2df46SAndroid Build Coastguard WorkerArguments:
348*6fa2df46SAndroid Build Coastguard Worker
349*6fa2df46SAndroid Build Coastguard Worker- `string input_fd` - Shared variable name pointing to a file descriptor.
350*6fa2df46SAndroid Build Coastguard Worker- (optional) `int64 size` (`default = -1`) - How much data (in bytes) should be
351*6fa2df46SAndroid Build Coastguard Worker  read in total.  If it is set to `-1`, then file size is used.
352*6fa2df46SAndroid Build Coastguard Worker- (optional) `int64 block_size` (`default = 4096`) - How much data (in bytes)
353*6fa2df46SAndroid Build Coastguard Worker  should be read at once. If it is set to `-1`, then file size is used.
354*6fa2df46SAndroid Build Coastguard Worker- (optional) `int64 starting_offset` (`default = 0`) - If `access_order` is set
355*6fa2df46SAndroid Build Coastguard Worker  to `SEQUENTIAL`, then the blocks, from which the data should be read, will
356*6fa2df46SAndroid Build Coastguard Worker  start from this starting offset (in bytes).
357*6fa2df46SAndroid Build Coastguard Worker- (optional) `Order access_order` (`default = SEQUENTIAL`) - Order of the read.
358*6fa2df46SAndroid Build Coastguard Worker  Options: `SEQUENTIAL` and `RANDOM`.
359*6fa2df46SAndroid Build Coastguard Worker- (optional) `uint32 seed` - Seed for the random number generator. If the seed
360*6fa2df46SAndroid Build Coastguard Worker  is not provided, current system time is used as the seed.
361*6fa2df46SAndroid Build Coastguard Worker- (optional) `ReadFAdvise fadvise` (`default = AUTOMATIC`) - Sets the argument
362*6fa2df46SAndroid Build Coastguard Worker  for the `posix_fadvise(2)` operation. Options: `AUTOMATIC`, `NORMAL`,
363*6fa2df46SAndroid Build Coastguard Worker  `SEQUENTIAL` and `RANDOM`. If `AUTOMATIC` is set, then
364*6fa2df46SAndroid Build Coastguard Worker  `POSIX_FADV_SEQUENTIAL` or `POSIX_FADV_RANDOM` will be used for `SEQUENTIAL`
365*6fa2df46SAndroid Build Coastguard Worker  and `RANDOM` access order respectively.
366*6fa2df46SAndroid Build Coastguard Worker- (optional) `Reseeding reseeding` (`default = ONCE`) - How often the random
367*6fa2df46SAndroid Build Coastguard Worker  number generator should be reseeded with the provided (or generated) seed.
368*6fa2df46SAndroid Build Coastguard Worker  Options: `ONCE`, `EACH_ROUND_OF_CYCLES`, `EACH_CYCLE`.
369*6fa2df46SAndroid Build Coastguard Worker
370*6fa2df46SAndroid Build Coastguard Worker### `read_directory`
371*6fa2df46SAndroid Build Coastguard Worker
372*6fa2df46SAndroid Build Coastguard WorkerReads file names from a directory and stores them as a list in a shared
373*6fa2df46SAndroid Build Coastguard Workervariable. Uses `readdir(3)`.
374*6fa2df46SAndroid Build Coastguard Worker
375*6fa2df46SAndroid Build Coastguard WorkerArguments:
376*6fa2df46SAndroid Build Coastguard Worker
377*6fa2df46SAndroid Build Coastguard Worker- `string directory_name` - Name of the directory
378*6fa2df46SAndroid Build Coastguard Worker- `string output` - Shared variable name to which files names should be saved.
379*6fa2df46SAndroid Build Coastguard Worker
380*6fa2df46SAndroid Build Coastguard Worker### `invalidate_cache`
381*6fa2df46SAndroid Build Coastguard Worker
382*6fa2df46SAndroid Build Coastguard WorkerDrops kernel caches, including dentry, inode and page caches. This is done by
383*6fa2df46SAndroid Build Coastguard Workercalling `sync()` and then writing `3` to `/proc/sys/vm/drop_caches`.
384*6fa2df46SAndroid Build Coastguard Worker
385*6fa2df46SAndroid Build Coastguard Worker# Sampling {#sampling}
386*6fa2df46SAndroid Build Coastguard Worker
387*6fa2df46SAndroid Build Coastguard WorkerTODO
388*6fa2df46SAndroid Build Coastguard Worker
389*6fa2df46SAndroid Build Coastguard Worker# Dependencies
390*6fa2df46SAndroid Build Coastguard Worker
391*6fa2df46SAndroid Build Coastguard Worker## Android
392*6fa2df46SAndroid Build Coastguard Worker
393*6fa2df46SAndroid Build Coastguard WorkerThe project is currently being developed as part of the Android Open Source
394*6fa2df46SAndroid Build Coastguard WorkerProject (AOSP) and is supposed to run out-of-the-box.
395*6fa2df46SAndroid Build Coastguard Worker
396*6fa2df46SAndroid Build Coastguard Worker## Linux
397*6fa2df46SAndroid Build Coastguard Worker
398*6fa2df46SAndroid Build Coastguard WorkerThe following utilities are required to build the project on Linux:
399*6fa2df46SAndroid Build Coastguard Worker
400*6fa2df46SAndroid Build Coastguard Worker```
401*6fa2df46SAndroid Build Coastguard Workersudo apt install cmake protobuf-compiler
402*6fa2df46SAndroid Build Coastguard Worker
403*6fa2df46SAndroid Build Coastguard Worker```
404*6fa2df46SAndroid Build Coastguard Worker
405*6fa2df46SAndroid Build Coastguard Worker# Testing
406*6fa2df46SAndroid Build Coastguard Worker
407*6fa2df46SAndroid Build Coastguard Worker## Linux
408*6fa2df46SAndroid Build Coastguard Worker
409*6fa2df46SAndroid Build Coastguard WorkerA suite of unit tests is provided in the test/ directory.
410*6fa2df46SAndroid Build Coastguard WorkerIn Linux these tests can be run with the following commands:
411*6fa2df46SAndroid Build Coastguard Worker
412*6fa2df46SAndroid Build Coastguard Worker```
413*6fa2df46SAndroid Build Coastguard Workermkdir build
414*6fa2df46SAndroid Build Coastguard Workercd build
415*6fa2df46SAndroid Build Coastguard Workermake
416*6fa2df46SAndroid Build Coastguard Workercd test
417*6fa2df46SAndroid Build Coastguard Workerctest
418*6fa2df46SAndroid Build Coastguard Worker```
419*6fa2df46SAndroid Build Coastguard Worker
420*6fa2df46SAndroid Build Coastguard Worker### Coverage
421*6fa2df46SAndroid Build Coastguard Worker
422*6fa2df46SAndroid Build Coastguard WorkerAs an extension to testing, coverage is not a metric that guarantees good
423*6fa2df46SAndroid Build Coastguard Workerquality testing, but at least shows what is not been tested yet.
424*6fa2df46SAndroid Build Coastguard Worker
425*6fa2df46SAndroid Build Coastguard WorkerOne way of getting coverage data is to rely on `llvm` to build the code with
426*6fa2df46SAndroid Build Coastguard Workerextra flags to generate coverage information, `llvm-cov` to extract coverage
427*6fa2df46SAndroid Build Coastguard Workerdata, and `lcov` to aggregate and export all the coverage information into a
428*6fa2df46SAndroid Build Coastguard Workerhuman-readable format.
429*6fa2df46SAndroid Build Coastguard Worker
430*6fa2df46SAndroid Build Coastguard Worker```
431*6fa2df46SAndroid Build Coastguard Workermkdir build
432*6fa2df46SAndroid Build Coastguard Workercd build
433*6fa2df46SAndroid Build Coastguard WorkerCC=/usr/bin/clang CXX=/usr/bin/clang++ cmake -DCMAKE_BUILD_TYPE=Debug ..
434*6fa2df46SAndroid Build Coastguard Workermake
435*6fa2df46SAndroid Build Coastguard Workerctest --test-dir test
436*6fa2df46SAndroid Build Coastguard Workerlcov -d ./CMakeFiles/ -b . --gcov-tool $PWD/../test/llvm-gcov.sh --capture -o cov.info
437*6fa2df46SAndroid Build Coastguard Workergenhtml cov.info -o coverage_html
438*6fa2df46SAndroid Build Coastguard Worker```
439*6fa2df46SAndroid Build Coastguard Worker
440*6fa2df46SAndroid Build Coastguard Worker> **_NOTE:_**: `lcov` version `2.0-1` has issues such as `geninfo: ERROR: "XXX:
441*6fa2df46SAndroid Build Coastguard Worker> function YYY found on line but no corresponding 'line' coverage data point.
442*6fa2df46SAndroid Build Coastguard Worker> Cannot derive function end line.` This can be solved by downgrading to
443*6fa2df46SAndroid Build Coastguard Worker> version 1.6. The lcov repository already has a binary, so `PATH` can be
444*6fa2df46SAndroid Build Coastguard Worker> updated with its `bin` folder.
445*6fa2df46SAndroid Build Coastguard Worker
446