From 2d1186b48c6c7d6bad1d30727b8dd4d05c84688c Mon Sep 17 00:00:00 2001 From: twerth Date: Tue, 19 Feb 2019 03:12:34 -0800 Subject: [PATCH] Add instrumentation for genquery. RELNOTES: None PiperOrigin-RevId: 234571640 --- .../devtools/build/lib/rules/genquery/BUILD | 1 + .../build/lib/rules/genquery/GenQuery.java | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/rules/genquery/BUILD b/src/main/java/com/google/devtools/build/lib/rules/genquery/BUILD index b8ecac2480e570..34924523159507 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/genquery/BUILD +++ b/src/main/java/com/google/devtools/build/lib/rules/genquery/BUILD @@ -23,6 +23,7 @@ java_library( "//src/main/java/com/google/devtools/build/lib/actions", "//src/main/java/com/google/devtools/build/lib/collect/nestedset", "//src/main/java/com/google/devtools/build/lib/concurrent", + "//src/main/java/com/google/devtools/build/lib/profiler", "//src/main/java/com/google/devtools/build/lib/query2", "//src/main/java/com/google/devtools/build/lib/query2:query-engine", "//src/main/java/com/google/devtools/build/lib/query2:query-output", diff --git a/src/main/java/com/google/devtools/build/lib/rules/genquery/GenQuery.java b/src/main/java/com/google/devtools/build/lib/rules/genquery/GenQuery.java index 3d2f611dbcb43a..b6808a1dadcf1e 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/genquery/GenQuery.java +++ b/src/main/java/com/google/devtools/build/lib/rules/genquery/GenQuery.java @@ -55,6 +55,8 @@ import com.google.devtools.build.lib.pkgcache.FilteringPolicies; import com.google.devtools.build.lib.pkgcache.PackageProvider; import com.google.devtools.build.lib.pkgcache.TargetPatternPreloader; +import com.google.devtools.build.lib.profiler.Profiler; +import com.google.devtools.build.lib.profiler.SilentCloseable; import com.google.devtools.build.lib.query2.BlazeQueryEnvironment; import com.google.devtools.build.lib.query2.QueryEnvironmentFactory; import com.google.devtools.build.lib.query2.engine.DigraphQueryEvalResult; @@ -151,12 +153,16 @@ public ConfiguredTarget create(RuleContext ruleContext) // force relative_locations to true so it has a deterministic output across machines. queryOptions.relativeLocations = true; - ByteString result = - executeQuery( - ruleContext, - queryOptions, - ruleContext.attributes().get("scope", BuildType.LABEL_LIST), - query); + ByteString result; + try (SilentCloseable c = + Profiler.instance().profile("GenQuery.executeQuery/" + ruleContext.getLabel())) { + result = + executeQuery( + ruleContext, + queryOptions, + ruleContext.attributes().get("scope", BuildType.LABEL_LIST), + query); + } if (result == null || ruleContext.hasErrors()) { return null; }