def buildTxnRepo(app, cpuInfo, probes, topdownCache, topdownMetrics, events, benchmarkProbes, benchmarkPaths): """ Builds a repository of transactions for current profile session and benchmarks :param app: An instance of xpedite app, to interact with target application :param cpuInfo: Cpu info of the host running target app :param probes: List of probes enabled for the profile session :param topdownCache: A cache of supported topdown hierarchies :param topdownMetrics: Top down metrics to be computed :param events: PMU events collected for the profiling session :param benchmarkProbes: List of probes enabled for the benchmark session :param benchmarkPaths: List of stored reports from previous runs, for benchmarking """ from xpedite.txn.collector import Collector from xpedite.benchmark import BenchmarksCollector from xpedite.txn.loader import ChaoticTxnLoader, BoundedTxnLoader from xpedite.txn.filter import TrivialCounterFilter from xpedite.analytics import CURRENT_RUN from xpedite.util import timeAction counterFilter = TrivialCounterFilter() collector = Collector(counterFilter) if any(probe.canBeginTxn or probe.canEndTxn for probe in probes): loaderType = BoundedTxnLoader else: loaderType = ChaoticTxnLoader loader = loaderType(CURRENT_RUN, cpuInfo, probes, topdownMetrics, events) timeAction('gathering counters', lambda: collector.gatherCounters(app, loader)) currentTxns = loader.getData() if not currentTxns: if loader.processedCounterCount: msg = 'failed to load transactions. recheck routes specified in your profile info' LOGGER.error(msg) raise Exception(msg) else: msg = 'failed to load transactions. It appears the app hit any of the activated probes' LOGGER.error(msg) raise Exception(msg) repo = TxnRepo() repo.addCurrent(currentTxns) if benchmarkPaths: benchmarksCollector = BenchmarksCollector(benchmarkPaths) benchmarksCollector.loadTxns( repo, counterFilter, benchmarksCollector.gatherBenchmarks(10), loaderFactory=lambda benchmark: loaderFactory( loaderType, benchmark, probes, benchmarkProbes, topdownCache, topdownMetrics)) return repo
def loadTxns(repo, counterFilter, benchmarks, loaderFactory): """ Loads transactions for a list of benchmarks :param repo: Transaction repo to collect transactions loaded for benchmarks :param counterFilter: Filter to exclude counters from loading :param benchmarks: List of benchmarks to be loaded :param loaderFactory: Factory to instantiate a loader instance """ for benchmark in benchmarks: loader = loaderFactory(benchmark) collector = Collector(counterFilter) collector.loadDataSources(benchmark.dataSources, loader) repo.addBenchmark(loader.getData())
def gatherBenchmarks(self, count): """ Gathers benchmarks from a list of paths in the file system :param count: Max count of benchmarks to load """ benchmarks = [] if not self.benchmarkPaths: return benchmarks for i, path in enumerate(self.benchmarkPaths): benchmarkPath = os.path.join(path, BENCHMARK_DIR_NAME) if os.path.isdir(benchmarkPath): info = loadBenchmarkInfo(benchmarkPath) if info: (benchmarkName, cpuInfo, path, legend, events) = info benchmark = Benchmark(benchmarkName, cpuInfo, path, legend, events) dataSource = Collector.gatherDataSource(benchmarkPath) if dataSource: benchmark.dataSource = dataSource benchmarks.append(benchmark) else: LOGGER.warn('skip processing benchmark %s. failed to load benchmark info', path) if len(benchmarks) >= count: if i + 1 < len(self.benchmarkPaths): LOGGER.debug('skip processing %s benchmarks. limit reached.', self.benchmarkPaths[i+1:]) break else: LOGGER.warn('skip processing benchmark %s. failed to locate benchmark files', path) return benchmarks
def __init__(self, name, ip, appInfoPath, runId=None, dataSourcePath=None, workspace=None): """Constructs an instance of XpediteDormantApp""" dataSource = Collector.gatherDataSource(dataSourcePath) if dataSourcePath else None if dataSource: LOGGER.warn('Data source detected. overriding appinfo to %s', dataSource.appInfoPath) appInfoPath = dataSource.appInfoPath XpediteApp.__init__(self, name, ip, appInfoPath, dryRun=True, workspace=workspace) self.dataSource = dataSource self.runId = runId