Example #1
0
        /// <inheritdoc />
        public T QueryOutput <T>(DataOutputPath identifier)
        {
            var value = this.QueryOutput(identifier);

            return((T)value);
        }
        public static void BuildTable(ITableBuilder tableBuilder, IDataExtensionRetrieval tableData)
        {
            int maximumFieldCount = tableData.QueryOutput <int>(
                DataOutputPath.ForSource(PerfConstants.SourceId, PerfGenericEventDataCooker.Identifier, nameof(PerfGenericEventDataCooker.MaximumEventFieldCount)));

            var events = tableData.QueryOutput <ProcessedEventData <PerfGenericEvent> >(
                DataOutputPath.ForSource(PerfConstants.SourceId, PerfGenericEventDataCooker.Identifier, nameof(PerfGenericEventDataCooker.Events)));

            var tableGenerator = tableBuilder.SetRowCount((int)events.Count);

            var genericEventProjection = new EventProjection <PerfGenericEvent>(events);

            var eventNameColumn = new DataColumn <string>(
                eventNameColumnConfig,
                genericEventProjection.Compose((genericEvent) => genericEvent.EventName));

            tableGenerator.AddColumn(eventNameColumn);

            var eventIdColumn = new DataColumn <uint>(
                eventIdColumnConfig,
                genericEventProjection.Compose((genericEvent) => genericEvent.Id));

            tableGenerator.AddColumn(eventIdColumn);

            var cpuIdColumn = new DataColumn <uint>(
                cpuIdColumnConfig,
                genericEventProjection.Compose((genericEvent) => genericEvent.CpuId));

            tableGenerator.AddColumn(cpuIdColumn);

            var eventTimestampColumn = new DataColumn <Timestamp>(
                eventTimestampColumnConfig,
                genericEventProjection.Compose((genericEvent) => genericEvent.Timestamp));

            tableGenerator.AddColumn(eventTimestampColumn);

            tableGenerator.AddColumn(countColumnConfig, Projection.Constant(1));

            // Add the field columns, with column names depending on the given event
            for (int columnIndex = 0; columnIndex < maximumFieldCount; columnIndex++)
            {
                string fieldName = "Field " + (columnIndex + 1);

                var genericEventFieldProjection = new GenericEventFieldProjection(columnIndex, genericEventProjection);

                var genericEventFieldNameProjection =
                    genericEventFieldProjection.Compose((field) => field.HasValue ? field.Value.Name : string.Empty);

                // generate a column configuration
                var fieldColumnConfiguration = new ColumnConfiguration(
                    new ColumnMetadata(Common.GenerateGuidFromName(fieldName), fieldName, genericEventFieldNameProjection, fieldName),
                    new UIHints
                {
                    IsVisible     = true,
                    Width         = 80,
                    TextAlignment = TextAlignment.Left,
                });

                var genericEventFieldAsStringProjection =
                    genericEventFieldProjection.Compose((field) => field.HasValue ? field.Value.Value : string.Empty);

                tableGenerator.AddColumn(fieldColumnConfiguration, genericEventFieldAsStringProjection);
            }
        }
Example #3
0
        public static void BuildTable(ITableBuilder tableBuilder, IDataExtensionRetrieval tableData)
        {
            var pathIdentifier = DataOutputPath.Create(PerfCpuClockDataCooker.CookerPath + "/CpuClockEvents");

            var cpuClocks = tableData.QueryOutput <IReadOnlyList <ICpuClockEvent> >(pathIdentifier);

            if (cpuClocks.Count == 0)
            {
                return;
            }

            var config = new TableConfiguration("CPU Utilization")
            {
                Columns = new[]
                {
                    cpuColumn,
                    callStackColumn,
                    TableConfiguration.PivotColumn,
                    pidColumn,
                    threadIdColumn,
                    ipColumn,
                    symbolTypeColumn,
                    ipSymbolColumn,
                    idColumn,
                    weightColumn,
                    countColumn,
                    timeStampColumn,
                    TableConfiguration.GraphColumn,
                    weightPctColumn
                },
                Layout = TableLayoutStyle.GraphAndTable,
            };

            config.AddColumnRole(ColumnRole.EndTime, timeStampColumn);
            config.AddColumnRole(ColumnRole.Duration, weightColumn);
            config.AddColumnRole(ColumnRole.ResourceId, cpuColumn);

            var table = tableBuilder.AddTableConfiguration(config)
                        .SetDefaultTableConfiguration(config)
                        .SetRowCount(cpuClocks.Count);

            var timeStampProjection = Projection.CreateUsingFuncAdaptor((i) => cpuClocks[i].Timestamp);

            table.AddColumn(cpuColumn, Projection.CreateUsingFuncAdaptor((i) => cpuClocks[i].Cpu));
            table.AddColumn(ipColumn, Projection.CreateUsingFuncAdaptor((i) => cpuClocks[i].Ip));
            table.AddColumn(symbolTypeColumn, Projection.CreateUsingFuncAdaptor((i) => cpuClocks[i].Ip_Symbol?.SymbolType?.SymbolTypeDescription.SymbolTypeShortName));
            table.AddColumn(ipSymbolColumn, Projection.CreateUsingFuncAdaptor((i) => cpuClocks[i].Ip_Symbol?.Name));
            table.AddColumn(threadIdColumn, Projection.CreateUsingFuncAdaptor((i) => cpuClocks[i].Tid));
            table.AddColumn(pidColumn, Projection.CreateUsingFuncAdaptor((i) => cpuClocks[i].Pid));
            table.AddColumn(idColumn, Projection.CreateUsingFuncAdaptor((i) => cpuClocks[i].Id));
            table.AddColumn(perfPeriodColumn, Projection.CreateUsingFuncAdaptor((i) => cpuClocks[i].Perf_Period));
            table.AddColumn(perfCallchainSizeColumn, Projection.CreateUsingFuncAdaptor((i) => cpuClocks[i].Perf_Callchain_Size));
            table.AddHierarchicalColumn(callStackColumn, Projection.CreateUsingFuncAdaptor((i) => cpuClocks[i].CallStack), new ArrayAccessProvider <string>());
            table.AddColumn(timeStampColumn, timeStampProjection);

            var oneMsSample = new TimestampDelta(1000000); // 1ms for now until we can figure out weight better
            var oneNs       = new TimestampDelta(1);
            var weightProj  = Projection.Constant(oneMsSample);

            var timeStampStartProjection = Projection.CreateUsingFuncAdaptor((i) => cpuClocks[i].Timestamp - oneNs); // We will say sample lasted 1ns
            IProjection <int, Timestamp> viewportClippedStartTimeProj = Projection.ClipTimeToViewport.Create(timeStampStartProjection);
            IProjection <int, Timestamp> viewportClippedEndTimeProj   = Projection.ClipTimeToViewport.Create(timeStampProjection);

            IProjection <int, TimestampDelta> clippedWeightProj = Projection.Select(
                viewportClippedEndTimeProj,
                viewportClippedStartTimeProj,
                new ReduceTimeSinceLastDiff());

            IProjection <int, double> weightPercentProj = Projection.ViewportRelativePercent.Create(clippedWeightProj);

            IProjection <int, int> countProj = SequentialGenerator.Create(
                cpuClocks.Count,
                Projection.Constant(1),
                Projection.Constant(0));

            table.AddColumn(weightColumn, weightProj);
            table.AddColumn(countColumn, countProj);
            table.AddColumn(weightPctColumn, weightPercentProj);
            table.AddColumn(startTimeCol, timeStampStartProjection);
            table.AddColumn(viewportClippedStartTimeCol, viewportClippedStartTimeProj);
            table.AddColumn(viewportClippedEndTimeCol, viewportClippedEndTimeProj);
            table.AddColumn(clippedWeightCol, clippedWeightProj);
        }
Example #4
0
 public static bool IsDataAvailable(IDataExtensionRetrieval tableData)
 {
     return(tableData.QueryOutput <IReadOnlyList <ISyscall> >(
                DataOutputPath.ForSource(LTTngConstants.SourceId, LTTngSyscallDataCooker.Identifier, nameof(LTTngSyscallDataCooker.Syscalls))).Any());
 }
Example #5
0
        public static void BuildTable(ITableBuilder tableBuilder, IDataExtensionRetrieval tableData)
        {
            var threads = tableData.QueryOutput <IReadOnlyList <IExecutionEvent> >(
                DataOutputPath.Create(LTTngThreadDataCooker.CookerPath + "/ExecutionEvents"));

            if (threads.Count == 0)
            {
                return;
            }

            const string filterIdleSamplesQuery   = "[New Thread Id]:=\"0\"";
            var          timelineByCPUTableConfig = new TableConfiguration("Timeline by CPU")
            {
                Columns = new[]
                {
                    cpuColumn,
                    nextPidColumn,
                    nextTidColumn,
                    TableConfiguration.PivotColumn,
                    nextCommandColumn,
                    previousStateColumn,
                    nextThreadPreviousSwitchOutTimeColumn,
                    previousTidColumn,
                    readyingPidColumn,
                    readyingTidColumn,
                    readyTimeColumn,
                    waitTimeColumn,
                    switchedInTimeColumn,
                    priorityColumn,
                    TableConfiguration.GraphColumn,
                    switchInTimeColumn,
                    switchOutTimeColumn
                },
                Layout = TableLayoutStyle.GraphAndTable,
                InitialFilterShouldKeep = false,
                InitialFilterQuery      = filterIdleSamplesQuery,
            };

            timelineByCPUTableConfig.AddColumnRole(ColumnRole.EndThreadId, nextTidColumn);
            timelineByCPUTableConfig.AddColumnRole(ColumnRole.StartTime, switchInTimeColumn);
            timelineByCPUTableConfig.AddColumnRole(ColumnRole.ResourceId, cpuColumn);
            timelineByCPUTableConfig.AddColumnRole(ColumnRole.WaitEndTime, switchInTimeColumn);
            timelineByCPUTableConfig.AddColumnRole(ColumnRole.Duration, switchedInTimeColumn);

            var utilByProcessCmdTable = new TableConfiguration("Utilization by Process Id, Thread Id, Cmd")
            {
                Columns = new[]
                {
                    nextPidColumn,
                    nextTidColumn,
                    nextCommandColumn,
                    TableConfiguration.PivotColumn,
                    cpuColumn,
                    previousStateColumn,
                    nextThreadPreviousSwitchOutTimeColumn,
                    previousTidColumn,
                    readyingPidColumn,
                    readyingTidColumn,
                    switchInTimeColumn,
                    readyTimeColumn,
                    waitTimeColumn,
                    switchedInTimeColumn,
                    priorityColumn,
                    TableConfiguration.GraphColumn,
                    percentCpuUsagePreset,
                },
                Layout = TableLayoutStyle.GraphAndTable,
                InitialFilterShouldKeep = false,
                InitialFilterQuery      = filterIdleSamplesQuery,
            };

            utilByProcessCmdTable.AddColumnRole(ColumnRole.EndThreadId, nextTidColumn);
            utilByProcessCmdTable.AddColumnRole(ColumnRole.StartTime, switchInTimeColumn);
            utilByProcessCmdTable.AddColumnRole(ColumnRole.ResourceId, cpuColumn);
            utilByProcessCmdTable.AddColumnRole(ColumnRole.WaitEndTime, switchInTimeColumn);
            utilByProcessCmdTable.AddColumnRole(ColumnRole.Duration, switchedInTimeColumn);

            var utilByCpuTable = new TableConfiguration("Utilization by CPU")
            {
                Columns = new[]
                {
                    cpuColumn,
                    TableConfiguration.PivotColumn,
                    nextPidColumn,
                    nextTidColumn,
                    nextCommandColumn,
                    previousStateColumn,
                    nextThreadPreviousSwitchOutTimeColumn,
                    previousTidColumn,
                    readyingPidColumn,
                    readyingTidColumn,
                    switchInTimeColumn,
                    readyTimeColumn,
                    waitTimeColumn,
                    switchedInTimeColumn,
                    priorityColumn,
                    TableConfiguration.GraphColumn,
                    percentCpuUsagePreset,
                },
                Layout = TableLayoutStyle.GraphAndTable,
                InitialFilterShouldKeep = false,
                InitialFilterQuery      = filterIdleSamplesQuery,
            };

            utilByCpuTable.AddColumnRole(ColumnRole.EndThreadId, nextTidColumn);
            utilByCpuTable.AddColumnRole(ColumnRole.StartTime, switchInTimeColumn);
            utilByCpuTable.AddColumnRole(ColumnRole.ResourceId, cpuColumn);
            utilByCpuTable.AddColumnRole(ColumnRole.WaitEndTime, switchInTimeColumn);
            utilByCpuTable.AddColumnRole(ColumnRole.Duration, switchedInTimeColumn);

            var table = tableBuilder.AddTableConfiguration(timelineByCPUTableConfig)
                        .AddTableConfiguration(utilByProcessCmdTable)
                        .AddTableConfiguration(utilByCpuTable)
                        .SetDefaultTableConfiguration(utilByProcessCmdTable)
                        .SetRowCount(threads.Count);

            var switchInTime  = Projection.CreateUsingFuncAdaptor((i) => threads[i].SwitchInTime);
            var switchOutTime = Projection.CreateUsingFuncAdaptor((i) => threads[i].SwitchOutTime);

            table.AddColumn(cpuColumn, Projection.CreateUsingFuncAdaptor((i) => threads[i].Cpu));
            table.AddColumn(nextPidColumn, Projection.CreateUsingFuncAdaptor((i) => threads[i].NextPid));
            table.AddColumn(nextTidColumn, Projection.CreateUsingFuncAdaptor((i) => threads[i].NextTid));
            table.AddColumn(previousStateColumn, Projection.CreateUsingFuncAdaptor((i) => threads[i].PreviousState));
            table.AddColumn(nextThreadPreviousSwitchOutTimeColumn, Projection.CreateUsingFuncAdaptor((i) => threads[i].NextThreadPreviousSwitchOutTime));
            table.AddColumn(previousTidColumn, Projection.CreateUsingFuncAdaptor((i) => threads[i].PreviousTid));
            table.AddColumn(readyingPidColumn, Projection.CreateUsingFuncAdaptor((i) => threads[i].ReadyingPid));
            table.AddColumn(readyingTidColumn, Projection.CreateUsingFuncAdaptor((i) => threads[i].ReadyingTid));
            table.AddColumn(readyTimeColumn, Projection.CreateUsingFuncAdaptor((i) => threads[i].ReadyTime));
            table.AddColumn(waitTimeColumn, Projection.CreateUsingFuncAdaptor((i) => threads[i].WaitTime));
            table.AddColumn(switchedInTimeColumn, Projection.CreateUsingFuncAdaptor((i) => threads[i].SwitchOutTime - threads[i].SwitchInTime));
            table.AddColumn(priorityColumn, Projection.CreateUsingFuncAdaptor((i) => threads[i].Priority));
            table.AddColumn(switchInTimeColumn, switchInTime);
            table.AddColumn(switchOutTimeColumn, switchOutTime);
            table.AddColumn(previousPidColumn, Projection.CreateUsingFuncAdaptor((i) => threads[i].PreviousPid));
            table.AddColumn(nextCommandColumn, Projection.CreateUsingFuncAdaptor((i) => threads[i].NextImage));
            table.AddColumn(previousCommandColumn, Projection.CreateUsingFuncAdaptor((i) => threads[i].PreviousImage));


            // Time the thread switching in switches out
            var viewportClippedSwitchOutTimeForNextOnCpuColumn = Projection.ClipTimeToViewport.Create(switchOutTime);

            // Switch in time is the thread switching in, which is the switch out time of the thread switching out on the CPU
            var viewportClippedSwitchOutTimeForPreviousOnCpuColumn = Projection.ClipTimeToViewport.Create(switchInTime);

            IProjection <int, TimestampDelta> cpuUsageInViewportColumn = Projection.Select(
                viewportClippedSwitchOutTimeForNextOnCpuColumn,
                viewportClippedSwitchOutTimeForPreviousOnCpuColumn,
                new ReduceTimeSinceLastDiff());

            var percentCpuUsageColumn = Projection.ViewportRelativePercent.Create(cpuUsageInViewportColumn);

            var cpuUsageColumn = Projection.Select(switchOutTime, switchInTime, new ReduceTimeSinceLastDiff());

            table.AddColumn(cpuUsageInViewportPreset, cpuUsageInViewportColumn);
            table.AddColumn(cpuUsagePreset, cpuUsageColumn);
            table.AddColumn(percentCpuUsagePreset, percentCpuUsageColumn);
        }