Skip to content

The cargo registry cache misses on every run for a large workspace — and the restore failure is invisible #132

Description

@debuggingfuture

#118 made the cargo registry cacheable by teaching CacheService a base outside the checkout. On a large Rust consumer it still misses every run — the full cargo fetch --locked download runs each time, ~1.0 GB and ~40s, and the log is byte-identical run to run.

Evidence

The install's exec logs are identical across a dozen consecutive executions (exec-5.ndjson, 41,299 B of Downloaded <crate> lines). composeRestoreOr runs onMiss only on a miss or a restore error, so one of the two is happening on every attempt — and it has been happening since #118 deployed, which rules out "the first run pays and the rest hit".

The suspicion, stated as a suspicion

The archive is 113.9 MB for that repo (registry/cache 113 MB + registry/index 44 MB, gzipped). The restore path does:

await box.writeFile(TARBALL_PATH, archive.body);

— streaming a 114 MB body from R2 into the container through the Worker, against a 128 MB isolate memory budget. That is close enough to the ceiling to be worth ruling in or out before anything else, and it would explain why a smaller consumer's node_modules cache works while this one does not.

Not confirmed: restore catches its own failure into CacheError and composeRestoreOr treats it as a miss, so the failure is invisible from the consumer side. The first fix is to make it visible — log the restore error at warn with its phase and size, so the next run says which of the two it is instead of leaving it to be inferred.

Why it matters more than 40 seconds

It is 40s and 1 GB today, on a run that shares one container. The moment stages get their own containers (#131), the same download is paid N times.

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