summaryrefslogtreecommitdiffstats
path: root/taskcluster/docs/caches.rst
blob: dcda4102dd9ff3148779e7535b74449542f261ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
.. taskcluster_caches:

Caches
======

There are various caches used by the in-tree tasks. This page attempts to
document them and their appropriate use.

Caches are essentially isolated filesystems that are persisted between
tasks. For example, if 2 tasks run on a worker - one after the other -
and both tasks request the same cache, the subsequent task will be
able to see files in the cache that were created by the first task.
It's also worth noting that TaskCluster workers ensure a cache can only
be used by 1 task at a time. If a worker is simultaneously running
multiple tasks requesting the same named cache, the worker will
have multiple caches of the same name on the worker.

Caches and ``run-task``
-----------------------

``run-task`` is our generic task wrapper script. It does common activities
like ensure a version control checkout is present.

One of the roles of ``run-task`` is to verify and sanitize caches.
It does this by storing state in a cache on its first use. If the recorded
*capabilities* of an existing cache don't match expectations for the
current task, ``run-task`` bails. This ensures that caches are only
reused by tasks with similar execution *profiles*. This prevents
accidental cache use across incompatible tasks. It also allows run-task
to make assumptions about the state of caches, which can help avoid
costly operations.

In addition, the hash of ``run-task`` is used to derive the cache name.
So any time ``run-task`` changes, a new set of caches are used. This
ensures that any backwards incompatible changes or bug fixes to
``run-task`` result in fresh caches.

Some caches are reserved for use with run-task. That property will be denoted
below.

Common Caches
-------------

Version Control Caches
::::::::::::::::::::::

``level-{{level}}-checkouts-{{hash}}``
   This cache holds version control checkouts, each in a subdirectory named
   after the repo (e.g., ``gecko``).

   Checkouts should be read-only. If a task needs to create new files from
   content of a checkout, this content should be written in a separate
   directory/cache (like a workspace).

   This cache name pattern is managed by ``run-task`` and must only be
   used with ``run-task``.

``level-{{level}}-checkouts-sparse-{{hash}}``
   This is like the above but is used when the checkout is sparse (contains
   a subset of files).

``level-{{level}}-checkouts-{{version}}`` (deprecated)
   This cache holds version control checkouts, each in a subdirectory named
   after the repo (e.g., ``gecko``).

   Checkouts should be read-only. If a task needs to create new files from
   content of a checkout, this content should be written in a separate
   directory/cache (like a workspace).

   A ``version`` parameter appears in the cache name to allow
   backwards-incompatible changes to the cache's behavior.

   The ``hg-store`` contains a `shared store <https://www.mercurial-scm.org/wiki/ShareExtension>`
   that is is used by ``hg robustcheckout``. If you are using ``run-task`` you
   should set the ``HG_STORE_PATH`` environment variable to point to this
   directory. If you are using ``hg robustcheckout``, pass this directory to the
   ``--sharebase`` option.

Workspace Caches
::::::::::::::::

``level-{{level}}-*-workspace``
   These caches (of various names typically ending with ``workspace``)
   contain state to be shared between task invocations. Use cases are
   dependent on the task.

Other
:::::

``level-{{level}}-tooltool-cache-{{hash}}``
   Tooltool invocations should use this cache. Tooltool will store files here
   indexed by their hash.

   This cache name pattern is reserved for use with ``run-task`` and must only
   be used by ``run-task``

``tooltool-cache`` (deprecated)
   Legacy location for tooltool files. Use the per-level one instead.