Skip to content

Commit b03f297

Browse files
r-barnesmeta-codesync[bot]
authored andcommitted
getdeps: eliminate per-dep cache pyramid; enable sccache by default
Summary: Our GHA workflows did not previously use sccache, so they had a complex per-dep cache pyramid. Now they do use sccache. sccache works on a per-file level so it can accelerate builds even when a dependency has changed. Now that we have this new caching mechanism we can retire the cache pyramid for a significant reduction in workflow complexity. Trying that here. Flip `--use-build-cache` to off by default. The pyramid is now opt-in via `--use-build-cache`; sccache remains on by default for all non-Windows platforms (it was already the default — this change makes the pyramid the non-default). Golden test fixtures are regenerated to match the new output shape. Reviewed By: bigfootjon Differential Revision: D105903053 fbshipit-source-id: 8eb0fa3afa0de8975752710bb695619d2453d2c4
1 parent bd77812 commit b03f297

9 files changed

Lines changed: 146 additions & 1812 deletions

File tree

.github/workflows/getdeps_linux.yml

Lines changed: 35 additions & 490 deletions
Large diffs are not rendered by default.

build/fbcode_builder/getdeps/test/fixtures/expected/folly_shared_libs/getdeps_shared-libs_linux.yml

Lines changed: 24 additions & 336 deletions
Large diffs are not rendered by default.

build/fbcode_builder/getdeps/test/fixtures/expected/openr/getdeps_linux.yml

Lines changed: 35 additions & 490 deletions
Large diffs are not rendered by default.

build/fbcode_builder/getdeps/test/fixtures/expected/rebalancer_linux/getdeps_linux.yml

Lines changed: 29 additions & 406 deletions
Large diffs are not rendered by default.

build/fbcode_builder/getdeps/test/fixtures/expected/xxhash_plain/getdeps_linux.yml

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -39,39 +39,13 @@ jobs:
3939
name: Query paths
4040
run: python3 build/fbcode_builder/getdeps.py query-paths --recursive --src-dir=. xxhash >> "$GITHUB_OUTPUT"
4141

42-
- name: Restore ninja from cache
43-
id: restore_ninja
44-
if: ${{ steps.paths.outputs.ninja_SOURCE }}
45-
uses: actions/cache/restore@v4
46-
with:
47-
path: ${{ steps.paths.outputs.ninja_INSTALL }}
48-
key: ${{ steps.paths.outputs.ninja_CACHE_KEY }}-install
4942
- name: Build ninja
50-
if: ${{ steps.paths.outputs.ninja_SOURCE && ! steps.restore_ninja.outputs.cache-hit }}
43+
if: ${{ steps.paths.outputs.ninja_SOURCE }}
5144
run: python3 build/fbcode_builder/getdeps.py build --build-type RelWithDebInfo --no-tests ninja
52-
- name: Save ninja to cache
53-
uses: actions/cache/save@v4
54-
if: ${{ steps.paths.outputs.ninja_SOURCE && ! steps.restore_ninja.outputs.cache-hit }}
55-
with:
56-
path: ${{ steps.paths.outputs.ninja_INSTALL }}
57-
key: ${{ steps.paths.outputs.ninja_CACHE_KEY }}-install
5845

59-
- name: Restore cmake from cache
60-
id: restore_cmake
61-
if: ${{ steps.paths.outputs.cmake_SOURCE }}
62-
uses: actions/cache/restore@v4
63-
with:
64-
path: ${{ steps.paths.outputs.cmake_INSTALL }}
65-
key: ${{ steps.paths.outputs.cmake_CACHE_KEY }}-install
6646
- name: Build cmake
67-
if: ${{ steps.paths.outputs.cmake_SOURCE && ! steps.restore_cmake.outputs.cache-hit }}
47+
if: ${{ steps.paths.outputs.cmake_SOURCE }}
6848
run: python3 build/fbcode_builder/getdeps.py build --build-type RelWithDebInfo --no-tests cmake
69-
- name: Save cmake to cache
70-
uses: actions/cache/save@v4
71-
if: ${{ steps.paths.outputs.cmake_SOURCE && ! steps.restore_cmake.outputs.cache-hit }}
72-
with:
73-
path: ${{ steps.paths.outputs.cmake_INSTALL }}
74-
key: ${{ steps.paths.outputs.cmake_CACHE_KEY }}-install
7549

7650
- name: Build xxhash
7751
run: python3 build/fbcode_builder/getdeps.py build --build-type RelWithDebInfo --src-dir=. xxhash --project-install-prefix xxhash:/usr/local

build/fbcode_builder/getdeps/test/fixtures/expected/xxhash_plain/getdeps_mac.yml

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -45,39 +45,13 @@ jobs:
4545
name: Query paths
4646
run: python3 build/fbcode_builder/getdeps.py query-paths --recursive --src-dir=. xxhash >> "$GITHUB_OUTPUT"
4747

48-
- name: Restore ninja from cache
49-
id: restore_ninja
50-
if: ${{ steps.paths.outputs.ninja_SOURCE }}
51-
uses: actions/cache/restore@v4
52-
with:
53-
path: ${{ steps.paths.outputs.ninja_INSTALL }}
54-
key: ${{ steps.paths.outputs.ninja_CACHE_KEY }}-install
5548
- name: Build ninja
56-
if: ${{ steps.paths.outputs.ninja_SOURCE && ! steps.restore_ninja.outputs.cache-hit }}
49+
if: ${{ steps.paths.outputs.ninja_SOURCE }}
5750
run: python3 build/fbcode_builder/getdeps.py build --build-type RelWithDebInfo --no-tests ninja
58-
- name: Save ninja to cache
59-
uses: actions/cache/save@v4
60-
if: ${{ steps.paths.outputs.ninja_SOURCE && ! steps.restore_ninja.outputs.cache-hit }}
61-
with:
62-
path: ${{ steps.paths.outputs.ninja_INSTALL }}
63-
key: ${{ steps.paths.outputs.ninja_CACHE_KEY }}-install
6451

65-
- name: Restore cmake from cache
66-
id: restore_cmake
67-
if: ${{ steps.paths.outputs.cmake_SOURCE }}
68-
uses: actions/cache/restore@v4
69-
with:
70-
path: ${{ steps.paths.outputs.cmake_INSTALL }}
71-
key: ${{ steps.paths.outputs.cmake_CACHE_KEY }}-install
7252
- name: Build cmake
73-
if: ${{ steps.paths.outputs.cmake_SOURCE && ! steps.restore_cmake.outputs.cache-hit }}
53+
if: ${{ steps.paths.outputs.cmake_SOURCE }}
7454
run: python3 build/fbcode_builder/getdeps.py build --build-type RelWithDebInfo --no-tests cmake
75-
- name: Save cmake to cache
76-
uses: actions/cache/save@v4
77-
if: ${{ steps.paths.outputs.cmake_SOURCE && ! steps.restore_cmake.outputs.cache-hit }}
78-
with:
79-
path: ${{ steps.paths.outputs.cmake_INSTALL }}
80-
key: ${{ steps.paths.outputs.cmake_CACHE_KEY }}-install
8155

8256
- name: Build xxhash
8357
run: python3 build/fbcode_builder/getdeps.py build --build-type RelWithDebInfo --src-dir=. xxhash --project-install-prefix xxhash:/usr/local

build/fbcode_builder/getdeps/test/fixtures/expected/xxhash_plain/getdeps_windows.yml

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ jobs:
1818
build:
1919
runs-on: windows-2022
2020
timeout-minutes: 60
21+
env:
22+
SCCACHE_GHA_ENABLED: "on"
2123
steps:
2224

2325
- name: Show runner info
@@ -40,48 +42,31 @@ jobs:
4042

4143
- uses: actions/checkout@v6
4244

45+
- name: Set up sccache
46+
uses: mozilla-actions/sccache-action@v0.0.9
47+
with:
48+
version: "v0.14.0"
49+
4350
- id: paths
4451
name: Query paths
4552
run: python build/fbcode_builder/getdeps.py query-paths --recursive --src-dir=. xxhash >> $env:GITHUB_OUTPUT
4653
shell: pwsh
4754

48-
- name: Restore ninja from cache
49-
id: restore_ninja
50-
if: ${{ steps.paths.outputs.ninja_SOURCE }}
51-
uses: actions/cache/restore@v4
52-
with:
53-
path: ${{ steps.paths.outputs.ninja_INSTALL }}
54-
key: ${{ steps.paths.outputs.ninja_CACHE_KEY }}-install
5555
- name: Build ninja
56-
if: ${{ steps.paths.outputs.ninja_SOURCE && ! steps.restore_ninja.outputs.cache-hit }}
56+
if: ${{ steps.paths.outputs.ninja_SOURCE }}
5757
run: python build/fbcode_builder/getdeps.py build --build-type RelWithDebInfo --no-tests ninja
58-
- name: Save ninja to cache
59-
uses: actions/cache/save@v4
60-
if: ${{ steps.paths.outputs.ninja_SOURCE && ! steps.restore_ninja.outputs.cache-hit }}
61-
with:
62-
path: ${{ steps.paths.outputs.ninja_INSTALL }}
63-
key: ${{ steps.paths.outputs.ninja_CACHE_KEY }}-install
6458

65-
- name: Restore cmake from cache
66-
id: restore_cmake
67-
if: ${{ steps.paths.outputs.cmake_SOURCE }}
68-
uses: actions/cache/restore@v4
69-
with:
70-
path: ${{ steps.paths.outputs.cmake_INSTALL }}
71-
key: ${{ steps.paths.outputs.cmake_CACHE_KEY }}-install
7259
- name: Build cmake
73-
if: ${{ steps.paths.outputs.cmake_SOURCE && ! steps.restore_cmake.outputs.cache-hit }}
60+
if: ${{ steps.paths.outputs.cmake_SOURCE }}
7461
run: python build/fbcode_builder/getdeps.py build --build-type RelWithDebInfo --no-tests cmake
75-
- name: Save cmake to cache
76-
uses: actions/cache/save@v4
77-
if: ${{ steps.paths.outputs.cmake_SOURCE && ! steps.restore_cmake.outputs.cache-hit }}
78-
with:
79-
path: ${{ steps.paths.outputs.cmake_INSTALL }}
80-
key: ${{ steps.paths.outputs.cmake_CACHE_KEY }}-install
8162

8263
- name: Build xxhash
8364
run: python build/fbcode_builder/getdeps.py build --build-type RelWithDebInfo --src-dir=. xxhash
8465

66+
- name: Show sccache stats
67+
if: always()
68+
run: sccache --show-stats
69+
8570
- name: Copy artifacts
8671
run: python build/fbcode_builder/getdeps.py fixup-dyn-deps --src-dir=. xxhash _artifacts/windows --final-install-prefix /usr/local
8772
- uses: actions/upload-artifact@v6

build/fbcode_builder/getdeps/test/workflow_generator_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def _make_args(project: str, output_dir: str, **overrides: Any) -> argparse.Name
7878
"free_up_disk": False,
7979
"free_up_disk_before_build": False,
8080
"build_type": "RelWithDebInfo",
81-
"use_build_cache": True,
81+
"use_build_cache": False,
8282
"package_extra_cmake_defines": [],
8383
"scratch_path": None,
8484
"vcvars_path": None,

build/fbcode_builder/getdeps/workflow_generator.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def gh(key):
8787

8888
run_tests = args.enable_tests and gh("run_tests") != "off"
8989
rust_version = gh("rust_version") or "stable"
90-
use_sccache = gh("sccache") != "off" and not build_opts.is_windows()
90+
use_sccache = gh("sccache") != "off"
9191
use_homebrew_llvm = build_opts.is_darwin()
9292
override_build_type = args.build_type or gh("build_type")
9393
timeout_minutes = gh("timeout_minutes") or "60"
@@ -430,11 +430,11 @@ def setup_project_cmd_parser(self, parser):
430430
)
431431
parser.add_argument("--build-type", **BUILD_TYPE_ARG)
432432
parser.add_argument(
433-
"--no-build-cache",
434-
action="store_false",
435-
default=True,
433+
"--use-build-cache",
434+
action="store_true",
435+
default=False,
436436
dest="use_build_cache",
437-
help="Do not attempt to use the build cache.",
437+
help="Emit a per-dep actions/cache restore/save pyramid. Disabled by default; sccache handles compile-unit caching instead.",
438438
)
439439
parser.add_argument(
440440
"--package-extra-cmake-defines",

0 commit comments

Comments
 (0)