Skip to content

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

Closed

Description

@jmillikin-stripe

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.

Activity

  1. jmillikin-stripe commented on Jun 1, 2018

    @jmillikin-stripe
    ContributorAuthor

    Related to (possible duplicate of?) #4595

  2. ittaiz commented on Jun 1, 2018

    @ittaiz
    Member

    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

  3. jmillikin-stripe commented on Jun 6, 2018

    @jmillikin-stripe
    ContributorAuthor

    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.

  4. buchgr commented on Jun 6, 2018

    @buchgr
    Contributor

    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.

  5. ittaiz commented on Jun 6, 2018

    @ittaiz
    Member

    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

  6. added a commit that references this issue on Jun 6, 2018
    0b7924a
  7. jmillikin-stripe commented on Jun 6, 2018

    @jmillikin-stripe
    ContributorAuthor

    @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.

  8. ittaiz commented on Jun 6, 2018

    @ittaiz
    Member
  9. jmillikin-stripe commented on Jun 6, 2018

    @jmillikin-stripe
    ContributorAuthor

    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.

  10. ittaiz commented on Jun 6, 2018

    @ittaiz
    Member

    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?

  11. jmillikin-stripe commented on Jun 6, 2018

    @jmillikin-stripe
    ContributorAuthor

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

  12. ittaiz commented on Jun 6, 2018

    @ittaiz
    Member
  13. 1 remaining item

  14. dslomov commented on Jun 7, 2018

    @dslomov
    Contributor

    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)
  15. self-assigned this
    on Jun 7, 2018
  16. added a commit that references this issue on Jun 7, 2018
    4dfb07d
  17. jmillikin-stripe commented on Jun 7, 2018

    @jmillikin-stripe
    ContributorAuthor

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

  18. ittaiz commented on Jun 7, 2018

    @ittaiz
    Member

    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.

  19. ulfjack commented on Jun 8, 2018

    @ulfjack
    Contributor

    @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.

  20. added a commit that references this issue on Jun 8, 2018
  21. added a commit that references this issue on Jun 8, 2018
    e565f24
  22. added a commit that references this issue on Jun 20, 2018
  23. added a commit that references this issue on Jun 26, 2018
    76d62a5
  24. added 2 commits that reference this issue on Aug 2, 2018
    d4cae6e
    6ec17ac
  25. or-shachar commented on Oct 10, 2018

    @or-shachar
    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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions