Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache all uploads and downloads to GCS #639

Merged

Conversation

Kurt-Bonatz
Copy link
Contributor

@Kurt-Bonatz Kurt-Bonatz commented Feb 12, 2020

Currently, when using local apk artifacts, Flank always uploads every
app/test apk pair even if the app apk has already been uploaded. This is
also true for pulling the old JUnitReport from GCS for smart flank where
every test apk re-downloads the results. To fix this we simply cache
uploads and downloads in a ConcurrentHashMap where the key is the GCS
path for downloads and the filename for uploads.

This change also fixes a bug where local test apks would be uploaded and
then re-downloaded to parse their tests. The sharding loop now loops over
the local AppTestPair where it uploads them if necessary and scans for
tests on the local test apk.

All in all this shaves almost 4 minutes off of shard generation for a
project with 20+ modules. There is also likely more work that can be
done to parallelize matrix creation (uploading apks, parsing tests,
creating the shard), but it is out of scope of this change.

Matrix/shard generation output (truncated and sanitized)
Before (60s smart flank shard time):

      additional-app-test-apks:
        - app: output/app.apk
          test: output/app1-dev-debug-androidTest.apk
        - app: output/app.apk
          test: output/app2-dev-debug-androidTest.apk
        - app: output/app.apk
          test: output/app3-dev-debug-androidTest.apk
        ...
        - app: output/app.apk
          test: output/app19-dev-debug-androidTest.apk
        - app: output/app.apk
          test: output/app20-dev-debug-androidTest.apk
RunTests
  Uploading app.apk .  Uploading app-dev-debug-androidTest.apk .

  Uploading app.apk .  Uploading app1-dev-debug-androidTest.apk .

  Uploading app.apk .  Uploading app2-dev-debug-androidTest.apk .

  Uploading app.apk .  Uploading app3-dev-debug-androidTest.apk .

  ...

  Uploading app.apk .  Uploading app19-dev-debug-androidTest.apk .

  Uploading app.apk .  Uploading app20-dev-debug-androidTest.apk


  Smart Flank cache hit: 81% (29 / 36)
  Shard times: 31s, 40s

  ...

  2593 tests / 153 shards

  153 matrix ids created in 6m 12s

After (45s smart flank shard time hence more shards):

      additional-app-test-apks:
        - app: output/app.apk
          test: output/app1-dev-debug-androidTest.apk
        - app: output/app.apk
          test: output/app2-dev-debug-androidTest.apk
        - app: output/app.apk
          test: output/app3-dev-debug-androidTest.apk
        ...
        - app: output/app.apk
          test: output/app19-dev-debug-androidTest.apk
        - app: output/app.apk
          test: output/app20-dev-debug-androidTest.apk
RunTests
  Uploading app.apk .  Uploading app-dev-debug-androidTest.apk .


  Smart Flank cache hit: 81% (29 / 36)
  Shard times: 30s, 40s

  Uploading app1-dev-debug-androidTest.apk .

  Smart Flank cache hit: 84% (21 / 25)
  Shard times: 40s, 40s, 40s, 41s

  Uploading app2-dev-debug-androidTest.apk .

  Smart Flank cache hit: 100% (197 / 197)
  Shard times: 41s, 41s, 41s, 41s, 41s, 41s, 41s, 41s

  Uploading app3-dev-debug-androidTest.apk .

  Smart Flank cache hit: 100% (7 / 7)
  Shard times: 12s

  ...

  Smart Flank cache hit: 100% (7 / 7)
  Shard times: 2s

  Uploading app20-dev-debug-androidTest.apk .

  Smart Flank cache hit: 67% (2 / 3)
  Shard times: 11s

  2594 tests / 206 shards

  206 matrix ids created in 2m 25s

Currently, when using local apk artifacts, Flank always uploads every
app/test apk pair even if the app apk has already been uploaded. This is
also true for pulling the old JUnitReport from GCS for smart flank where
every test apk re-downloads the results. To fix this we simply cache
uploads and downloads in a ConcurrentHashMap where the key is the GCS
path for downloads and the filename for uploads.

This change also fixes a bug where local test apks would be uploaded and
then re-downloaded parse their tests. The sharding loop now loops over
the local AppTestPair where it uploads them if necessary and scans for
tests on the local test apk.

All in all this shaves almost 4 minutes off of shard generation for a
project with 20+ modules. There is also likely more work that can be
done to parallelize matrix creation (uploading apks, parsing tests,
creating the shard), but it is out of scope of this change.
@bootstraponline
Copy link
Contributor

This PR is awesome! Thanks for contributing.

Kurt-Bonatz and others added 2 commits February 21, 2020 11:51
Make sure that when an exception is ignored, we still close our file
system resources (ReadChannel/FileOutputStream). Also rename some
variables and methods to better describe what they are and how they are
used.
@bootstraponline bootstraponline merged commit c021274 into Flank:master Feb 26, 2020
@bootstraponline
Copy link
Contributor

Merged! Thanks for your contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants