Search in sources :

Example 1 with ProfilerTask

use of com.google.devtools.build.lib.profiler.ProfilerTask in project bazel by bazelbuild.

the class PhaseStatistics method addProfileInfo.

/**
   * Add statistics from {@link ProfileInfo} to the ones already accumulated for this phase.
   */
public void addProfileInfo(String workSpaceName, ProfileInfo info) {
    Task phaseTask = info.getPhaseTask(phase);
    if (phaseTask != null) {
        if (vfsStatistics != null) {
            vfsStatistics.addProfileInfo(workSpaceName, info);
        }
        wasExecuted = true;
        long infoPhaseDuration = info.getPhaseDuration(phaseTask);
        phaseDurationNanos += infoPhaseDuration;
        List<Task> taskList = info.getTasksForPhase(phaseTask);
        long duration = infoPhaseDuration;
        for (Task task : taskList) {
            // Tasks on the phaseTask thread already accounted for in the phaseDuration.
            if (task.threadId != phaseTask.threadId) {
                duration += task.durationNanos;
            }
        }
        totalDurationNanos += duration;
        for (ProfilerTask type : ProfilerTask.values()) {
            AggregateAttr attr = info.getStatsForType(type, taskList);
            long totalTime = Math.max(0, attr.totalTime);
            long count = Math.max(0, attr.count);
            add(taskCounts, type, count);
            add(taskDurations, type, totalTime);
        }
    }
}
Also used : Task(com.google.devtools.build.lib.profiler.ProfileInfo.Task) ProfilerTask(com.google.devtools.build.lib.profiler.ProfilerTask) ProfilerTask(com.google.devtools.build.lib.profiler.ProfilerTask) AggregateAttr(com.google.devtools.build.lib.profiler.ProfileInfo.AggregateAttr)

Example 2 with ProfilerTask

use of com.google.devtools.build.lib.profiler.ProfilerTask in project bazel by bazelbuild.

the class PhaseStatistics method add.

/**
   * Add statistics accumulated in another PhaseStatistics object to this one.
   */
public void add(PhaseStatistics other) {
    Preconditions.checkArgument(phase == other.phase, "Should not combine statistics from different phases");
    if (other.wasExecuted) {
        if (vfsStatistics != null && other.vfsStatistics != null) {
            vfsStatistics.add(other.vfsStatistics);
        }
        wasExecuted = true;
        phaseDurationNanos += other.phaseDurationNanos;
        totalDurationNanos += other.totalDurationNanos;
        for (ProfilerTask type : other) {
            long otherCount = other.getCount(type);
            long otherDuration = other.getTotalDurationNanos(type);
            add(taskCounts, type, otherCount);
            add(taskDurations, type, otherDuration);
        }
    }
}
Also used : ProfilerTask(com.google.devtools.build.lib.profiler.ProfilerTask)

Example 3 with ProfilerTask

use of com.google.devtools.build.lib.profiler.ProfilerTask in project bazel by bazelbuild.

the class PhaseHtml method printVfsStatistics.

/**
   * Print the time spent on VFS operations on each path. Output is grouped by operation and sorted
   * by descending duration. If multiple of the same VFS operation were logged for the same path,
   * print the total duration.
   */
private void printVfsStatistics(@Nullable PhaseVfsStatistics stats) {
    if (vfsStatsLimit == 0 || stats == null || stats.isEmpty()) {
        return;
    }
    lnElement("h4", "VFS path statistics:");
    lnOpen("table", "class", "phase-statistics");
    lnOpen("tr");
    element("td", "Type");
    element("td", "Frequency");
    element("td", "Duration");
    element("td", "class", "left", "Path");
    // tr
    close();
    for (ProfilerTask type : stats) {
        int numPrinted = 0;
        for (Stat stat : stats.getSortedStatistics(type)) {
            lnOpen("tr");
            if (vfsStatsLimit != -1 && numPrinted++ == vfsStatsLimit) {
                open("td", "class", "center", "colspan", "4");
                printf("... %d more ...", stats.getStatisticsCount(type) - vfsStatsLimit);
                close();
                // tr
                close();
                break;
            }
            element("td", type.name());
            element("td", stat.getCount());
            element("td", TimeUtilities.prettyTime(stat.getDuration()));
            element("td", "class", "left", stat.path);
            // tr
            close();
        }
    }
    // table
    lnClose();
}
Also used : Stat(com.google.devtools.build.lib.profiler.statistics.PhaseVfsStatistics.Stat) ProfilerTask(com.google.devtools.build.lib.profiler.ProfilerTask)

Example 4 with ProfilerTask

use of com.google.devtools.build.lib.profiler.ProfilerTask in project bazel by bazelbuild.

the class PhaseText method printVfsStatistics.

/**
   * Print the time spent on VFS operations on each path. Output is grouped by operation and
   * sorted by descending duration. If multiple of the same VFS operation were logged for the same
   * path, print the total duration.
   */
private void printVfsStatistics(@Nullable PhaseVfsStatistics stats) {
    if (vfsStatsLimit == 0 || stats == null || stats.isEmpty()) {
        return;
    }
    lnPrint("VFS path statistics:");
    lnPrintf("%15s %10s %10s %s", "Type", "Frequency", "Duration", "Path");
    for (ProfilerTask type : stats) {
        int numPrinted = 0;
        for (Stat stat : stats.getSortedStatistics(type)) {
            if (vfsStatsLimit != -1 && numPrinted++ == vfsStatsLimit) {
                lnPrintf("... %d more ...", stats.getStatisticsCount(type) - vfsStatsLimit);
                break;
            }
            lnPrintf("%15s %10d %10s %s", type.name(), stat.getCount(), TimeUtilities.prettyTime(stat.getDuration()), stat.path);
        }
    }
    printLn();
}
Also used : Stat(com.google.devtools.build.lib.profiler.statistics.PhaseVfsStatistics.Stat) ProfilerTask(com.google.devtools.build.lib.profiler.ProfilerTask)

Example 5 with ProfilerTask

use of com.google.devtools.build.lib.profiler.ProfilerTask in project bazel by bazelbuild.

the class ProfileCommand method dumpTask.

/**
   * Dumps the task information and all subtasks.
   */
private void dumpTask(ProfileInfo.Task task, PrintStream out, int indent) {
    StringBuilder builder = new StringBuilder(String.format(Joiner.on('\n').join("", "%s %s", "Thread: %-6d  Id: %-6d  Parent: %d", "Start time: %-12s   Duration: %s"), task.type, task.getDescription(), task.threadId, task.id, task.parentId, TimeUtilities.prettyTime(task.startTime), TimeUtilities.prettyTime(task.durationNanos)));
    if (task.hasStats()) {
        builder.append("\n");
        ProfileInfo.AggregateAttr[] stats = task.getStatAttrArray();
        for (ProfilerTask type : ProfilerTask.values()) {
            ProfileInfo.AggregateAttr attr = stats[type.ordinal()];
            if (attr != null) {
                builder.append(type.toString().toLowerCase()).append("=(").append(attr.count).append(", ").append(TimeUtilities.prettyTime(attr.totalTime)).append(") ");
            }
        }
    }
    out.println(StringUtil.indent(builder.toString(), indent));
    for (ProfileInfo.Task subtask : task.subtasks) {
        dumpTask(subtask, out, indent + 1);
    }
}
Also used : ProfilerTask(com.google.devtools.build.lib.profiler.ProfilerTask) Task(com.google.devtools.build.lib.profiler.ProfileInfo.Task) ProfileInfo(com.google.devtools.build.lib.profiler.ProfileInfo)

Aggregations

ProfilerTask (com.google.devtools.build.lib.profiler.ProfilerTask)10 Task (com.google.devtools.build.lib.profiler.ProfileInfo.Task)3 ProfileInfo (com.google.devtools.build.lib.profiler.ProfileInfo)2 Stat (com.google.devtools.build.lib.profiler.statistics.PhaseVfsStatistics.Stat)2 AggregateAttr (com.google.devtools.build.lib.profiler.ProfileInfo.AggregateAttr)1 CriticalPathEntry (com.google.devtools.build.lib.profiler.ProfileInfo.CriticalPathEntry)1 ProfilePhase (com.google.devtools.build.lib.profiler.ProfilePhase)1 PhaseStatistics (com.google.devtools.build.lib.profiler.statistics.PhaseStatistics)1 Path (com.google.devtools.build.lib.vfs.Path)1