[codesize] CodeSize-* CI tasks: Add support for computing binary size diffs w.r.t. tip-of-tree.

Today, CodeSize-<BINARY>-<CONFIG> CI tasks (e.g. CodeSize-dm-Debian10-Clang-x86_64-OptimizeForSize) depend on a single Build-<CONFIG> task (e.g. Build-Debian10-Clang-x86_64-OptimizeForSize), which compiles the <BINARY> (e.g. "dm") at the corresponding changelist/patchset when running as tryjob, or at the corresponding commit when running as a post-submit task:

    Build-<CONFIG>  -->  CodeSize-<BINARY>-<CONFIG>

This CL updates the CodeSize-<BINARY>-<CONFIG> tasks such that they depend on an additional Build-<CONFIG>-NoPatch task (e.g. Build-Debian10-Clang-x86_64-OptimizeForSize-NoPatch), which always compiles the <BINARY> at tip-of-tree:

    Build-<CONFIG>  ----------+
                              |
                              v

                  CodeSize-<BINARY>-<CONFIG>

                              ^
                              |
    Build-<CONFIG>-NoPatch  --+

Then, when running as a tryjob, CodeSize-<BINARY>-<CONFIG> tasks will compute a Bloaty[1] size diff[2] between the <BINARY> compiled at the changelist/patchset and the <BINARY> built at tip-of-tree, and upload the verbatim Bloaty output to the skia-codesize GCS bucket.

When running as a post-submit task, no size diffs are computed, and the <BINARY> produced by the Build-<CONFIG>-NoPatch task is ignored.

Note that the current size profiling behavior of CodeSize-<BINARY>-<CONFIG> tasks is unaffected by this CL.

Implementation details
----------------------

While the Build-<CONFIG> tasks use the "compile" recipe, the new Build-<CONFIG>-NoPatch tasks use the "sync_and_compile" recipe, which provides more control on how the Skia repository checkout is synced prior to compilation.

This CL updates the "sync_and_compile" recipe such that if the task name contains the phrase "NoPatch", then the repository will be synced at tip-of-tree.

Another change to the "sync_and_compile" recipe is that when the task name contains "NoPatch", the Skia checkout and build output paths will match those paths used by the "compile" recipe. This is to prevent spurious deltas between the binaries compiled by Build-<CONFIG> and Build-<CONFIG>-NoPatch tasks. If said paths don't match, then some debug strings in the binaries might be different, for example:

    $ strings build/dm | grep ^\.\./.*dm/DM.*\.cpp$ | sort | head -n 3
    ../../../../../../skia/dm/DM.cpp
    ../../../../../../skia/dm/DMGpuTestProcs.cpp
    ../../../../../../skia/dm/DMJsonWriter.cpp

    $ strings build_nopatch/dm | ^\.\./.*dm/DM.*\.cpp$ | sort | head -3
    ../../../dm/DM.cpp
    ../../../dm/DMGpuTestProcs.cpp
    ../../../dm/DMJsonWriter.cpp

Testing
-------

To check that everything works, on patchset 56 I added a 10,000-byte string to //dm.DM.cpp and ran the CodeSize-dm-Debian10-Clang-x86_64-OptimizeForSize task. This resulted in the following Bloaty size diff:

    $ gsutil cat gs://skia-codesize/2022/07/27/04/tryjob/556358/56/lnwGGlkpXd2obFWx9xrA/Build-Debian10-Clang-x86_64-OptimizeForSize/dm.diff.txt
         VM SIZE                     FILE SIZE
     --------------               --------------
      +0.1% +9.75Ki .rodata       +9.75Ki  +0.1%
      [ = ]       0 .debug_info       +45  +0.0%
      [ = ]       0 .debug_str        +45  +0.0%
      [ = ]       0 .debug_line       +28  +0.0%
      [ = ]       0 .debug_ranges     +16  +0.0%
      +0.0%     +16 .text             +16  +0.0%
      [ = ]       0 [Unmapped]        +10  +200%
      -0.0%      -8 .eh_frame          -8  -0.0%
      +0.0% +9.76Ki TOTAL         +9.90Ki  +0.0%

Note the ~10KB size difference with respect to tip-of-tree.

Then, on patchset 57 I undid that change and re-ran the CodeSize-dm-Debian10-Clang-x86_64-OptimizeForSize task, which resulted in a virtually empty diff:

    $ gsutil cat gs://skia-codesize/2022/07/27/04/tryjob/556358/57/Sxq9YjSxGDTizWUR2B3o/Build-Debian10-Clang-x86_64-OptimizeForSize/dm.diff.txt
         VM SIZE                  FILE SIZE
     --------------            --------------
      [ = ]       0 .debug_str      -8  -0.0%
      [ = ]       0 TOTAL           -8  -0.0%

Note that the file size is 8 bytes smaller, even though I expected them to be identical because nothing changed on patchset 57 with respect to tip-of-tree.

To investigate this spurious delta, I examined both "dm" binaries (compiled at patchset 57 vs. ToT). I noticed small differences in their file size and in the strings they contain. I looked at the gn and ninja command-line invocations used to compile these binaries and saw no differences. I'm not sure what's causing this delta, but given how small it is, it probably doesn't warrant further investigation.

Next steps
----------

Subsequent CLs will change the codesizeserver binary to read the diffs from GCS and display them at https://codesize.skia.org.

[1] https://github.com/google/bloaty
[2] https://github.com/google/bloaty/blob/f01ea59bdda11708d74a3826c23d6e2db6c996f0/doc/using.md#size-diffs

Bug: skia:13535
Change-Id: I051dfdc9b5aa1b4c7a15aa57117506f2dd55c23a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/556358
Reviewed-by: Kevin Lubick <kjlubick@google.com>
9 files changed