bazel icon indicating copy to clipboard operation
bazel copied to clipboard

Cache management facilities

Open cgils opened this issue 9 years ago • 24 comments

Please consider adding some way of setting a maximum cache size. At the moment our project's build caches grow unbounded leading to us discarding them periodically.

A facility with which to display cache information would be nice as well. Something like the output of ccache -s, for example:

  cache directory                     /home/user/.ccache
  cache hit (direct)                 34993
  cache hit (preprocessed)             153
  cache miss                         23479
  compile failed                         3
  ccache internal error                  1
  preprocessor error                     1
  cache file missing                     1
  unsupported source language          382
  no input file                       7322
  files in cache                     70445
  cache size                          16.4 Gbytes
  max cache size                      90.0 Gbytes

cgils avatar Mar 12 '16 00:03 cgils

@cgils, are you talking about project "cache" (it is not really a cache, it is just your output directory) or stuff that gets into ~/.cache/bazel?

dslomov avatar Mar 14 '16 14:03 dslomov

Stuff that gets put into ~/.cache/bazel.

cgils avatar Mar 14 '16 16:03 cgils

I vote for this to be higher priority :). Bazel is commonly filling up hard drives on our project from the ~/.cache/bazel directory growing unbounded.

glinscott avatar Apr 29 '16 16:04 glinscott

+1

kavehv avatar Jul 28 '16 18:07 kavehv

+1

jianga avatar Aug 22 '16 20:08 jianga

+1, esp. if the home dir is on NFS.

jiayiliu avatar Mar 31 '17 00:03 jiayiliu

+1

lefromage avatar Apr 05 '17 03:04 lefromage

+1

burnzzz avatar Apr 23 '17 19:04 burnzzz

+1

softprops avatar Apr 23 '17 19:04 softprops

+1

llhe avatar May 15 '18 04:05 llhe

+1

dahlstrom-g avatar Jul 06 '18 15:07 dahlstrom-g

@buchgr

hlopko avatar Jul 10 '18 12:07 hlopko

@jin do you have an idea to which component to assign this issue?

buchgr avatar Jan 16 '19 10:01 buchgr

@buchgr team-Local-Exec sounds like a good fit.

jin avatar Jan 16 '19 14:01 jin

There are several kinds of data to be managed here:

  • Bazel "installation files". This is https://github.com/bazelbuild/bazel/issues/2109 and they should be auto-purged. No question.

  • Output trees. These are just the build artifacts of a given build. They are not a cache. Bazel discarding them automatically is a bad idea as we'd be throwing away people's data. bazel clean removes these on a workspace basis. (I think these files living under ~/.cache/ is also a mistake.)

  • Fetch/remote cache (whatever it's called). bazel fetch can download a lot of stuff and this stuff is shared across workspaces. This is a cache and could be automatically cleaned. However, pruning stuff from here affects the ability to work offline, so I'd be wary of doing that too. It'd be pretty annoying to fetch everything before hopping into a plane, only to discover later that some random stuff was pruned and you cannot do anything any longer.

Separately, having a command to dump all files Bazel knows about, grouped by category/project and with a summary of their size, would be awesome. Tag each entry with an ID so you can tell bazel clean some-id and it'd be even better.

jmmv avatar Jan 24 '19 20:01 jmmv

+1

edrumwri avatar Feb 03 '19 15:02 edrumwri

Per #2765, one more thing to consider if implementing a smarter clean command is bazel clean //target. Noting here because this would possibly conflict with the bazel clean some-id proposal above.

jmmv avatar Mar 14 '19 10:03 jmmv

+1

ozio85 avatar Feb 21 '20 15:02 ozio85

+1

jonatanj avatar Feb 21 '20 15:02 jonatanj

It had been some time since 2016, it'd be great for this to get higher priority.

To give some context, I'm on 2TB drive and have to keep fighting with Bazel for living space. My ~/.cache/bazel is consistently eating up to 0.7TB of free space (in 2-3 weeks). I have to purge it then. And that results in multi-GB downloads (CUDA, etc).

It'd be great to add a limit and an LRU-type of behavior to the cache. Alternative - remove "{Fast, Correct} - Choose two" advertisement from the web page. Eating all the space on the disk is not correct. Making a user to purge cache completely is not fast.

dchichkov avatar Apr 03 '21 01:04 dchichkov

This issue should really be P1, not P2. It is extremely bad that on my system there have been nearly a million files generated in the ~/.cache that aren't automatically cleared.

On many personal computers, people might just not realize this is happening, and have their entire filesystem slowed down due to the additional effort needed by their system to index everything.

Then, on some shared computers where there are hard file limit constraints, bazel is effectively unusable because it generates so many files. (This is the only reason I noticed this in the first place – otherwise I would have just had a slower filesystem without knowing why)

MilesCranmer avatar Jan 31 '23 21:01 MilesCranmer

+1

Ryang20718 avatar Apr 24 '23 18:04 Ryang20718

+1

gosha-frost avatar Jul 20 '23 14:07 gosha-frost

+1

StilesCrisis avatar Sep 01 '23 19:09 StilesCrisis

We acknowledge the problem discussed here; however, for the sake of clarity, I'm going to close this issue in favor of the following narrower-scoped ones:

https://github.com/bazelbuild/bazel/issues/2109 https://github.com/bazelbuild/bazel/issues/5139 https://github.com/bazelbuild/bazel/issues/22515 https://github.com/bazelbuild/bazel/issues/22516

tjgq avatar May 23 '24 17:05 tjgq