| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- name: 'Show Cache Stats'
- description: 'Displays statistics for ccache and Bazel remote cache to help analyze cache performance and hit rates'
- inputs:
- clear_stats:
- description: 'Whether to clear ccache stats after displaying (default: true)'
- required: true
- type: boolean
- default: true
- runs:
- using: 'composite'
- steps:
- - name: Show ccache Stats
- shell: bash
- working-directory: ${{ github.workspace }}
- run: |
- set -euo pipefail
- echo "===================="
- echo "=== ccache stats ==="
- echo "===================="
- ccache -s || true
- echo "====================="
- echo "=== ccache config ==="
- echo "====================="
- ccache -p || true
- echo "====================="
- if command -v ccache >/dev/null 2>&1; then
- echo "ccache is installed"
- else
- echo "ccache not installed, exiting"
- exit 0
- fi
- STATS="$(ccache -s)"
-
- CACHEABLE=$(echo "$STATS" | awk '/Cacheable calls:/ {
- match($0, /[0-9]+/);
- print substr($0, RSTART, RLENGTH)
- }' | head -n1)
-
- HITS=$(echo "$STATS" | awk '/^[[:space:]]*Hits:/ {
- match($0, /[0-9]+/);
- print substr($0, RSTART, RLENGTH)
- }' | head -n1)
-
- DIRECT=$(echo "$STATS" | awk '/Direct:/ {
- match($0, /[0-9]+/);
- print substr($0, RSTART, RLENGTH)
- }' | head -n1)
-
- if [ "${CACHEABLE:-0}" -gt 0 ]; then
- HIT_RATE=$(awk -v h="${HITS:-0}" -v c="$CACHEABLE" 'BEGIN{printf "%.1f", (h/c)*100}')
- DIRECT_RATE=$(awk -v d="${DIRECT:-0}" -v c="$CACHEABLE" 'BEGIN{printf "%.1f", (d/c)*100}')
- else
- HIT_RATE="0.0"
- DIRECT_RATE="0.0"
- fi
-
- echo "hit_rate=${HIT_RATE}%"
- echo "direct_rate=${DIRECT_RATE}%"
- if [ "${{ inputs.clear_stats }}" = "true" ]; then
- echo "=== ccache reset ==="
- echo "====================="
- ccache -z || true
- echo "====================="
- else
- echo "Keeping ccache stats for next run"
- fi
- - name: Show ccache folder Stats
- shell: bash
- working-directory: ${{ github.workspace }}
- run: |
- set -euo pipefail
- echo "==============="
- echo "=== .ccache ==="
- echo "==============="
- du -sh /home/runner/.ccache || true
- ls -l /home/runner/.ccache || true
- echo "==============="
- - name: Show Bazel Cache folder Stats
- shell: bash
- working-directory: ${{ github.workspace }}
- run: |
- set -euo pipefail
- echo "===================="
- echo "=== .cache/bazel ==="
- echo "===================="
- du -sh /home/runner/.cache/bazel || true
- ls -l /home/runner/.cache/bazel || true
- echo "===================="
-
- - name: Show ld cache folder Stats
- shell: bash
- working-directory: ${{ github.workspace }}
- run: |
- set -euo pipefail
- echo "================="
- echo "=== .ld_cache ==="
- echo "================="
- du -sh /home/runner/.ld_cache || true
- ls -l /home/runner/.ld_cache || true
- echo "================="
-
|