Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions .github/workflows/zed-cargo-product.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ on:
type: string
default: ""
base_sha:
description: Seed commit. Defaults to benchmark-source.env.
description: Seed commit. Defaults to cargo-layer-source.env.
required: false
type: string
default: ""
head_sha:
description: Adjacent commit built by every warm lane. Defaults to benchmark-source.env.
description: Adjacent commit built by every warm lane. Defaults to cargo-layer-source.env.
required: false
type: string
default: ""
Expand Down Expand Up @@ -55,7 +55,7 @@ jobs:
INPUT_HEAD_SHA: ${{ inputs.head_sha }}
run: |
set -euo pipefail
source benchmark-source.env
source cargo-layer-source.env
echo "base_sha=${INPUT_BASE_SHA:-$ZED_BASE_SHA}" >> "$GITHUB_OUTPUT"
echo "head_sha=${INPUT_HEAD_SHA:-$ZED_HEAD_SHA}" >> "$GITHUB_OUTPUT"

Expand Down Expand Up @@ -165,7 +165,6 @@ jobs:
mode: cargo
trust-policy: restore
working-directory: upstream
fail-on-cache-miss: true
fail-on-cache-error: true
diagnostics: summary
metadata-hints: phase=matrix-target-only-primary
Expand Down Expand Up @@ -317,7 +316,6 @@ jobs:
mode: cargo
trust-policy: restore
working-directory: upstream
fail-on-cache-miss: true
fail-on-cache-error: true
diagnostics: summary
metadata-hints: phase=matrix-combined-primary
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ lane/phase selector.
The GitHub workflow selects those plans and leaves cache identity, target
selection, and compiler-cache selection to the BoringCache CLI.

[`cargo-layer-source.env`](cargo-layer-source.env) pins the reviewed adjacent
source pair for that matrix independently of the continuously advancing rolling
source. Every matrix plan tag carries the pinned head identity, so a later
rolling sync cannot silently turn the cold seed into an older-cohort restore.

The root [`.boringcache.toml`](.boringcache.toml) owns the persistent rolling
chain. [`.github/workflows/zed-cargo-product.yml`](.github/workflows/zed-cargo-product.yml)
owns the independent release matrix.
3 changes: 3 additions & 0 deletions cargo-layer-source.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ZED_SOURCE_REPOSITORY=zed-industries/zed
ZED_BASE_SHA=4e8057d74db3570b3bd419ff296eb84c35b3a5a3
ZED_HEAD_SHA=d4010e91ccc9635853698af160f15bb479a484d0
8 changes: 4 additions & 4 deletions plans/cold/primary/.boringcache.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
workspace = "boringcache/benchmark-zed"

[entries.cargo-registry]
tag = "zed-cargo-layers-1181-d4010e9-registry"
tag = "zed-cargo-layers-1181-d4010e9-r4-registry"

[entries.cargo-git]
tag = "zed-cargo-layers-1181-d4010e9-git"
tag = "zed-cargo-layers-1181-d4010e9-r4-git"

[entries.zed-target]
kind = "cargo-target"
tag = "zed-cargo-layers-1181-d4010e9-target"
tag = "zed-cargo-layers-1181-d4010e9-r4-target"
path = "target"

[profiles.cargo-product]
entries = ["cargo-registry", "cargo-git", "zed-target"]

[adapters.sccache]
tag = "zed-cargo-layers-1181-d4010e9-sccache"
tag = "zed-cargo-layers-1181-d4010e9-r4-sccache"
no-git = true
metadata-hints = ["benchmark=zed-cargo-layers", "layer=compiler"]

Expand Down
8 changes: 4 additions & 4 deletions plans/cold/remote-server/.boringcache.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
workspace = "boringcache/benchmark-zed"

[entries.cargo-registry]
tag = "zed-cargo-layers-1181-d4010e9-registry"
tag = "zed-cargo-layers-1181-d4010e9-r4-registry"

[entries.cargo-git]
tag = "zed-cargo-layers-1181-d4010e9-git"
tag = "zed-cargo-layers-1181-d4010e9-r4-git"

[entries.zed-target]
kind = "cargo-target"
tag = "zed-cargo-layers-1181-d4010e9-target"
tag = "zed-cargo-layers-1181-d4010e9-r4-target"
path = "target"

[profiles.cargo-product]
entries = ["cargo-registry", "cargo-git", "zed-target"]

[adapters.sccache]
tag = "zed-cargo-layers-1181-d4010e9-sccache"
tag = "zed-cargo-layers-1181-d4010e9-r4-sccache"
no-git = true
metadata-hints = ["benchmark=zed-cargo-layers", "layer=compiler"]

Expand Down
8 changes: 4 additions & 4 deletions plans/combined/primary/.boringcache.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
workspace = "boringcache/benchmark-zed"

[entries.cargo-registry]
tag = "zed-cargo-layers-1181-d4010e9-registry"
tag = "zed-cargo-layers-1181-d4010e9-r4-registry"

[entries.cargo-git]
tag = "zed-cargo-layers-1181-d4010e9-git"
tag = "zed-cargo-layers-1181-d4010e9-r4-git"

[entries.zed-target]
kind = "cargo-target"
tag = "zed-cargo-layers-1181-d4010e9-target"
tag = "zed-cargo-layers-1181-d4010e9-r4-target"
path = "target"

[profiles.cargo-product]
entries = ["cargo-registry", "cargo-git", "zed-target"]

[adapters.sccache]
tag = "zed-cargo-layers-1181-d4010e9-sccache"
tag = "zed-cargo-layers-1181-d4010e9-r4-sccache"
no-git = true
metadata-hints = ["benchmark=zed-cargo-layers", "layer=compiler"]

Expand Down
8 changes: 4 additions & 4 deletions plans/combined/remote-server/.boringcache.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
workspace = "boringcache/benchmark-zed"

[entries.cargo-registry]
tag = "zed-cargo-layers-1181-d4010e9-registry"
tag = "zed-cargo-layers-1181-d4010e9-r4-registry"

[entries.cargo-git]
tag = "zed-cargo-layers-1181-d4010e9-git"
tag = "zed-cargo-layers-1181-d4010e9-r4-git"

[entries.zed-target]
kind = "cargo-target"
tag = "zed-cargo-layers-1181-d4010e9-target"
tag = "zed-cargo-layers-1181-d4010e9-r4-target"
path = "target"

[profiles.cargo-product]
entries = ["cargo-registry", "cargo-git", "zed-target"]

[adapters.sccache]
tag = "zed-cargo-layers-1181-d4010e9-sccache"
tag = "zed-cargo-layers-1181-d4010e9-r4-sccache"
no-git = true
metadata-hints = ["benchmark=zed-cargo-layers", "layer=compiler"]

Expand Down
8 changes: 4 additions & 4 deletions plans/sccache-only/primary/.boringcache.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
workspace = "boringcache/benchmark-zed"

[entries.cargo-registry]
tag = "zed-cargo-layers-1181-d4010e9-registry"
tag = "zed-cargo-layers-1181-d4010e9-r4-registry"

[entries.cargo-git]
tag = "zed-cargo-layers-1181-d4010e9-git"
tag = "zed-cargo-layers-1181-d4010e9-r4-git"

[entries.zed-target]
kind = "cargo-target"
tag = "zed-cargo-layers-1181-d4010e9-target"
tag = "zed-cargo-layers-1181-d4010e9-r4-target"
path = "target"

[profiles.cargo-product]
entries = ["cargo-registry", "cargo-git"]

[adapters.sccache]
tag = "zed-cargo-layers-1181-d4010e9-sccache"
tag = "zed-cargo-layers-1181-d4010e9-r4-sccache"
no-git = true
metadata-hints = ["benchmark=zed-cargo-layers", "layer=compiler"]

Expand Down
8 changes: 4 additions & 4 deletions plans/sccache-only/remote-server/.boringcache.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
workspace = "boringcache/benchmark-zed"

[entries.cargo-registry]
tag = "zed-cargo-layers-1181-d4010e9-registry"
tag = "zed-cargo-layers-1181-d4010e9-r4-registry"

[entries.cargo-git]
tag = "zed-cargo-layers-1181-d4010e9-git"
tag = "zed-cargo-layers-1181-d4010e9-r4-git"

[entries.zed-target]
kind = "cargo-target"
tag = "zed-cargo-layers-1181-d4010e9-target"
tag = "zed-cargo-layers-1181-d4010e9-r4-target"
path = "target"

[profiles.cargo-product]
entries = ["cargo-registry", "cargo-git"]

[adapters.sccache]
tag = "zed-cargo-layers-1181-d4010e9-sccache"
tag = "zed-cargo-layers-1181-d4010e9-r4-sccache"
no-git = true
metadata-hints = ["benchmark=zed-cargo-layers", "layer=compiler"]

Expand Down
6 changes: 3 additions & 3 deletions plans/target-only/primary/.boringcache.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
workspace = "boringcache/benchmark-zed"

[entries.cargo-registry]
tag = "zed-cargo-layers-1181-d4010e9-registry"
tag = "zed-cargo-layers-1181-d4010e9-r4-registry"

[entries.cargo-git]
tag = "zed-cargo-layers-1181-d4010e9-git"
tag = "zed-cargo-layers-1181-d4010e9-r4-git"

[entries.zed-target]
kind = "cargo-target"
tag = "zed-cargo-layers-1181-d4010e9-target"
tag = "zed-cargo-layers-1181-d4010e9-r4-target"
path = "target"

[profiles.cargo-product]
Expand Down
6 changes: 3 additions & 3 deletions plans/target-only/remote-server/.boringcache.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
workspace = "boringcache/benchmark-zed"

[entries.cargo-registry]
tag = "zed-cargo-layers-1181-d4010e9-registry"
tag = "zed-cargo-layers-1181-d4010e9-r4-registry"

[entries.cargo-git]
tag = "zed-cargo-layers-1181-d4010e9-git"
tag = "zed-cargo-layers-1181-d4010e9-r4-git"

[entries.zed-target]
kind = "cargo-target"
tag = "zed-cargo-layers-1181-d4010e9-target"
tag = "zed-cargo-layers-1181-d4010e9-r4-target"
path = "target"

[profiles.cargo-product]
Expand Down
5 changes: 4 additions & 1 deletion scripts/summarize-cargo-evidence.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ def summarize(label: str, evidence_path: Path) -> str:
evidence = json.loads(evidence_path.read_text())
phase = evidence.get("phases", {}).get("restore", {})
mode = phase.get("mode_evidence", {})
native = mode.get("native_tool", {})
native = mode.get("native_tool") or {}
compiler_cache = mode.get("cargo_cache", {}).get("compiler_cache")

requests = native.get("compile_requests")
executed = native.get("compile_requests_executed")
Expand All @@ -35,6 +36,8 @@ def summarize(label: str, evidence_path: Path) -> str:
lines.append(f" - elapsed: {elapsed:.0f}s")
if target_hit is not None:
lines.append(f" - target snapshot restored: `{target_hit}`")
if compiler_cache == "none":
lines.append(" - compiler cache: disabled")
if requests is not None:
lines.append(
f" - Cargo units compiled: {executed if executed is not None else requests}"
Expand Down
17 changes: 16 additions & 1 deletion scripts/verify-zed-release-recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ def verify_upstream(upstream: Path, contract: dict[str, str]) -> None:


def verify_plans() -> None:
source = read_settings(ROOT / "cargo-layer-source.env")
cohort = source["ZED_HEAD_SHA"][:7]
target_tags: set[str] = set()
compiler_tags: set[str] = set()
dependency_tag_pairs: set[tuple[str, str]] = set()
Expand Down Expand Up @@ -142,6 +144,11 @@ def verify_plans() -> None:
require(cargo["no-git"] is True, f"{path} must use stable reviewed tags")

config_entries = plan["entries"]
for entry in config_entries.values():
require(
cohort in entry["tag"],
f"{path} does not carry the pinned layer-source identity",
)
target_tags.add(config_entries["zed-target"]["tag"])
dependency_tag_pairs.add(
(
Expand All @@ -155,6 +162,10 @@ def verify_plans() -> None:
f"{path} must give sccache an independent identity",
)
compiler_tags.add(plan["adapters"]["sccache"]["tag"])
require(
cohort in plan["adapters"]["sccache"]["tag"],
f"{path} compiler tag does not carry the pinned layer-source identity",
)
else:
require(
"sccache" not in plan["adapters"],
Expand All @@ -178,6 +189,10 @@ def verify_workflows() -> None:

require("scope-boringcache-run" not in all_workflows, "Workflows must not rewrite tags")
require("mode: sccache" not in all_workflows, "Cargo owns the composed lifecycle")
require(
"source cargo-layer-source.env" in matrix,
"The layer matrix must not follow the moving rolling source",
)
require(
"boringcache/one@ab52a39d3d7358c22b359a6ffbf86cf74be9bf56" in matrix,
"The matrix must use released One 1.18.1",
Expand Down Expand Up @@ -210,7 +225,7 @@ def verify_workflows() -> None:

def verify(upstream: Path) -> str:
contract = read_settings(ROOT / "scripts/zed-release-recipe.env")
source = read_settings(ROOT / "benchmark-source.env")
source = read_settings(ROOT / "cargo-layer-source.env")
verify_upstream(upstream, contract)
verify_plans()
verify_workflows()
Expand Down
51 changes: 51 additions & 0 deletions test/test_cargo_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def test_action_selects_plans_but_does_not_plan_layers(self):
self.assertNotIn("scope-boringcache-run", workflow_text)
self.assertNotIn("mode: sccache", workflow_text)
self.assertNotIn("sed -i", workflow_text)
self.assertNotIn("fail-on-cache-miss", matrix)
self.assertNotIn("cache_scope:", rolling)
self.assertEqual(matrix.count("mode: cargo"), 8)
self.assertIn("inputs.cli_version", matrix)
Expand Down Expand Up @@ -129,6 +130,25 @@ def test_source_pair_matches_the_pinned_submodule(self):

self.assertEqual(source["ZED_HEAD_SHA"], head)

def test_layer_matrix_owns_a_fixed_source_cohort(self):
source = dict(
line.split("=", 1)
for line in (ROOT / "cargo-layer-source.env").read_text().splitlines()
)
cohort = source["ZED_HEAD_SHA"][:7]
matrix = (WORKFLOWS / "zed-cargo-product.yml").read_text()

self.assertNotEqual(source["ZED_BASE_SHA"], source["ZED_HEAD_SHA"])
self.assertIn("source cargo-layer-source.env", matrix)
self.assertNotIn("source benchmark-source.env", matrix)
for path in sorted((ROOT / "plans").glob("*/*/.boringcache.toml")):
plan = tomllib.loads(path.read_text())
for entry in plan["entries"].values():
self.assertIn(cohort, entry["tag"])
sccache = plan["adapters"].get("sccache")
if sccache:
self.assertIn(cohort, sccache["tag"])

def test_release_recipe_and_layer_contract(self):
subprocess.run(
[sys.executable, str(ROOT / "scripts/verify-zed-release-recipe.py"), "upstream"],
Expand Down Expand Up @@ -172,6 +192,37 @@ def test_native_hit_rate_is_already_a_percentage(self):
self.assertIn("96.0% hit rate", result.stdout)
self.assertNotIn("9600", result.stdout)

def test_report_handles_a_disabled_compiler_cache(self):
evidence = {
"phases": {
"restore": {
"mode_evidence": {
"elapsed_seconds": 12.4,
"target_cache_hit": True,
"native_tool": None,
"cargo_cache": {"compiler_cache": "none"},
}
}
}
}
with tempfile.TemporaryDirectory() as directory:
path = Path(directory) / "evidence.json"
path.write_text(json.dumps(evidence))
result = subprocess.run(
[
sys.executable,
str(ROOT / "scripts/summarize-cargo-evidence.py"),
"target-only",
str(path),
],
check=True,
text=True,
capture_output=True,
)

self.assertIn("target snapshot restored: `True`", result.stdout)
self.assertIn("compiler cache: disabled", result.stdout)


if __name__ == "__main__":
unittest.main()
Loading