bazelbuild / bazelbuild/remote-apis

Idea: cache lifetime hints

Open
#151 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
445
Forks
141
PR merge metrics
No merged PRs in 30d

Description

## Opportunity

CAS/AC implementations could benefit from additional metadata that would hint about the appropriate lifetime of the object. That would allow tailor the cache for specific usages, reduce the active cache size and costs.

## Motivation example

Imagine a respectable-size monorepo where majority of full builds are triggered from CI on branches that are not yet merged into the main branch. Let's say that one of the artifacts produced by the build is 10Gb and that it only makes sense to cache this artifact when it's build from the main branch, not in all the feature branches. Also let's say that there are thousands of people contributing, so there is very small chance that this artifact from a feature branch would be re-used. Think like a big docker image that almost always impacted by any meaningful change in the repo.

Currently the API doesn't have a good mechanic to tell cache to lower the lifetime from its default in this case.

## Implementation

I had couple ideas in mind about how it could be done:

1. Adding `int32 lifetime_hint` to the write API. That would put the burden of calculating the desired ttl on the client. Probably not ideal.
2. Adding a generic `map lifetime_properties` (I hope there is a better name) similar to the `platform` that just acts as a bag of properties and server could decide for itself what to do with it. For example, that would allow `bazel` wrapper script to inject branch name into this bag of properties. Server could be aware of the branch names patterns that are used and ejects the big blobs earlier if it's not from the main branch.

I was thinking about sending a PR instead of issue to make the discussion easier, but the `ByteStream.Write` is in a different repo and it's probably not a good idea to change that one directly.
So I'm hoping there is some clever way to achieve the same end goal that community could suggest, if the idea is worthwhile pursuing.

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the CAS/AC write API and the ByteStream.Write definition, which the issue identifies as living in another repository. Compare the lifetime_hint and lifetime_properties proposals with the existing platform metadata, then document a community-agreed design and its compatibility implications.

Written by the indexing model from the issue text.

Assessment

Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.