blob: 87c783e127d71736977ccb5993d2ebb869d9a0c8 [file] [log] [blame] [view]
olaolaa5e36ee2018-06-15 08:16:44 -07001# Execution Log Parser
2
Googler2d60e012024-10-01 01:52:32 -07003This tool is used to inspect and parse the Bazel execution logs. Currently
4supported formats are `binary`, `json`, and `compact`.
5
olaolaa5e36ee2018-06-15 08:16:44 -07006To generate the execution log, run e.g.:
7
8 bazel build \
Googler2d60e012024-10-01 01:52:32 -07009 --execution_log_compact_file=/tmp/exec.log :hello_world
olaolaa5e36ee2018-06-15 08:16:44 -070010
Googler2d60e012024-10-01 01:52:32 -070011Then build the parser and run it:
olaolaa5e36ee2018-06-15 08:16:44 -070012
Googlerb93f4b82024-02-02 07:40:04 -080013 bazel build src/tools/execlog:parser
olaolaa5e36ee2018-06-15 08:16:44 -070014 bazel-bin/src/tools/execlog/parser --log_path=/tmp/exec.log
15
16This will simply print the log contents to stdout in text form.
Googler943c17b2018-08-20 09:45:53 -070017
18To output results to a file, use `--output_path`:
19
20 bazel-bin/src/tools/execlog/parser --log_path=/tmp/exec.log \
21 --output_path=/tmp/exec.log.txt
22
23To limit the output to a certain runner, use `--restrict_to_runner` option.
24For example,
25
26 bazel-bin/src/tools/execlog/parser --log_path=/tmp/exec.log \
27 --restrict_to_runner="linux-sandbox"
28
29Will limit the output to those actions that were ran in the linux sandbox.
30
31
32Note that because Bazel is nondeterministic, different runs of the same build
33may produce logs where actions are in a different order. To achieve a more
34meaningful textual diff, use the parser to convert both files at the same time:
35
36 bazel-bin/src/tools/execlog/parser --log_path=/tmp/exec1.log \
37 --log_path=/tmp/exec2.log \
38 --output_path=/tmp/exec1.log.txt \
39 --output_path=/tmp/exec2.log.txt
40
41This will convert `/tmp/exec1.log` to text as-is, but will reorder `/tmp/exec2.log`
42to match the order of actions found in `/tmp/exec1.log`. Actions are matched if
43their first output is the same. Actions that are not found in `/tmp/exec1.log`
44are put at the end of `/tmp/exec2.log.txt`.
45
46Note that this reordering makes it easier to see differences using text-based
47diffing tools, but may break the logical sequence of actions in
48`/tmp/exec2.log.txt`.
Googlerb93f4b82024-02-02 07:40:04 -080049
50# Execution Log Converter
51
52This tool is used to convert between Bazel execution log formats.
Googlerd8c606c2024-06-21 06:29:42 -070053Currently supported formats are `binary`, `json`, and `compact`.
Googlerb93f4b82024-02-02 07:40:04 -080054
55For example, to convert from the binary format to the JSON format:
56
57 bazel build src/tools/execlog:converter
58 bazel-bin/src/tools/execlog/converter \
59 --input binary:/tmp/binary.log --output json:/tmp/json.log
60
61By default, the output will be in the same order as the input. To sort in a
Googlerd8c606c2024-06-21 06:29:42 -070062deterministic order, use `--sort`.
63
64For large log files, you might need to increase the JVM heap size. To do so,
65pass a corresponding `--jvm_flag`, for example `--jvm_flag=-Xmx4g` for 4GB of heap.
66