From 5b7b7daa425ffc93e98c12cbd37ea7b15a8bcc8d Mon Sep 17 00:00:00 2001 From: Adin Scannell Date: Mon, 26 Apr 2021 11:40:10 -0700 Subject: nogo: enable bazel workers and other optimizations. This is a suite of changes intended to dramatically speed up nogo speed. First, there are minor changes that help efficiency significantly. * Gob-based encoding is used internally, and JSON only used for the final set of findings. This is done to preserve the existing format (which is consumed by external tooling), and to facilitate manual debugging. * Unnecessary regex compilation is elided in the configuration, and care is taken for merges to prevent redundant entries. I'm not sure quite sure how, but it turns out that this was consumed a significant amount of time, presumably compiling the same regexes over and over again. Second, this change enables bazel workers for nogo analyzers. Workers enable persistent processes instead of creating and tearing down a sandbox every invocation. A library is introduced to abstraction these details, and allow the tools to still be written using standard flags, etc. The key here is that these binaries and the core of nogo become aware of caches with worker.Cache. This allows us to save significant time loading the same set of files and findings over and over again. These caches are keyed by the digests that are provided by bazel, and are capped in overall size. Note that the worker package attempts to capture output during each run, but tools are no longer permitted to write to stdout. This necessitated dropping some spurious output from checklocks. PiperOrigin-RevId: 370505732 --- tools/bazeldefs/go.bzl | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tools/bazeldefs/go.bzl') diff --git a/tools/bazeldefs/go.bzl b/tools/bazeldefs/go.bzl index d16376032..da027846b 100644 --- a/tools/bazeldefs/go.bzl +++ b/tools/bazeldefs/go.bzl @@ -8,8 +8,13 @@ load("//tools/bazeldefs:defs.bzl", "select_arch", "select_system") gazelle = _gazelle go_embed_data = _go_embed_data go_path = _go_path +bazel_worker_proto = "//tools/bazeldefs:worker_protocol_go_proto" def _go_proto_or_grpc_library(go_library_func, name, **kwargs): + if "importpath" in kwargs: + # If importpath is explicit, pass straight through. + go_library_func(name = name, **kwargs) + return deps = [ dep.replace("_proto", "_go_proto") for dep in (kwargs.pop("deps", []) or []) -- cgit v1.2.3