Commit Graph

24 Commits (main)

Author SHA1 Message Date
Fumitoshi Ukai a5519ca872 post_build_ninja_summary: run siso.py instead of siso command
Passing args via siso.bat is problematic.
Invoke 'python3 siso.py' instead.

Bug: 323780528
Change-Id: I991aeab375068d790f9e1f9fd264db9c1003f9dc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6247814
Reviewed-by: Takuto Ikuta <tikuta@chromium.org>
Auto-Submit: Fumitoshi Ukai <ukai@google.com>
Commit-Queue: Fumitoshi Ukai <ukai@google.com>
3 weeks ago
Takuto Ikuta 1d1f17af89 allow v6 ninja log format
This is for https://crrev.com/c/5632535.
v6 in 1.12.1 is the same format with v5 in 1.11.1 actually.
ref: https://github.com/ninja-build/ninja/pull/2240


Bug: 346910589
Change-Id: Id13fc0945d1d7f80b42b87c37969c01ffa113e24
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5633274
Reviewed-by: Junji Watanabe <jwata@google.com>
Commit-Queue: Junji Watanabe <jwata@google.com>
Auto-Submit: Takuto Ikuta <tikuta@chromium.org>
Commit-Queue: Takuto Ikuta <tikuta@chromium.org>
9 months ago
Takuto Ikuta 8efb05d3d4 check `siso summary`
This is to make sure that the command runs as intended and make more
verbose if it has some error.

Bug: b/312632221
Change-Id: I44b372452b37b744f6c02c5a2e34fafe3717e351
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5051585
Commit-Queue: Takuto Ikuta <tikuta@chromium.org>
Auto-Submit: Takuto Ikuta <tikuta@chromium.org>
Reviewed-by: Junji Watanabe <jwata@google.com>
Commit-Queue: Junji Watanabe <jwata@google.com>
1 year ago
Takuto Ikuta df3e577855 apply black and `git cl format` for ninja related python files
This is made by
$ black --line-length 79 *ninja*.py
$ git cl format

Change-Id: Ic446898a5461ae536542f6312cae2ce126dfe82a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5035265
Auto-Submit: Takuto Ikuta <tikuta@chromium.org>
Reviewed-by: Junji Watanabe <jwata@google.com>
Commit-Queue: Takuto Ikuta <tikuta@chromium.org>
Reviewed-by: Philipp Wollermann <philwo@chromium.org>
Reviewed-by: Fumitoshi Ukai <ukai@google.com>
1 year ago
Takuto Ikuta 0b98e7c063 fix for long line warnings
This is preparation CL for https://crrev.com/c/5035265.

Change-Id: I9ab8ffed471d3813a0e94bbdb47bf95e3bb46337
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5036119
Commit-Queue: Philipp Wollermann <philwo@chromium.org>
Reviewed-by: Philipp Wollermann <philwo@chromium.org>
Auto-Submit: Takuto Ikuta <tikuta@chromium.org>
1 year ago
Ho Cheung 9f3b33a275 [py3.12] Use a Raw String in post_build_ninja_summary
depot_tools/post_build_ninja_summary.py:5: SyntaxWarning: invalid
escape sequence '\d'
  """Summarize the last ninja build, invoked with ninja's -C syntax.

Bug: chromium:1487454
Change-Id: I117b94872d65552168c295b4886ccb48a2fd4052
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4986821
Reviewed-by: Bruce Dawson <brucedawson@chromium.org>
Commit-Queue: Ho Cheung <uioptt24@gmail.com>
1 year ago
Junji Watanabe c51829968b [autoninja] Update Siso .ninja_log comments
Siso is going to generate non-empty .ninja_log for the analysis tools.
https://crrev.com/c/4907677

This CL fixes the comment about empty ninja_log.

It's not compatible with Ninja's .ninja_log. So `gn clean` will still
be required.

Bug: b/298594790
Change-Id: Ib4c60f3ed22f516d6f7e2847aaf57e228121eccf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4937692
Auto-Submit: Junji Watanabe <jwata@google.com>
Commit-Queue: Junji Watanabe <jwata@google.com>
Reviewed-by: Takuto Ikuta <tikuta@chromium.org>
1 year ago
Bruce Dawson 8babcb7e2e Automatically run siso metrics summary for siso builds
siso doesn't generate .ninja_log files so post_build_ninja_summary.py
doesn't work, but it _does_ generate siso_metrics.json files which can
be used to generate similar reports to post_build_ninja_summary.py.

Therefore, when a siso_metrics.json file is detected the siso metrics
summary command is invoked, thus preserving (more or less) the old
behavior.

Bug: b/293657720
Change-Id: I084402ca4dca9895b502ab336fa7b45b770f4768
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4854377
Reviewed-by: Junji Watanabe <jwata@google.com>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
1 year ago
Philipp Wollermann c3d210d605 post_build_ninja_summary.py: Gracefully handle empty .ninja_log files
These are currently produced by Siso, until b/298594790 is addressed.

Before:
$ post_build_ninja_summary.py -C out/fastbuild-siso-reclient
Traceback (most recent call last):
  File "/usr/local/google/home/philwo/depot_tools/post_build_ninja_summary.py", line 366, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/google/home/philwo/depot_tools/post_build_ninja_summary.py", line 356, in main
    entries = ReadTargets(log, False)
              ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/google/home/philwo/depot_tools/post_build_ninja_summary.py", line 123, in ReadTargets
    assert header == '# ninja log v5\n', \
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: unrecognized ninja log version ''

After:
$ post_build_ninja_summary.py -C out/fastbuild-siso-reclient
<nothing>

Bug: b/298594790
Fixed: b/297349353
Change-Id: I10d4613e7386707276003fe0fd05cb5b0914be46
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4846349
Reviewed-by: Takuto Ikuta <tikuta@chromium.org>
Auto-Submit: Philipp Wollermann <philwo@google.com>
Reviewed-by: Bruce Dawson <brucedawson@chromium.org>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
2 years ago
Mike Frysinger 124bb8e53c switch to 4 space indent
Leave the recipes/ code at 2 space to match the rest of the recipes
project in other repos.

Reformatted using:
files=( $(
	git ls-tree -r --name-only HEAD | \
		grep -Ev -e '^(third_party|recipes)/' | \
		grep '\.py$';
	git grep -l '#!/usr/bin/env.*python' | grep -v '\.py$'
) )
parallel ./yapf -i -- "${files[@]}"
~/chromiumos/chromite/contrib/reflow_overlong_comments "${files[@]}"

The files that still had strings that were too long were manually
reformatted because they were easy and only a few issues.
autoninja.py
clang_format.py
download_from_google_storage.py
fix_encoding.py
gclient_utils.py
git_cache.py
git_common.py
git_map_branches.py
git_reparent_branch.py
gn.py
my_activity.py
owners_finder.py
presubmit_canned_checks.py
reclient_helper.py
reclientreport.py
roll_dep.py
rustfmt.py
siso.py
split_cl.py
subcommand.py
subprocess2.py
swift_format.py
upload_to_google_storage.py

These files still had lines (strings) that were too long, so the pylint
warnings were suppressed with a TODO.
auth.py
gclient.py
gclient_eval.py
gclient_paths.py
gclient_scm.py
gerrit_util.py
git_cl.py
presubmit_canned_checks.py
presubmit_support.py
scm.py

Change-Id: Ia6535c4f2c48d46b589ec1e791dde6c6b2ea858f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4836379
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
Auto-Submit: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
2 years ago
Bruce Dawson 58da0c8284 Add elapsed-time sorting option to build summary
post_build_ninja_summary.py normally sorts its output by weighted time,
which is elapsed time divided by how many steps are running. Sometimes
it is more appropriate to sort by elapsed (wall clock) time instead.
This adds a -e/--elapsed_time_sorting option to do this.

Change-Id: I13a1b094f8fd7f6795a871bee91932ce0ddab79d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4285697
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
2 years ago
Andrew Grieve 1f51102073 post_build_ninja_summary.py: chmod u+x
Makes it easier to run on linux/mac.

Change-Id: I0ebf512cd576a5c8aafbddc7c6b6f8e2bd6919d9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3971922
Reviewed-by: Bruce Dawson <brucedawson@chromium.org>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
Auto-Submit: Andrew Grieve <agrieve@chromium.org>
2 years ago
Takuto Ikuta 13466d016b autoninja: use pure python3 to get build id and for post_build_ninja_summary.py
This is for comments in
https://crrev.com/c/2629087/11/autoninja
and
https://crrev.com/c/2629087/11/autoninja.bat

Change-Id: I2edafaee7916b7c826af7a7f8f0150a541c8d098
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2631396
Reviewed-by: Bruce Dawson <brucedawson@chromium.org>
Reviewed-by: Fumitoshi Ukai <ukai@google.com>
Reviewed-by: Yoshisato Yanagisawa <yyanagisawa@google.com>
Commit-Queue: Takuto Ikuta <tikuta@chromium.org>
Auto-Submit: Takuto Ikuta <tikuta@chromium.org>
4 years ago
Bruce Dawson 0081a12803 Miscellaneous fixes to post_build_ninja_summary.py
In Python 3 dict.values() is not a sortable type so it must be converted
to a list prior to returning targets data from the ReadTargets function.

In Python 3 you cannot compare arbitrary objects. This could happen when
sorting task_start_stop_times if the time and types were identical. This
is fixed by using the first two entries in the tuple as the sorting key.

When a .ninja_log file is corrupt it triggers a diagnostic message which
has only caused confusion. This changes that message to suggest the most
likely root cause (corruption) since that is the only cause I have seen.

If a build step generates multiple targets with long names then wrapping
of lines may occur. To avoid that the target description size is capped.

Bug: 941669
Change-Id: I2a808d2629a639e231ce2dbf2dab41251110b156
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2432409
Auto-Submit: Bruce Dawson <brucedawson@chromium.org>
Commit-Queue: Dirk Pranke <dpranke@google.com>
Reviewed-by: Dirk Pranke <dpranke@google.com>
4 years ago
Peter Wen e3a42b258e More detailed build-step type summary for android
Increase the number of long times by extension to report from 5 to 10
since java build steps produce a number of different extension types. It
is difficult to distinguish between android vs non-android builds, so
increase this default for all platforms.

Prioritize .jar outputs for java targets and allow up to two levels of
extensions to be recognized.

e.g.
file.interface.jar would have .interface.jar as its full extension.
file.javac.jar would have .javac.jar as its full extension.

Some of these build steps require .jar outputs, which is why these
targets use a secondary extension to differentiate.

Example output: https://crrev.com/c/2142395

Bug: chromium:1067273
Change-Id: Id5780980f60841c3384d91bf96121c6dec3e8bed
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2142163
Reviewed-by: Bruce Dawson <brucedawson@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
Commit-Queue: Peter Wen <wnwen@chromium.org>
Auto-Submit: Peter Wen <wnwen@chromium.org>
5 years ago
Bruce Dawson 34d90bebd8 Allow customizable build-type grouping
The post_build_ninja_summary.py script, which autoninja automatically
runs if NINJA_SUMMARIZE_BUILD=1 is set, summarizes build time by file
extension. This is a good default summary but it can be handy to create
additional output categories. This change allows using fn_match style
wildcards to create additional categories which will then be summarized.
For instance:

  python post_build_ninja_summary.py -C out/Def -s prec*.obj;blink*.obj

In addition the chromium_step_types environment variable can be set so
that when autoninja runs this script there will be additional summary
categories.

This has been used most recently when measuring the cost of creating and
using blink precompiled header files.

Bug: 1061326
Change-Id: I080b4ddd06d045a2351220e202cd9eec111bf00e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2093145
Auto-Submit: Bruce Dawson <brucedawson@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
5 years ago
Bruce Dawson 1eb16f6798 Fix build summary to classify *.mojom*.obj as .obj
The build summary script was overly aggressive about summarizing .mojom
files under the mojo category. This was intended to measure the cost of
generating source from mojo files but it accidentally pulled in the
.mojom object files.

Categorizing different types of object files might be worthwhile but
that should be done intentionally and consistently.

Change-Id: Iab6b7e94797ce7f1ed46805034b4f274c88617e0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2067647
Commit-Queue: Aaron Gable <agable@chromium.org>
Auto-Submit: Bruce Dawson <brucedawson@chromium.org>
Reviewed-by: Aaron Gable <agable@chromium.org>
5 years ago
Edward Lemur 59a3b2fd5d Run autoninja scripts using vpython.
Bug: 1002153
Change-Id: I769a5370d726f4ce478035f59bfd1df50fef452e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1992315
Reviewed-by: Takuto Ikuta <tikuta@chromium.org>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
5 years ago
Bruce Dawson 0e9afd2a56 Change "CPU time" to "elapsed time"
The "CPU time" values printed by post_build_ninja_summary.py are not
actually measure of CPU time, they are measures of wall-clock time or
elapsed time. This just changes the labeling of the numbers - the actual
numbers printed are unchanged.

The "weighted time" number continues to be the more important number
since it is an approximation of how much the build step(s) are affecting
build time. See the comments in the script for details.

Change-Id: Ibdb4efdd327ece34492ab10337c234a826514197
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1900019
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
5 years ago
Raul Tambre 80ee78e7fa Convert print statements to Python 3 style
Ran "2to3 -w -n -f print ./" and manually added imports.
Ran "^\s*print " and "\s+print " to find batch/shell scripts, comments and the like with embedded code, and updated them manually.
Also manually added imports to files, which used print as a function, but were missing the import.

The scripts still work with Python 2.
There are no intended behaviour changes.

Bug: 942522
Change-Id: Id777e4d4df4adcdfdab1b18bde89f235ef491b9f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1595684
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
Commit-Queue: Dirk Pranke <dpranke@chromium.org>
Auto-Submit: Raul Tambre <raul@tambre.ee>
6 years ago
Bruce Dawson 6be8afd57a Improve post_build_ninja_summary.py's incremental build handling
post_build_ninja_summary.py detects a new incremental build by looking
for the end time stamps to go backwards. This means that repeated builds
that have a single long step will not be reliably detected and will, in
some cases, be missed entirely. This hits me sometimes when doing link
testing - delete an output DLL, rebuild, and the old results may be
displayed again.

This change updates the script to check for a different duration for an
existing record as well as an earlier end time should handle almost all
cases.

This also renames the targets local variable to avoid confusion due
to the targets member variable of the Targets class.

Bug: chromium:787983
Change-Id: I60a371df75d6cb7a55bd46b38156cb109feb8f15
Reviewed-on: https://chromium-review.googlesource.com/1061413
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
7 years ago
Daniel Bratell a10370c44b Add --log-file arg to post_build_ninja_summary.py
Sometimes the log files are not named .ninja_log and then it's
good if you can give the script the actual name and path.

Change-Id: I59e9812c81a83ffac3ecdc8b29887e99bf71b60f
Reviewed-on: https://chromium-review.googlesource.com/1012112
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
Reviewed-by: Bruce Dawson <brucedawson@chromium.org>
Commit-Queue: Daniel Bratell <bratell@opera.com>
7 years ago
Bruce Dawson e186e50d0b Update post_build_ninja_summary.py for Linux
post_build_ninja_summary.py gives a summary of a ninja build. It can be
run standalone or it can be run automatically by autoninja. This CL
updates the Python script and the autoninja bash script to make this
work on Linux. This includes removing a zero-value assert, and ensuring
that .so files get categorized as such.

Change-Id: I2d59ab129f5ce70117beeb119719f8432bfbab7c
Reviewed-on: https://chromium-review.googlesource.com/915053
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
7 years ago
Bruce Dawson ffc0c7c691 Script to summarize performance of ninja builds
post_build_ninja_summary.py analyzes the .ninja_log file in an output
directory to summarize build performance. It lists the most expensive
build steps, and build-step types, printing both their elapsed time and,
more importantly, their "weighted" time which is a measure of their
contribution to the total build time.

For each time segment within the build the running build steps
accumulate weighted time that is proportional to the elapsed time
divided by the number of tasks running. If a thousand compilation steps
are running in parallel then they will each be "charged" for 1/1,000th
of the elapsed time. If a single link step is running alone then it is
charged with all of the elapsed time.

Bug: chromium:787983
Change-Id: Id5aea715f798a16415dd0365a27f0051202668e5
Reviewed-on: https://chromium-review.googlesource.com/871988
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
Reviewed-by: Erik Staab <estaab@chromium.org>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
7 years ago