Skip to content

Learn coverage artifact names once per task kind - #3088

Draft
marco-c wants to merge 2 commits into
mozilla:masterfrom
marco-c:skip-artifact-listing
Draft

marco-c wants to merge 2 commits into
mozilla:masterfrom
marco-c:skip-artifact-listing

Conversation

@marco-c

@marco-c marco-c commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

Before downloading the coverage artifacts of a task, the bot lists all of its artifacts (listLatestArtifacts) to find the coverage ones. That is one listing call per downloaded task. On the mozilla-central task group WCCcu_Z9TJuINVImjxA5hA, there are 555 coverage tasks, and 355 remain after download_all picks the best task for each chunk and platform, so that's 355 listing calls per run. The time saved is small, but it roughly halves the number of Taskcluster API requests.

Change

  • Before the download pool starts, ArtifactsHandler.find_artifact_names groups the tasks to download by kind (task["tags"]["kind"], falling back to the task name prefix if the tag is missing). For each kind, it lists the artifacts of the tasks one by one until one has coverage artifacts (same filter as before: names containing code-coverage-grcov.zip / code-coverage-jsvm.zip). It records those full names for the kind and logs them, one info line per kind, so a future naming change shows up in the logs. If no task of a kind has coverage artifacts, the kind gets no names.
  • ArtifactsHandler.download requests the kind's names directly. A 404 means "this task doesn't have this artifact": it is logged and skipped, and no Artifact is recorded. Local paths and Artifact records are the same as before for artifacts that exist. If download is called for a kind whose names are unknown, it learns them from that task.
  • utils.download_file no longer retries on HTTP 404, since retrying won't make the artifact appear and would cost minutes with the 16-64 s exponential waits. Other errors (e.g. 403, 500, bad zip files) are still retried 5 times, as before.
  • The mock_tenacity test fixture now also patches wait_exponential, which download_file uses. Before, retry tests really waited: the bot test suite drops from ~2.5 min to ~30-40 s locally.

Artifact names per kind

I listed the artifacts of all 555 coverage tasks of WCCcu_Z9TJuINVImjxA5hA. All of them have a kind tag, and within each kind every task that has coverage artifacts uses the same names:

Kind Tasks With coverage artifacts Names
web-platform-tests 295 292 public/test_info/code-coverage-grcov.zip, public/test_info/code-coverage-jsvm.zip
mochitest 141 141 same
reftest 59 59 same
test 49 37 same
build 8 4 public/code-coverage-grcov.zip
source-test 2 2 public/code-coverage-grcov.zip
build-signing 1 0 none

The build tasks without coverage artifacts are the fuzzing builds.

The change assumes that tasks of the same kind use the same names. If that stops being true, artifacts with new names would be silently missed, but the per-kind log line shows which names were used.

I ran download_all against this task group with download stubbed out, using the real Taskcluster API. It made 8 listing calls instead of 355. All 8 came from the 7 kinds: build needed 2 because the first build task had no coverage artifacts. The 355 tasks then need 704 direct download requests. Up to a few dozen of those can be 404s, for tasks that have no coverage artifacts at all, and each 404 costs one request.

Tests

  • New tests in bot/tests/test_artifacts.py go through responses. They cover:
    • names learned once per kind, checked by the exact listing calls
    • falling back to the next task when the first task of a kind has no coverage artifacts
    • a kind with no coverage artifacts at all
    • tasks of different kinds with different names, with no listing calls
    • a missing jsvm artifact: the 404 is skipped and requested only once
    • a 500 being retried 5 times and then raised
    • the full path from listing to downloaded files with the real fixtures
  • test_download_all now checks that one listing call is made for the whole group.
  • New tests in bot/tests/test_taskcluster.py: download_artifact on a 404 makes a single request and leaves no file behind, plus tests for get_task_kind.
  • pytest bot/tests/test_artifacts.py bot/tests/test_taskcluster.py bot/tests/test_grcov.py bot/tests/test_reports.py (with grcov v0.10.9) passes. In the full bot test suite, the same tests fail as on master locally, for unrelated reasons (missing hg version / pushlog extension).

This hasn't run on Taskcluster yet.

Download with 16 threads instead of 8

Second commit. On the last mozilla-central run (https://firefox-ci-tc.services.mozilla.com/tasks/bgdiwWLUQzuSAJbshFpQDg/runs/1), with the measurements from #3086: 642 artifacts (53.7 GB) downloaded in 212 s, i.e. 253 MB/s, with 6.9 downloads running at the same time on average out of 8. Each download got ~36 MB/s (median), while the worker sustained ~350 MB/s overall when the Mercurial clone was running in parallel. So the limit is the speed of each download, not the network, and more parallel downloads should be faster. The next run's summary line will tell.

Before downloading the coverage artifacts of a task, the bot listed all
of its artifacts to find the coverage ones, one listing call per task
(355 calls for the 555 coverage tasks of a recent mozilla-central task
group, after picking the best task for each chunk and platform).

The coverage artifact names only depend on the kind of task:
public/test_info/code-coverage-{grcov,jsvm}.zip for test kinds and
public/code-coverage-grcov.zip for build and source-test tasks. So,
before starting the downloads, list the artifacts of tasks of each kind
until one of them has coverage artifacts, log the names found for the
kind, and request those names directly for all the tasks of that kind.
On the same task group, this takes 8 listing calls.

Not all tasks have all artifacts (e.g. when they failed early), so a
404 is treated as the artifact being absent. download_file no longer
retries on 404, as retrying wouldn't make the artifact appear and would
waste minutes; other errors are still retried.

Also make the mock_tenacity fixture patch wait_exponential, which
download_file uses, so that tests exercising retries don't wait.
On the last mozilla-central run, the 642 artifacts (53.7 GB) were
downloaded at 253 MB/s, with 6.9 downloads running at the same time on
average out of 8. Each download only got ~36 MB/s (median), while the
worker sustained ~350 MB/s overall when the Mercurial clone was running
in parallel. So the throughput is limited by the speed of each download
rather than by the network, and more parallel downloads should make the
whole faster.
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.

1 participant