Update RBE platform

 - Use the docker container from gcr.io/bazel-untrusted/ubuntu1604_bazel_rbe
   which was built specifically for Bazel's tests on RBE.
 - Introduce a highcpu_machine constraint in order to map heavy tests to
 beefy RBE workers.
 - Add the highcpu_machine constraints to heavy test targets.

Progress towards #8033

Closes #8062.

PiperOrigin-RevId: 243829775
diff --git a/BUILD b/BUILD
index c0f94f3..8394e66 100644
--- a/BUILD
+++ b/BUILD
@@ -124,11 +124,32 @@
     visibility = ["//visibility:public"],
 )
 
+constraint_setting(name = "machine_size")
+
+# A machine with "high cpu count".
+constraint_value(
+    name = "highcpu_machine",
+    constraint_setting = ":machine_size",
+    visibility = ["//visibility:public"],
+)
+
 platform(
-    name = "rbe_ubuntu1604_with_network_and_privileged",
-    parents = ["@bazel_toolchains//configs/ubuntu16_04_clang/latest:platform"],
+    name = "default_host_platform",
+    constraint_values = [
+        ":highcpu_machine",
+    ],
+    parents = ["@bazel_tools//platforms:host_platform"],
+)
+
+# The default RBE platform where most actions run on
+platform(
+    name = "rbe_ubuntu1604_default",
+    parents = ["@bazel_toolchains//configs/ubuntu16_04_clang/1.2:rbe_ubuntu1604"],
     remote_execution_properties = """
-        {PARENT_REMOTE_EXECUTION_PROPERTIES}
+        properties: {
+          name: "container-image"
+          value:"docker://gcr.io/bazel-untrusted/ubuntu1604_bazel_rbe@sha256:b60b641427ca8aa99134cc1f9889e3349e391eed85854b5cfbb462884ec3420b"
+        }
         properties: {
           name: "dockerNetwork"
           value: "standard"
@@ -139,3 +160,20 @@
         }
         """,
 )
+
+# The highcpu RBE platform where heavy actions run on. In order to
+# use this platform add the highcpu_machine constraint to your target.
+platform(
+    name = "rbe_ubuntu1604_highcpu",
+    constraint_values = [
+        ":highcpu_machine",
+    ],
+    parents = [":rbe_ubuntu1604_default"],
+    remote_execution_properties = """
+        {PARENT_REMOTE_EXECUTION_PROPERTIES}
+        properties: {
+          name: "gceMachineType"
+          value: "n1-highcpu-32"
+        }
+        """,
+)
diff --git a/WORKSPACE b/WORKSPACE
index 93465e2..5f03fb4 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -277,13 +277,13 @@
 )
 
 http_archive(
-    name = "bazel_toolchains",
-    sha256 = "4b1468b254a572dbe134cc1fd7c6eab1618a72acd339749ea343bd8f55c3b7eb",
-    strip_prefix = "bazel-toolchains-d665ccfa3e9c90fa789671bf4ef5f7c19c5715c4",
-    urls = [
-        "https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/d665ccfa3e9c90fa789671bf4ef5f7c19c5715c4.tar.gz",
-        "https://github.com/bazelbuild/bazel-toolchains/archive/d665ccfa3e9c90fa789671bf4ef5f7c19c5715c4.tar.gz",
-    ],
+  name = "bazel_toolchains",
+  sha256 = "67335b3563d9b67dc2550b8f27cc689b64fadac491e69ce78763d9ba894cc5cc",
+  strip_prefix = "bazel-toolchains-cddc376d428ada2927ad359211c3e356bd9c9fbb",
+  urls = [
+    "https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/cddc376d428ada2927ad359211c3e356bd9c9fbb.tar.gz",
+    "https://github.com/bazelbuild/bazel-toolchains/archive/cddc376d428ada2927ad359211c3e356bd9c9fbb.tar.gz",
+  ],
 )
 
 # Creates toolchain configuration for remote execution with BuildKite CI
@@ -461,3 +461,5 @@
 load("@io_bazel_rules_sass//:defs.bzl", "sass_repositories")
 
 sass_repositories()
+
+register_execution_platforms("//:default_host_platform"); # buildozer: disable=positional-args
diff --git a/src/test/shell/bazel/BUILD b/src/test/shell/bazel/BUILD
index b8536ca..94c7075 100644
--- a/src/test/shell/bazel/BUILD
+++ b/src/test/shell/bazel/BUILD
@@ -175,6 +175,7 @@
     size = "large",  # Downloads and compiles protobuf for *every* *test* *case*
     srcs = ["bazel_proto_library_test.sh"],
     data = [":test-deps"],
+    exec_compatible_with = ["//:highcpu_machine"],
     tags = ["no_windows"],  # Doesn't work on Windows for unknown reason
 )
 
@@ -406,6 +407,7 @@
         "//src/test/shell/bazel/testdata:git-repos",
         "@bazel_tools//tools/bash/runfiles",
     ],
+    exec_compatible_with = ["//:highcpu_machine"],
 )
 
 sh_test(
@@ -697,6 +699,7 @@
         "//src:embedded_jdk_allmodules_cached",
         "@bazel_tools//tools/bash/runfiles",
     ],
+    exec_compatible_with = ["//:highcpu_machine"],
     tags = ["block-network"],
 )
 
@@ -709,6 +712,7 @@
         ":test-deps",
         "//:bazel-distfile",
     ],
+    exec_compatible_with = ["//:highcpu_machine"],
     tags = [
         "no_windows",
         "slow",
diff --git a/src/tools/singlejar/BUILD b/src/tools/singlejar/BUILD
index 8784beb..2cf4acb 100644
--- a/src/tools/singlejar/BUILD
+++ b/src/tools/singlejar/BUILD
@@ -109,6 +109,8 @@
         ":zip_headers",
         ":zlib_interface",
     ],
+    # Requires at least 5 GiB of memory
+    exec_compatible_with = ["//:highcpu_machine"],
     deps = [
         ":combiners",
         ":input_jar",