From 79832e31478cdb8c513edf24b4612533e83a1d6e Mon Sep 17 00:00:00 2001 From: Adam Dinwoodie Date: Tue, 10 Jan 2023 22:42:36 +0000 Subject: [PATCH] Add cache performance testing This should hopefully show how much of a difference, if any, caching packages makes. There's no automated comparison here, the test just runs one install without a cache, then a second install with a cache, then a human needs to look at what difference it makes. --- .github/workflows/cache-perf.yml | 48 ++++++++++++++++++++++++++++++ .github/workflows/cache-test.yml | 36 ++++++---------------- .github/workflows/clear-caches.yml | 29 ++++++++++++++++++ 3 files changed, 86 insertions(+), 27 deletions(-) create mode 100644 .github/workflows/cache-perf.yml create mode 100644 .github/workflows/clear-caches.yml diff --git a/.github/workflows/cache-perf.yml b/.github/workflows/cache-perf.yml new file mode 100644 index 0000000..2a1d78a --- /dev/null +++ b/.github/workflows/cache-perf.yml @@ -0,0 +1,48 @@ +name: Cache performance testing + +# Only run manually: the purpose of this test is to check how much (if at all) +# using the caches helps, and that's not something that needs doing often, and +# it is something that's time consuming. +on: workflow_dispatch + +# Avoid running at the same time as other actions that interfere with caches, +# to avoid pollution. +concurrency: caches + +jobs: + clear-caches: + uses: ./.github/workflows/clear-caches.yml + permissions: + actions: write + + # There should now be no cache, so we can test how long it takes to do an + # install without a cache while building the cache for the later action. + install-without-cache: + runs-on: windows-latest + needs: clear-caches + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install a large set of Cygwin packages + uses: ./ + with: + packages: > + biber doxygen evolution kde-dev-utils + mkvtoolnix-debuginfo nghttp x11vnc + package-cache: saveonly + + install-with-cache: + runs-on: windows-latest + needs: install-without-cache + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install a large set of Cygwin packages + uses: ./ + with: + packages: > + biber doxygen evolution kde-dev-utils + mkvtoolnix-debuginfo nghttp x11vnc + package-cache: enabled diff --git a/.github/workflows/cache-test.yml b/.github/workflows/cache-test.yml index 99540f2..b162182 100644 --- a/.github/workflows/cache-test.yml +++ b/.github/workflows/cache-test.yml @@ -8,29 +8,9 @@ concurrency: caches jobs: clear-caches: - runs-on: ubuntu-latest + uses: ./.github/workflows/clear-caches.yml permissions: actions: write - steps: - # This will only delete up to 100 caches. That should be far more than - # is ever needed. - - name: Delete cache entries - uses: actions/github-script@v6 - with: - script: | - const response = await github.rest.actions.getActionsCacheList({ - owner: context.repo.owner, - repo: context.repo.repo, - per_page: 100, - key: 'cygwin-install-action-packages-' - }); - for (const cache of response.data.actions_caches) { - await github.rest.actions.deleteActionsCacheById({ - owner: context.repo.owner, - repo: context.repo.repo, - cache_id: cache.id - }); - } test-caching: runs-on: windows-latest @@ -53,6 +33,8 @@ jobs: # saveonly | yes (3) | no (7) # restoreonly | no (4) | yes (8) steps: + - name: Checkout + uses: actions/checkout@v3 - name: Install Cygwin + bash_completion, no caching uses: ./ @@ -78,7 +60,7 @@ jobs: run: | for file in /cygdrive/c/cygwin-packages/*/*/*/*/bash-completion-*.tar.*; do [[ -f "$file" ]] && exit 1 - fi + done - name: Delete the Cygwin installation and downloaded packages run: | @@ -98,7 +80,7 @@ jobs: run: | for file in /cygdrive/c/cygwin-packages/*/*/*/*/brotli-*.tar.*; do [[ -f "$file" ]] && exit 0 - fi + done exit 1 - name: Delete the Cygwin installation and downloaded packages @@ -119,7 +101,7 @@ jobs: run: | for file in /cygdrive/c/cygwin-packages/*/*/*/*/libyajl2-*.tar.*; do [[ -f "$file" ]] && exit 1 - fi + done - name: Delete the Cygwin installation and downloaded packages run: | @@ -139,7 +121,7 @@ jobs: run: | for file in /cygdrive/c/cygwin-packages/*/*/*/*/mksh-*.tar.*; do [[ -f "$file" ]] && exit 1 - fi + done - name: Delete the Cygwin installation and downloaded packages run: | @@ -158,7 +140,7 @@ jobs: run: | for file in /cygdrive/c/cygwin-packages/*/*/*/*/libgif7-*.tar.*; do [[ -f "$file" ]] && exit 1 - fi + done - name: Delete the Cygwin installation and downloaded packages run: | @@ -177,7 +159,7 @@ jobs: run: | for file in /cygdrive/c/cygwin-packages/*/*/*/*/mksh-*.tar.*; do [[ -f "$file" ]] && exit 1 - fi + done - name: Delete the Cygwin installation and downloaded packages run: | diff --git a/.github/workflows/clear-caches.yml b/.github/workflows/clear-caches.yml new file mode 100644 index 0000000..12c2d24 --- /dev/null +++ b/.github/workflows/clear-caches.yml @@ -0,0 +1,29 @@ +name: Clear Cygwin package caches + +on: workflow_call + +jobs: + clear-caches: + runs-on: ubuntu-latest + permissions: + actions: write + steps: + # This will only delete up to 100 caches. That should be far more than + # is ever needed. + - name: Delete cache entries + uses: actions/github-script@v6 + with: + script: | + const response = await github.rest.actions.getActionsCacheList({ + owner: context.repo.owner, + repo: context.repo.repo, + per_page: 100, + key: 'cygwin-install-action-packages-' + }); + for (const cache of response.data.actions_caches) { + await github.rest.actions.deleteActionsCacheById({ + owner: context.repo.owner, + repo: context.repo.repo, + cache_id: cache.id + }); + }