Repository navigation
Closed
Description
Common use case: fetching dependencies, syncing BOSH blobs, etc.
Caching the directories that these fetch into and update would dramatically speed up a bunch of builds. Our own ATC JS build spends 99% of its time just downloading npm packages.
Proposal:
Add a cache field to task configs, like so:
---
platform: linux
inputs:
- name: my-release
cache:
- path: my-release/.blobs
run:
path: my-release/ci/scripts/create-releaseThen, given I have a pipeline like so:
jobs:
- name: make-release
plan:
- get: my-release
- task: create-release
file: my-release/ci/create-release.ymlThis would cache the directory my-release/.blobs between runs of that specific task in its job's build plan. So, the cache lookup key would be something like team-id+pipeline-id+job-name+task-name.
Notes:
- This should also have the guarantee that two concurrent builds of the same job do not pollute each others' caches. There should be some sort of copy-on-write semantics, such that each job gets its own copy of the cache (initially empty), and at the end all other caches are marked "stale" and are set to expire.
- Assumes tools will be durable to the directory being initially present + empty on the initial cache run. I think this should be fine. Without this it'll be very annoying to orchestrate.
- The caching is for purely ephemeral data, so it doesn't sacrifice Concourse's "not being a source of truth" principle.
- Has the same cache warming semantics as
gets, i.e. it may take a bit for the cache to warm across the workers; it does not influence worker placement. - Has no effect on one-off builds, as there is not enough information to scope/correlate the caches (compared to a job build).
Reacted by Dylan Waits, Dani Brown, Dave Syer, Khaled Janania, Simon van der Veldt, Daniel Mason, Ciro S. Costa, Louis-Paul Dareau, Gabriele Petronella, Dmitry Matrosov and 51 more
Activity
concourse-bot commentedon Dec 12, 2015
Hi there!
We use Pivotal Tracker to provide visibility into what our team is working on. A story for this issue has been automatically created.
The current status is as follows:
This comment, as well as the labels on the issue, will be automatically updated as the status in Tracker changes.
xoebus commentedon Dec 12, 2015
👍
It's an important feature but I can see it getting abused. Maybe we need a best practices document that sets some guidelines for having a sane pipeline. e.g. don't publish a different artefact to the same version number otherwise nothing will work properly.
Maybe we could have a random chance of running a task without a cache to make sure people aren't depending on it. 👀
nicorikken commentedon Dec 14, 2015
I'd certainly like to see this come about. Our use-case includes downloading NPM dependencies as well, but also downloading Nix-packages. Copy-on-write would suit that use-case.
Sharing this cache even among pipelines would make sense efficiency-wise, although that would introduce (semantic) dependencies between pipelines.
vito commentedon Dec 14, 2015
@nicorikken We'll probably not start with cross-pipeline or even cross-job caching as that opens another can of worms: how to configure which caches apply to which tasks/etc. I could see that becoming a nightmare pretty quickly if you e.g. copy a job from another pipeline that has a cache name the same as yours because it was called something too generic.
So we'll probably just stick with as tightly-scoped as possible (individual task within job).
nicorikken commentedon Dec 17, 2015
@vito Totally agree, makes most sense. There are other 'hacks' for getting around such issues, and worst-case somebody would have to write a specific resource targeting the local disk.
jchester commentedon Dec 19, 2015
👍 from me, both privately (I have a pipeline pulling umpteen zillion jars) and professionally (pivnet is a hungry gem consumer).
devcurmudgeon commentedon Jan 5, 2016
not sure i understand this discussion properly, but i think just supporting the possibility to have 'cache' directory/ies untouched between jobs would be very useful on its own. various tools have their own cache lookup processes (eg bitbake)
tomwhoiscontrary commentedon Jul 19, 2016
👍 we've got microservices built with Gradle, so every one of our 27 tasks starts by downloading Gradle, then all our dependencies, and it's horrendous. Cache plox.
As a stop-gap, could we write some sort of pre-loading resource? It would somehow download the Gradle binary and some set of dependencies, then we would copy that into place before kicking off the build. That would let us exploit Concourse's local caching of resources, right?
simonvanderveldt commentedon Jul 21, 2016
@vito While I do understand it will be hard to make sure people don't use it for the wrong reasons we see a serious speedup with shared caches between pipelines (and by extension also between jobs).
But the caches we share in these cases are the "normal" per user package manager's caches, so for example for npm this is
~/.npm/and for sbt this is~/.ivy2/.Would it be possible to support this somehow?
@nicorikken Can you share those other "hacks"?
seadowg commentedon Aug 31, 2016
As a wee push: not having this feature is still causing major problems with Concourse at some enterprise companies due to terrible connections (usually through a VPN). I've seen this drop down the backlog a couple of times so just thought I'd add my feelings from the world of self important anecdotal evidence.
81 remaining items
add caching between task runs
add test for task caches
bump atc testflight
do not initialize task cache volumes for one off builds
bump atc
add documentation for task caches
vito commentedon Jun 27, 2017
@mariash minor thing - noticed these show up as "unknown" in
fly volumes. could we show something special for these? e.g.task-cacheand maybe the pipeline/job/step?vito commentedon Jun 28, 2017
Breaking that last bit out as a separate issue in 3.3.x since it's not critical enough to block release.
add documentation for task caches
bump atc
alnavart commentedon Mar 4, 2022
Hi, based on last @mariash comment. Where reflect that "garbage collect task caches" was not done. Are cache volumes never removed by the garbage collector?
We had some issues related with the disk usage after enable some caches and can be related with it.
Thanks