Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.4.0] Implement disk cache garbage collection. #23833

Merged
merged 17 commits into from
Oct 2, 2024

Conversation

tjgq
Copy link
Contributor

@tjgq tjgq commented Oct 1, 2024

tjgq added 16 commits October 1, 2024 12:25
The garbage collection policy is defined by a maximum target size and a maximum age of individual cache entries, both of which may be simultaneously provided. I/O operations are parallelized to improve performance for large caches or slow filesystems.

PiperOrigin-RevId: 677860078
Change-Id: Ib342ad5e80ef4ef4af237aae243a300d13caaa06
PiperOrigin-RevId: 678351425
Change-Id: I86caf1d0fd8d1da209bbaae760f06e963a7d94b9
… around the disk cache.

PiperOrigin-RevId: 678765547
Change-Id: I3a77a2eb32cb2972a54f0574d70c0b9e58d35f04
With this change, Bazel becomes able to automatically garbage collect the disk cache while idle. The idle delay is controlled by --experimental_disk_cache_gc_idle_delay, while the collection criteria are set by --experimental_disk_cache_gc_max_{size,age}. At least one of the latter must be set for a collection to take place.

An end-to-end test will be added in a followup.

PiperOrigin-RevId: 679078545
Change-Id: Ic86e795c384a1502af675f00f9db8b5777a6adff
…ction run.

PiperOrigin-RevId: 679111203
Change-Id: If8ecf6c0881e410506358725943bc8cc49d8533e
…efore CAS entries with the same age.

PiperOrigin-RevId: 679138266
Change-Id: I6eadf1b872b4adaece69e56fd3977088634a348f
…arbage collection.

PiperOrigin-RevId: 679173101
Change-Id: I3a095a420e7933c4f4073c2f8d19e3b9b13fda5c
This might be useful to users who desire more control over when garbage collection runs. It also makes it easier to benchmark, since the facilities built into Bazel aren't capable of profiling idle tasks.

PiperOrigin-RevId: 679287940
Change-Id: Ib08bff105c2674f9d63ef57181805af30bbc0254
The ExecutorService created in RemoteModule#beforeCommand is intended to have command scope, so it won't be available during idle periods. (The current state doesn't work, either, because we pass it into the DiskCacheGarbageCollectorIdleTask before initializing it. Oops.)

PiperOrigin-RevId: 679497012
Change-Id: I8e791580c2db078c6d39cb760936b8fbcba4ed3d
PiperOrigin-RevId: 679550494
Change-Id: Ie397d3e498423ce1dd121e786c8e8e129bcb87f2
…ion of automatic garbage collection.

PiperOrigin-RevId: 679593657
Change-Id: I4f5aa03d88913702ab4c1b879bc2bc9b0c40f720
PiperOrigin-RevId: 680491370
Change-Id: Ia3454a60296fa183e59b0fde8c41da42ef75aba5
PiperOrigin-RevId: 680521067
Change-Id: I6c018eeaf73d8c7d8763774dad609c450faa87ac
…tsubmits.

PiperOrigin-RevId: 680537609
Change-Id: I1f32f299928922164c6b7924638bc6efc5655ff1
Unlikely to matter, but technically has better performance under contention.

PiperOrigin-RevId: 680917850
Change-Id: I1a26f01d9e092427634f725bd2211c272500aecc
The earlier fix in 6922734 is wrong on Linux, where the native encoding is indicated by the sun.jnu.encoding property, and could be something other than UTF-8.

Closes bazelbuild#23817.

PiperOrigin-RevId: 680947021
Change-Id: Idd52c1615de6edf423f59b62e364f0b7131f2d47
@tjgq tjgq removed the request for review from oquenchil October 1, 2024 12:29
@tjgq tjgq removed team-Android Issues for Android team team-Configurability platforms, toolchains, cquery, select(), config transitions team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. team-Rules-Java Issues for Java rules team-Rules-CPP Issues for C++ rules team-Rules-Python Native rules for Python team-Local-Exec Issues and PRs for the Execution (Local) team team-Remote-Exec Issues and PRs for the Execution (Remote) team team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website team-Rules-ObjC Issues for Objective-C maintainers team-CLI Console UI team-Documentation Documentation improvements that cannot be directly linked to other team labels labels Oct 1, 2024
… disk cache entry.

This reduces the window for a race condition with a concurrent build. (We don't need to close it completely, as Bazel has the ability to retry a build on a cache eviction.)

PiperOrigin-RevId: 680963998
Change-Id: I474f192e93da5cf98333ec9e211b3abae95f7b69
@tjgq tjgq force-pushed the disk-cache-gc-cherrypick branch from f100079 to 53839d3 Compare October 1, 2024 12:39
Copy link
Member

@meteorcloudy meteorcloudy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@meteorcloudy meteorcloudy enabled auto-merge October 1, 2024 13:05
@iancha1992 iancha1992 added this to the 7.4.0 release blockers milestone Oct 1, 2024
@meteorcloudy meteorcloudy added this pull request to the merge queue Oct 1, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 1, 2024
@meteorcloudy meteorcloudy added this pull request to the merge queue Oct 2, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 2, 2024
@meteorcloudy meteorcloudy merged commit 00ed3e2 into bazelbuild:release-7.4.0 Oct 2, 2024
50 checks passed
@github-actions github-actions bot removed the awaiting-review PR is awaiting review from an assigned reviewer label Oct 2, 2024
@luispadron
Copy link
Contributor

Thanks ya'll for all the work on getting this into Bazel 7!

Copy link

@Chino1307 Chino1307 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.bazelci/postsubmit.yml

@@ -18,6 +18,7 @@ tasks:
- "//src:bazel_jdk_minimal"
- "//src:test_repos"
- "//src/main/java/..."
- "//src/tools/diskcache/..."

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.bazelci/postsubmit.yml

Copy link

@Chino1307 Chino1307 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/BUILD

@@ -64,6 +64,8 @@
import com.google.devtools.build.lib.remote.circuitbreaker.CircuitBreakerFactory;
import com.google.devtools.build.lib.remote.common.RemoteCacheClient;
import com.google.devtools.build.lib.remote.common.RemoteExecutionClient;
import com.google.devtools.build.lib.remote.disk.DiskCacheClient;
import com.google.devtools.build.lib.remote.disk.DiskCacheGarbageCollectorIdleTask;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/BUILD

Copy link

@Chino1307 Chino1307 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/main/java/com/google/devtools/build/lib/remote/disk/DiskCacheClient.java

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.bazelci/presubmit.yml

@@ -15,12 +15,17 @@ java_library(
name = "disk",
srcs = glob(["*.java"]),
deps = [
"//src/main/java/com/google/devtools/build/lib/concurrent",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/main/java/com/google/devtools/build/lib/remote/disk/BUILD

Copy link

@Chino1307 Chino1307 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/main/java/com/google/devtools/build/lib/remote/disk/DiskCacheClient.java

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.bazelci/postsubmit.yml

"//src/main/java/com/google/devtools/build/lib/vfs",
"//third_party:flogger",
"//third_party:guava",
"//third_party:jsr305",
"//third_party/protobuf:protobuf_java",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.bazelci/postsubmit.yml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-Performance Issues for Performance teams
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants