blob: 4b89be745cdad3c0e9b9ee93b9a3bb45a44ef69a [file] [log] [blame] [view]
Googlerd96c9082018-11-28 09:00:04 -08001---
2layout: documentation
Greg Estrenc0816752020-02-20 13:04:29 -08003title: Debugging remote cache hits for local execution
Googlerd96c9082018-11-28 09:00:04 -08004---
5
Googlera85685a2021-01-08 16:53:49 -08006# Debugging Remote Cache Hits for Local Execution
Googlerd96c9082018-11-28 09:00:04 -08007
8This page describes how to investigate cache misses in the context of local
9execution.
10
11This page assumes that you have a build and/or test that successfully builds
12locally and is set up to utilize remote caching, and that you want to ensure
13that the remote cache is being effectively utilized.
14
Googlerf86ad692021-03-08 11:18:47 -080015For tips on how to check your cache hit rate and how to compare the execution logs between two Bazel invocations, see [Debugging Remote Cache Hits for Remote Execution](/remote-execution-caching-debug.html). Everything presented in that guide also applies to remote caching with local execution. However, local execution presents some additional challenges.
Googlerd96c9082018-11-28 09:00:04 -080016
Googlerd96c9082018-11-28 09:00:04 -080017## Checking your cache hit rate
18
19Successful remote cache hits will show up in the status line, similarly to
20[Cache Hits rate with Remote
Attila Olh4279f842021-02-22 06:13:09 -080021Execution](/remote-execution-caching-debug.html#checking-your-cache-hit-rate).
Googlerd96c9082018-11-28 09:00:04 -080022In the standard output of your Bazel run, you will see something like the
23following:
24
25 INFO: 7 processes: 3 remote cache hit, 4 linux-sandbox.
26
27This means that out of 7 attempted actions, 3 got a remote cache hit and 4
28actions did not have cache hits and were executed locally using `linux-sandbox`
29strategy. Local cache hits are not included in this summary. If you are getting
300 processes (or a number lower than expected), run `bazel clean` followed by
31your build/test command.
32
33## Troubleshooting cache hits
34
35If you are not getting the cache hit rate you are expecting, do the following:
36
37### Ensure successful communication with the remote endpoint
38
39To ensure your build is successfully communicating with the remote cache, follow
40the steps in this section.
41
421. Check your output for warnings
43
44 With remote execution, a failure to talk to the remote endpoint would fail
45 your build. On the other hand, a cacheable local build would not fail if it
46 cannot cache. Check the output of your Bazel invocation for warnings, such
47 as:
48
49 WARNING: Error reading from the remote cache:
50
51 or
52
53 WARNING: Error writing to the remote cache:
54
55 Such warnings will be followed by the error message detailing the connection
56 problem that should help you debug: for example, mistyped endpoint name or
Raidd38d222021-07-28 07:13:29 -070057 incorrectly set credentials. Find and address any such errors. If the error
58 message you see does not give you enough information, try adding
59 `--verbose_failures`.
Googlerd96c9082018-11-28 09:00:04 -080060
612. Follow the steps from [Troubleshooting cache hits for remote
62 execution](/remote-execution-caching-debug.html#troubleshooting-cache-hits) to
63 ensure that your cache-writing Bazel invocations are able to get cache hits
64 on the same machine and across machines.
65
663. Ensure your cache-reading Bazel invocations can get cache hits.
67
68 a. Since cache-reading Bazel invocations will have a different command-line set
69 up, take additional care to ensure that they are properly set up to
ishikhmane038a262019-04-03 07:06:58 -070070 communicate with the remote cache. Ensure the `--remote_cache` flag is set
71 and there are no warnings in the output.
Googlerd96c9082018-11-28 09:00:04 -080072
73 b. Ensure your cache-reading Bazel invocations build the same targets as the
74 cache-writing Bazel invocations.
75
76 c. Follow the same steps as to [ensure caching across
77 machines](/remote-execution-caching-debug.html#ensure-caching-across-machines),
78 to ensure caching from your cache-writing Bazel invocation to your
79 cache-reading Bazel invocation.
80