|
| 1 | +# Copyright 2019 The Bazel Authors. All rights reserved. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +"Helpers for copy rules" |
| 16 | + |
| 17 | +# Hints for Bazel spawn strategy |
| 18 | +COPY_EXECUTION_REQUIREMENTS = { |
| 19 | + # ----------------+----------------------------------------------------------------------------- |
| 20 | + # no-remote | Prevents the action or test from being executed remotely or cached remotely. |
| 21 | + # | This is equivalent to using both `no-remote-cache` and `no-remote-exec`. |
| 22 | + # ----------------+----------------------------------------------------------------------------- |
| 23 | + # no-remote-cache | Results in the action or test never being cached remotely (but it may |
| 24 | + # | be cached locally; it may also be executed remotely). Note: for the purposes |
| 25 | + # | of this tag, the disk-cache is considered a local cache, whereas the http |
| 26 | + # | and gRPC caches are considered remote. If a combined cache is specified |
| 27 | + # | (i.e. a cache with local and remote components), it's treated as a remote |
| 28 | + # | cache and disabled entirely unless --incompatible_remote_results_ignore_disk |
| 29 | + # | is set in which case the local components will be used. |
| 30 | + # ----------------+----------------------------------------------------------------------------- |
| 31 | + # no-remote-exec | Results in the action or test never being executed remotely (but it may be |
| 32 | + # | cached remotely). |
| 33 | + # ----------------+----------------------------------------------------------------------------- |
| 34 | + # no-cache | Results in the action or test never being cached (remotely or locally) |
| 35 | + # ----------------+----------------------------------------------------------------------------- |
| 36 | + # no-sandbox | Results in the action or test never being sandboxed; it can still be cached |
| 37 | + # | or run remotely - use no-cache or no-remote to prevent either or both of |
| 38 | + # | those. |
| 39 | + # ----------------+----------------------------------------------------------------------------- |
| 40 | + # local | Precludes the action or test from being remotely cached, remotely executed, |
| 41 | + # | or run inside the sandbox. For genrules and tests, marking the rule with the |
| 42 | + # | local = True attribute has the same effect. |
| 43 | + # ----------------+----------------------------------------------------------------------------- |
| 44 | + # See https://bazel.google.cn/reference/be/common-definitions?hl=en&authuser=0#common-attributes |
| 45 | + # |
| 46 | + # Copying file & directories is entirely IO-bound and there is no point doing this work |
| 47 | + # remotely. |
| 48 | + # |
| 49 | + # Also, remote-execution does not allow source directory inputs, see |
| 50 | + # https://github.com/bazelbuild/bazel/commit/c64421bc35214f0414e4f4226cc953e8c55fa0d2 So we must |
| 51 | + # not attempt to execute remotely in that case. |
| 52 | + # |
| 53 | + # There is also no point pulling the output file or directory from the remote cache since the |
| 54 | + # bytes to copy are already available locally. Conversely, no point in writing to the cache if |
| 55 | + # no one has any reason to check it for this action. |
| 56 | + # |
| 57 | + # Read and writing to disk cache is disabled as well primarily to reduce disk usage on the local |
| 58 | + # machine. A disk cache hit of a directory copy could be slghtly faster than a copy since the |
| 59 | + # disk cache stores the directory artifact as a single entry, but the slight performance bump |
| 60 | + # comes at the cost of heavy disk cache usage, which is an unmanaged directory that grow beyond |
| 61 | + # the bounds of the physical disk. |
| 62 | + # TODO: run benchmarks to measure the impact on copy_directory |
| 63 | + # |
| 64 | + # Sandboxing for this action is wasteful as well since there is a 1:1 mapping of input |
| 65 | + # file/directory to output file/directory and no room for non-hermetic inputs to sneak in to the |
| 66 | + # input. |
| 67 | + "no-remote": "1", |
| 68 | + "no-remote-cache": "1", |
| 69 | + "no-remote-exec": "1", |
| 70 | + "no-cache": "1", |
| 71 | + "no-sandbox": "1", |
| 72 | + "local": "1", |
| 73 | +} |
0 commit comments