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

0.14 has no way to unset --disk_cache flag (interferes with remote build testing) #5308

Closed
jmillikin-stripe opened this issue Jun 1, 2018 · 17 comments

Comments

@jmillikin-stripe
Copy link
Contributor

Description of the problem / feature request:

The local disk cache and remote execution action strategy are incompatible -- if both are enabled in flags or bazelrc, Bazel will refuse to run.

In 0.13, disk caching is controlled by --experimental_local_disk_cache_path (string) and --experimental_local_disk_cache (bool). It was possible to enable caching in /etc/bazel.bazelrc, and disable it in a project's tools/bazel.rc for testing remote execution.

In 0.14 the flags were unified into --disk_cache (string) which is definitely nicer, but provides no mechanism to disable the disk cache in a project's local bazelrc. The check for "disk cache enabled?" is whether the diskCache option is not null, which is true if the flag has ever been set to anything.

This makes it very difficult to work with remote builds in 0.14 when running in a build environment with a standard cross-project /etc/bazel.bazelrc.

It would be nice if an empty value could also be considered "disk cache not enabled", so passing an empty string like bazel build --disk-cache= //... would work.

@jmillikin-stripe
Copy link
Contributor Author

Related to (possible duplicate of?) #4595

@ittaiz
Copy link
Member

ittaiz commented Jun 1, 2018

Actually I’d like to suggest that the empty string will mean bazel uses a sensible default (like external dependencies cache) and will be on by default.
I agree there still needs to be a way to turn it off and in addition I think the real issue is the clash between the two cached.
I know @buchgr is working on an interim solution for this problem

@jmillikin-stripe
Copy link
Contributor Author

Gentle ping -- this is kinda important for us (Stripe) because we're canarying remote execution in some of our larger builds, and we can't upgrade Bazel to 0.14 or later if doing so will break the remote execution flags.

@buchgr
Copy link
Contributor

buchgr commented Jun 6, 2018

I am currently on vacation until the 18th of June. I have totally missed that use case. I‘d be happy to fix that then or you can submit a PR and @laurentlb can cherry pick that into 0.15 (I think?).

Both /dev/null and the empty string sound good to me.

@ittaiz
Copy link
Member

ittaiz commented Jun 6, 2018

I’d really ask reserving the empty string to mean working in a default location (like the external dependencies cache).
@jmillikin-stripe,
Have you considered composing bazelrc files? That’s what we do. We have a baserc and then a remoterc/.bazelrc which both import the baserc (has 95% if content). Then when we run the builds in CI with remote execution we explicitly specify the remoterc as the one to use.

This doesn’t mean I don’t think we need to solve this issue (toggle off / unifying the behavior like what @buchgr started to work on) but I wonder if you can’t unblock yourself for the time being

jmillikin-stripe added a commit to jmillikin-stripe/bazel that referenced this issue Jun 6, 2018
This fixes a regression from v0.13. When the local disk cache flags were
unified into `--disk_cache`, it became impossible to override a default
cache location such that the cache became disabled. This prevents
canarying of remote execution in the presence of a default bazelrc that
enables the disk cache.

Fixes bazelbuild#5308
@jmillikin-stripe
Copy link
Contributor Author

@buchgr OK, sent #5338 to treat an empty disk cache path the same as being unset.

@ittaiz I think we might be talking about different things. There is no meaningful "default location" for the SimpleBlobStore enabled by --disk_cache. And composing bazelrcs doesn't help when the presence of a flag in an "earlier" bazelrc will cause another flag to become invalid regardless of later overrides.

@ittaiz
Copy link
Member

ittaiz commented Jun 6, 2018 via email

@jmillikin-stripe
Copy link
Contributor Author

Why do you think there’s no meaningful default location for the disk cache?

Because if I run bazel build //:foo, the local disk cache is not enabled or used.

My point about composition is that the disk cache options only exist in the
.bazelrc which doesn’t get evaluated when you run in CI

If my CI system has a /etc/bazel.bazelrc that contains build --disk_cache=/some/cache/dir, and my project is canarying remote execution with its tools/bazel.rc containing build --spawn_strategy=remote, then Bazel will fail with an error about conflicting flags. In Bazel 0.14.0, with this setup, there is no possible way to override the --disk_cache flag in the project's bazelrc such that remote execution will work.

@ittaiz
Copy link
Member

ittaiz commented Jun 6, 2018

Re default- what I meant is running “bazel build —disk_cache= //:foo” (in actuality —disk_cache is specified in the project bazelrc). The reason to use this notation is because different operating systems might have different options for where to store it and Bazel people prefer not to allow ~ in the options.

Re unset- I now understand the difference in perspectives. I was thinking about only Dev machines using this flag while CI using only remote so my composition idea works.

Wdyt about adding another flag to unset it?

@jmillikin-stripe
Copy link
Contributor Author

In your model, how would the behavior of bazel build --unset_disk_cache_flag //:foo and bazel build --disk_cache= //:foo be different?

@ittaiz
Copy link
Member

ittaiz commented Jun 6, 2018 via email

@ulfjack
Copy link
Contributor

ulfjack commented Jun 7, 2018

I don't think the empty string should turn on the disk cache, that seems rather confusing. Note that we do always use the action cache by default, which is also on disk.

The difference between the disk cache and the action cache is that the disk cache contains full copies of all the files in your build, increasing on-disk footprint by at least a factor of 2, or more if you want it to be actually useful. As such, I don't see us enabling it by default.

@dslomov
Copy link
Contributor

dslomov commented Jun 7, 2018

In the interest of time, here is the resolution:

  • in 0.14.1 and 0.15 we will accept Allow disabling the simple blob caches via CLI flag overrides. #5338. Empty value for --disk_cache disables disk cache.
  • going forward (I guess 0.16 and beyond) we will introduce a boolean --enable_disk_cache flag, off by default that will by default use some default location for disk cache. That location will be overridable with --disk_cache flag. --enable_disk_cache will enable disk cache even if --disk_cache= (empty string) is supplied (in that case, default location is used)

@dslomov dslomov self-assigned this Jun 7, 2018
dslomov pushed a commit that referenced this issue Jun 7, 2018
This fixes a regression from v0.13. When the local disk cache flags were
unified into `--disk_cache`, it became impossible to override a default
cache location such that the cache became disabled. This prevents
canarying of remote execution in the presence of a default bazelrc that
enables the disk cache.

Fixes #5308

Closes #5338.

PiperOrigin-RevId: 199613922
@jmillikin-stripe
Copy link
Contributor Author

Ulf, Dmitry, thank you both for the quick response and the patch cherrypick!

@ittaiz
Copy link
Member

ittaiz commented Jun 7, 2018

Thanks @dslomov!
I think this resolution is indeed in everyone’s best interest.
@ulfjack the action cache is almost irrelevant when working without remote execution and on a developer machine (between branches for example). You can also see it from the issues people opened in this repo to have this support.

@ulfjack
Copy link
Contributor

ulfjack commented Jun 8, 2018

@ittaiz - I understand that - I have the disk cache enabled myself -, but I'm not sure that's the common case across all Bazel users, and I am concerned about the increase in disk usage in the case where users just checkout a single source tree and build it once or twice. I think the disk usage increase is amortized if you have multiple checkouts for the same code base.

bazel-io pushed a commit that referenced this issue Jun 8, 2018
Baseline: 5c3f5c9

Cherry picks:
   + f96f037:
     Windows, Java launcher: Support jar files under different drives
   + ff8162d:
     sh_configure.bzl: FreeBSD is also a known platform
   + 7092ed3:
     Remove unneeded exec_compatible_with from local_sh_toolchain
   + 57bc201:
     Do not autodetect C++ toolchain when
     BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 is present
   + 35a78c0:
     remote: recursively delete incomplete downloaded output
     directory.
   + 3c9cd82:
     distfile: pack the archives needed later in the build
   + 27487c7:
     Slightly refactor SpawnAction to improve env handling
   + 1b333a2:
     Fix Cpp{Compile,Link}Action environment and cache key computation
   + 3da8929:
     Make SymlinkTreeAction properly use the configuration's
     environment
   + eca7b81:
     Add a missing dependency from checker framework dataflow to
     javacutils
   + 10a4de9:
     Release 0.14.0 (2018-06-01)
   + 4b80f24:
     Add option to enable Docker sandboxing.
   + 6b16352:
     Allow disabling the simple blob caches via CLI flag overrides.

Bug fix for [#5336](#5336)
Bug fix fot [#5308](#5308)
laurentlb pushed a commit that referenced this issue Jun 8, 2018
This fixes a regression from v0.13. When the local disk cache flags were
unified into `--disk_cache`, it became impossible to override a default
cache location such that the cache became disabled. This prevents
canarying of remote execution in the presence of a default bazelrc that
enables the disk cache.

Fixes #5308

Closes #5338.

PiperOrigin-RevId: 199613922
excitoon pushed a commit to excitoon-favorites/bazel that referenced this issue Jun 20, 2018
Baseline: 5c3f5c9

Cherry picks:
   + f96f037:
     Windows, Java launcher: Support jar files under different drives
   + ff8162d:
     sh_configure.bzl: FreeBSD is also a known platform
   + 7092ed3:
     Remove unneeded exec_compatible_with from local_sh_toolchain
   + 57bc201:
     Do not autodetect C++ toolchain when
     BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 is present
   + 35a78c0:
     remote: recursively delete incomplete downloaded output
     directory.
   + 3c9cd82:
     distfile: pack the archives needed later in the build
   + 27487c7:
     Slightly refactor SpawnAction to improve env handling
   + 1b333a2:
     Fix Cpp{Compile,Link}Action environment and cache key computation
   + 3da8929:
     Make SymlinkTreeAction properly use the configuration's
     environment
   + eca7b81:
     Add a missing dependency from checker framework dataflow to
     javacutils
   + 10a4de9:
     Release 0.14.0 (2018-06-01)
   + 4b80f24:
     Add option to enable Docker sandboxing.
   + 6b16352:
     Allow disabling the simple blob caches via CLI flag overrides.

Bug fix for [bazelbuild#5336](bazelbuild#5336)
Bug fix fot [bazelbuild#5308](bazelbuild#5308)
robfig pushed a commit to yext/bazel that referenced this issue Jun 26, 2018
This fixes a regression from v0.13. When the local disk cache flags were
unified into `--disk_cache`, it became impossible to override a default
cache location such that the cache became disabled. This prevents
canarying of remote execution in the presence of a default bazelrc that
enables the disk cache.

Fixes bazelbuild#5308

Closes bazelbuild#5338.

PiperOrigin-RevId: 199613922
werkt pushed a commit to werkt/bazel that referenced this issue Aug 2, 2018
This fixes a regression from v0.13. When the local disk cache flags were
unified into `--disk_cache`, it became impossible to override a default
cache location such that the cache became disabled. This prevents
canarying of remote execution in the presence of a default bazelrc that
enables the disk cache.

Fixes bazelbuild#5308

Closes bazelbuild#5338.

PiperOrigin-RevId: 199613922
werkt pushed a commit to werkt/bazel that referenced this issue Aug 2, 2018
Baseline: 5c3f5c9

Cherry picks:
   + f96f037:
     Windows, Java launcher: Support jar files under different drives
   + ff8162d:
     sh_configure.bzl: FreeBSD is also a known platform
   + 7092ed3:
     Remove unneeded exec_compatible_with from local_sh_toolchain
   + 57bc201:
     Do not autodetect C++ toolchain when
     BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 is present
   + 35a78c0:
     remote: recursively delete incomplete downloaded output
     directory.
   + 3c9cd82:
     distfile: pack the archives needed later in the build
   + 27487c7:
     Slightly refactor SpawnAction to improve env handling
   + 1b333a2:
     Fix Cpp{Compile,Link}Action environment and cache key computation
   + 3da8929:
     Make SymlinkTreeAction properly use the configuration's
     environment
   + eca7b81:
     Add a missing dependency from checker framework dataflow to
     javacutils
   + 10a4de9:
     Release 0.14.0 (2018-06-01)
   + 4b80f24:
     Add option to enable Docker sandboxing.
   + 6b16352:
     Allow disabling the simple blob caches via CLI flag overrides.

Bug fix for [bazelbuild#5336](bazelbuild#5336)
Bug fix fot [bazelbuild#5308](bazelbuild#5308)
@or-shachar
Copy link
Contributor

@dslomov - seems like the --enable_disk_cache flag is not there in 0.17.2.
Currently we disable it by overriding disk_cache with empty value. Is this the final solution for this or should we follow some other issue or PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants