Skip to content

Commit

Permalink
Add instrumentation for genquery.
Browse files Browse the repository at this point in the history
RELNOTES: None
PiperOrigin-RevId: 234571640
  • Loading branch information
meisterT authored and copybara-github committed Feb 19, 2019
1 parent 2310b1c commit 2d1186b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 2d1186b

Please sign in to comment.