use of com.google.devtools.build.lib.profiler.AutoProfiler in project bazel by bazelbuild.
the class ExecutionTool method saveCaches.
/**
* Writes the cache files to disk, reporting any errors that occurred during
* writing.
*/
private void saveCaches(ActionCache actionCache) {
long actionCacheSizeInBytes = 0;
long actionCacheSaveTimeInMs;
AutoProfiler p = AutoProfiler.profiledAndLogged("Saving action cache", ProfilerTask.INFO, log);
try {
actionCacheSizeInBytes = actionCache.save();
} catch (IOException e) {
getReporter().handle(Event.error("I/O error while writing action log: " + e.getMessage()));
} finally {
actionCacheSaveTimeInMs = MILLISECONDS.convert(p.completeAndGetElapsedTimeNanos(), NANOSECONDS);
}
env.getEventBus().post(new CachesSavedEvent(actionCacheSaveTimeInMs, actionCacheSizeInBytes));
}
use of com.google.devtools.build.lib.profiler.AutoProfiler in project bazel by bazelbuild.
the class ExecutionTool method startLocalOutputBuild.
/**
* Prepare for a local output build.
*/
private void startLocalOutputBuild(String workspaceName) throws ExecutorInitException {
try (AutoProfiler p = AutoProfiler.profiled("Starting local output build", ProfilerTask.INFO)) {
Path outputPath = env.getDirectories().getOutputPath(workspaceName);
Path localOutputPath = env.getDirectories().getLocalOutputPath();
if (outputPath.isSymbolicLink()) {
try {
// Remove the existing symlink first.
outputPath.delete();
if (localOutputPath.exists()) {
// Pre-existing local output directory. Move to outputPath.
localOutputPath.renameTo(outputPath);
}
} catch (IOException e) {
throw new ExecutorInitException("Couldn't handle local output directory symlinks", e);
}
}
}
}
use of com.google.devtools.build.lib.profiler.AutoProfiler in project bazel by bazelbuild.
the class SkyQueryEnvironment method beforeEvaluateQuery.
private void beforeEvaluateQuery() throws InterruptedException {
if (graph == null || !graphFactory.isUpToDate(universeKey)) {
// If this environment is uninitialized or the graph factory needs to evaluate, do so. We
// assume here that this environment cannot be initialized-but-stale if the factory is up
// to date.
EvaluationResult<SkyValue> result;
try (AutoProfiler p = AutoProfiler.logged("evaluation and walkable graph", LOG)) {
result = graphFactory.prepareAndGet(universeKey, loadingPhaseThreads, universeEvalEventHandler);
}
checkEvaluationResult(result);
packageSemaphore = makeFreshPackageMultisetSemaphore();
graph = result.getWalkableGraph();
blacklistPatternsSupplier = InterruptibleSupplier.Memoize.of(new BlacklistSupplier(graph));
graphBackedRecursivePackageProvider = new GraphBackedRecursivePackageProvider(graph, universeTargetPatternKeys, pkgPath);
}
if (executor == null) {
executor = MoreExecutors.listeningDecorator(new ThreadPoolExecutor(/*corePoolSize=*/
queryEvaluationParallelismLevel, /*maximumPoolSize=*/
queryEvaluationParallelismLevel, /*keepAliveTime=*/
1, /*units=*/
TimeUnit.SECONDS, /*workQueue=*/
new BlockingStack<Runnable>(), new ThreadFactoryBuilder().setNameFormat("QueryEnvironment %d").build()));
}
resolver = new RecursivePackageProviderBackedTargetPatternResolver(graphBackedRecursivePackageProvider, eventHandler, TargetPatternEvaluator.DEFAULT_FILTERING_POLICY, packageSemaphore);
}
use of com.google.devtools.build.lib.profiler.AutoProfiler in project bazel by bazelbuild.
the class ResourceManager method releaseResources.
/**
* Releases previously requested resource =.
*
* <p>NB! This method must be thread-safe!
*/
@VisibleForTesting
void releaseResources(ActionExecutionMetadata owner, ResourceSet resources) {
Preconditions.checkNotNull(resources, "releaseResources called with resources == NULL during %s", owner);
Preconditions.checkState(threadHasResources(), "releaseResources without resource lock during %s", owner);
boolean isConflict = false;
AutoProfiler p = profiled(owner, ProfilerTask.ACTION_RELEASE);
try {
isConflict = release(resources);
} finally {
threadLocked.set(false);
// Profile resource release only if it resolved at least one allocation request.
if (isConflict) {
p.complete();
}
}
}
use of com.google.devtools.build.lib.profiler.AutoProfiler in project bazel by bazelbuild.
the class SimpleCycleDetector method checkForCycles.
@Override
public void checkForCycles(Iterable<SkyKey> badRoots, EvaluationResult.Builder<?> result, ParallelEvaluatorContext evaluatorContext) throws InterruptedException {
try (AutoProfiler p = AutoProfiler.logged("Checking for Skyframe cycles", logger, 10)) {
for (SkyKey root : badRoots) {
ErrorInfo errorInfo = checkForCycles(root, evaluatorContext);
if (errorInfo == null) {
// This node just wasn't finished when evaluation aborted -- there were no cycles below
// it.
Preconditions.checkState(!evaluatorContext.keepGoing(), "", root, badRoots);
continue;
}
Preconditions.checkState(!Iterables.isEmpty(errorInfo.getCycleInfo()), "%s was not evaluated, but was not part of a cycle", root);
result.addError(root, errorInfo);
if (!evaluatorContext.keepGoing()) {
return;
}
}
}
}
Aggregations