Skip to content

Build recipes that exceed the 6h runner limit (e.g. envoy) via a Bazel remote cache #13958

Description

@tannevaled

Problem

github.com/envoyproxy/envoy cannot be bottled on the standard GitHub-hosted
runners: a from-scratch Bazel build exceeds the 6 h job time limit. This is
not a recipe defect — every recipe-level lever has been exhausted:

Lever tried Result
--jobs = HOST_CPUS * 0.5 x86-64 times out at 6 h
--jobs = HOST_CPUS * 1.0 ARM64 OOM-killed
--jobs = HOST_CPUS * 0.66 both fail (x64 timeout, ARM64 flaky Rust genrule)
--fission=no, -Wno-error, --disable-new-dtags, rustc wrapper needed to compile at all, but do not reduce wall-clock below 6 h

A single job cannot finish, and the recipe cannot change the runner's time limit.

Key insight (empirically verified)

Bazel uploads each action's result to a remote cache as soon as that action
completes
— not at the end of the build. Consequently a fresh, ephemeral
runner pointed at the same remote cache hits the cache for every action a
previous run already completed
, and only executes what remains. Splitting one

6 h build into several sequential ≤6 h windows becomes viable: window K
uploads the actions it finishes before timing out; window K+1 starts from a
clean checkout, hits the cache for those actions, and continues.

Proof

Reference cache: bazel-remote, built
pure-Go, CGO=0. Test project: 6 × sleep 4 genrules + an aggregator.

PHASE 1  COLD  (cache empty)        -> 7 processes executed        10 s
         bazel clean --expunge      -> wipes the ENTIRE output_base (= a brand-new runner)
PHASE 2  WARM  (same remote_cache)  -> 7 remote cache hit, 0 exec   2 s
         cache store survived the --expunge: 28 files / 112 K

--expunge deletes the whole local build state, which is exactly what an
ephemeral runner starts from. The warm run reconstructed the action graph and
resumed entirely from the cache — no re-execution. This is the multi-window
mechanism, demonstrated end to end.

Proposal

  1. Stand up a persistent Bazel remote cache reachable from the build workflow —
    e.g. bazel-remote (recipe proposed in github.com/buchgr/bazel-remote: new package #13957), backed by disk or S3, with
    GC/quota. One small always-on host, or an S3-proxy cache, suffices.
  2. Add to the envoy build the flags:
    --remote_cache=$CACHE_URL --remote_upload_local_results=true
    
    The cache URL / credentials are a workflow-level secret, not part of the
    public recipe (a public recipe must not carry secrets). This is why the
    change belongs at the workflow layer, not in package.yml.
  3. Run the build as N sequential jobs (a small needs:-ordered chain), each
    with the same --remote_cache. Each job may time out; the next resumes from
    the cache. After ≤N windows the final job produces a fully-populated tree and
    the bottle is packaged.

Alternatives considered

  • --disk_cache on a persistent runner volume — the local analogue; works
    only if the same runner volume survives between windows. Ephemeral hosted
    runners don't keep the volume, so a remote cache is the portable answer.
    (For a self-hosted runner with a persistent workspace, --disk_cache alone
    is enough and needs no server.)
  • A self-hosted runner without the 6 h cap — solves it directly but adds
    standing infra + trust surface; the remote-cache approach keeps the hosted
    runners.
  • RBE (BuildBuddy / NativeLink) — remote execution, not just caching;
    bigger lift, out of scope for "just get envoy to bottle".

Ask

Is pkgxdev open to (a) a persistent remote cache in the build infra and (b) a
chained multi-window job for the few recipes that exceed 6 h? If so, envoy
(otherwise code-complete) can land. Happy to wire the workflow side.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions