Search in sources :

Example 1 with AutoProfiler

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));
}
Also used : AutoProfiler(com.google.devtools.build.lib.profiler.AutoProfiler) IOException(java.io.IOException)

Example 2 with AutoProfiler

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);
            }
        }
    }
}
Also used : Path(com.google.devtools.build.lib.vfs.Path) AutoProfiler(com.google.devtools.build.lib.profiler.AutoProfiler) IOException(java.io.IOException) ExecutorInitException(com.google.devtools.build.lib.actions.ExecutorInitException)

Example 3 with AutoProfiler

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);
}
Also used : SkyValue(com.google.devtools.build.skyframe.SkyValue) RecursivePackageProviderBackedTargetPatternResolver(com.google.devtools.build.lib.skyframe.RecursivePackageProviderBackedTargetPatternResolver) GraphBackedRecursivePackageProvider(com.google.devtools.build.lib.skyframe.GraphBackedRecursivePackageProvider) AutoProfiler(com.google.devtools.build.lib.profiler.AutoProfiler) ThreadFactoryBuilder(com.google.common.util.concurrent.ThreadFactoryBuilder) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor)

Example 4 with AutoProfiler

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();
        }
    }
}
Also used : AutoProfiler(com.google.devtools.build.lib.profiler.AutoProfiler) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 5 with AutoProfiler

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;
            }
        }
    }
}
Also used : AutoProfiler(com.google.devtools.build.lib.profiler.AutoProfiler)

Aggregations

AutoProfiler (com.google.devtools.build.lib.profiler.AutoProfiler)9 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)2 SkyValue (com.google.devtools.build.skyframe.SkyValue)2 IOException (java.io.IOException)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Stopwatch (com.google.common.base.Stopwatch)1 ActionGraph (com.google.devtools.build.lib.actions.ActionGraph)1 Artifact (com.google.devtools.build.lib.actions.Artifact)1 BuildFailedException (com.google.devtools.build.lib.actions.BuildFailedException)1 ExecutorInitException (com.google.devtools.build.lib.actions.ExecutorInitException)1 TestExecException (com.google.devtools.build.lib.actions.TestExecException)1 ActionCache (com.google.devtools.build.lib.actions.cache.ActionCache)1 ConfiguredTarget (com.google.devtools.build.lib.analysis.ConfiguredTarget)1 BuildConfiguration (com.google.devtools.build.lib.analysis.config.BuildConfiguration)1 ExecutionStartingEvent (com.google.devtools.build.lib.buildtool.buildevent.ExecutionStartingEvent)1 ThrowableRecordingRunnableWrapper (com.google.devtools.build.lib.concurrent.ThrowableRecordingRunnableWrapper)1 ActionContextProvider (com.google.devtools.build.lib.exec.ActionContextProvider)1 ExecutorBuilder (com.google.devtools.build.lib.exec.ExecutorBuilder)1 OutputService (com.google.devtools.build.lib.exec.OutputService)1 ElapsedTimeReceiver (com.google.devtools.build.lib.profiler.AutoProfiler.ElapsedTimeReceiver)1