Search in sources :

Example 1 with CriticalPathModule

use of org.eclipse.tracecompass.analysis.graph.core.criticalpath.CriticalPathModule in project tracecompass by tracecompass.

the class CriticalPathView method analysisStarted.

/**
 * Signal handler for analysis started, we need to rebuilt the entry list with
 * updated statistics values for the current graph worker of the critical path
 * module.
 *
 * @param signal
 *            The signal
 */
@TmfSignalHandler
public void analysisStarted(TmfStartAnalysisSignal signal) {
    IAnalysisModule analysis = signal.getAnalysisModule();
    if (analysis instanceof CriticalPathModule) {
        CriticalPathModule criticalPath = (CriticalPathModule) analysis;
        /*
             * We need to wait for CriticalPathDataProviderFactory to have
             * received this signal. Create a new phaser and register, and wait
             * for the end synch signal to arrive and advance in a new thread.
             */
        fPhaser = new Phaser();
        fPhaser.register();
        new Thread() {

            @Override
            public void run() {
                fPhaser.awaitAdvance(0);
                Collection<ITmfTrace> traces = TmfTraceManager.getTraceSetWithExperiment(getTrace());
                if (traces.contains(criticalPath.getTrace())) {
                    rebuild();
                }
            }
        }.start();
    }
}
Also used : CriticalPathModule(org.eclipse.tracecompass.analysis.graph.core.criticalpath.CriticalPathModule) IAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule) Collection(java.util.Collection) Phaser(java.util.concurrent.Phaser) TmfSignalHandler(org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)

Example 2 with CriticalPathModule

use of org.eclipse.tracecompass.analysis.graph.core.criticalpath.CriticalPathModule in project tracecompass by tracecompass.

the class DistributedCriticalPathTest method internalTestNetworkExchange.

private static void internalTestNetworkExchange(@NonNull ITmfTrace experiment) throws TmfAnalysisException {
    TmfGraphBuilderModule module = TmfTraceUtils.getAnalysisModuleOfClass(experiment, TmfGraphBuilderModule.class, TEST_ANALYSIS_ID);
    assertNotNull(module);
    TmfGraph graph = module.getGraph();
    assertNotNull(graph);
    Set<IGraphWorker> workers = graph.getWorkers();
    assertEquals(7, workers.size());
    // Prepare a worker map
    final int clientThread = 200;
    final int otherClient = 201;
    final int depClient = 202;
    final int serverThread = 100;
    final int otherServer = 101;
    OsWorker clientWorker = null;
    OsWorker serverWorker = null;
    Map<Integer, IGraphWorker> workerMap = new HashMap<>();
    for (IGraphWorker worker : workers) {
        OsWorker osWorker = (OsWorker) worker;
        if (osWorker.getHostThread().getTid() < 0) {
            if (osWorker.getHostId().equals("simple_network_server.xml")) {
                serverWorker = osWorker;
            } else {
                clientWorker = osWorker;
            }
        }
        workerMap.put(osWorker.getHostThread().getTid(), worker);
    }
    // Make the expected graph
    TmfGraph expected = new TmfGraph();
    // other thread on client side
    IGraphWorker worker = workerMap.get(otherClient);
    assertNotNull(worker);
    expected.add(worker, new TmfVertex(7));
    expected.append(worker, new TmfVertex(10), EdgeType.RUNNING);
    expected.append(worker, new TmfVertex(15), EdgeType.PREEMPTED);
    expected.append(worker, new TmfVertex(75), EdgeType.RUNNING);
    // client thread
    worker = workerMap.get(clientThread);
    assertNotNull(worker);
    expected.add(worker, new TmfVertex(10));
    TmfVertex packet1Sent = new TmfVertex(13);
    expected.append(worker, packet1Sent, EdgeType.RUNNING);
    expected.append(worker, new TmfVertex(15), EdgeType.RUNNING);
    TmfVertex packet2Received = new TmfVertex(70);
    expected.append(worker, packet2Received, EdgeType.NETWORK);
    expected.append(worker, new TmfVertex(75), EdgeType.PREEMPTED);
    TmfVertex wakeupSource = new TmfVertex(90);
    expected.append(worker, wakeupSource, EdgeType.RUNNING);
    expected.append(worker, new TmfVertex(95), EdgeType.RUNNING);
    // client kernel worker
    worker = clientWorker;
    assertNotNull(worker);
    expected.add(worker, new TmfVertex(60));
    expected.append(worker, new TmfVertex(65), EdgeType.RUNNING);
    // thread on client waiting for client process
    worker = workerMap.get(depClient);
    assertNotNull(worker);
    expected.add(worker, new TmfVertex(7));
    TmfVertex wakeupTarget = new TmfVertex(90);
    expected.append(worker, wakeupTarget, EdgeType.BLOCKED);
    expected.append(worker, new TmfVertex(95), EdgeType.PREEMPTED);
    wakeupSource.linkVertical(wakeupTarget);
    // Other thread on server side
    worker = workerMap.get(otherServer);
    assertNotNull(worker);
    expected.add(worker, new TmfVertex(5));
    expected.append(worker, new TmfVertex(40), EdgeType.RUNNING);
    expected.append(worker, new TmfVertex(55), EdgeType.PREEMPTED);
    // Server thread
    worker = workerMap.get(serverThread);
    assertNotNull(worker);
    expected.add(worker, new TmfVertex(5));
    TmfVertex packet1Received = new TmfVertex(35);
    expected.append(worker, packet1Received, EdgeType.NETWORK);
    expected.append(worker, new TmfVertex(40), EdgeType.PREEMPTED);
    TmfVertex packet2Sent = new TmfVertex(45);
    expected.append(worker, packet2Sent, EdgeType.RUNNING);
    expected.append(worker, new TmfVertex(55), EdgeType.RUNNING);
    // Create the vertical links
    TmfEdge link = packet1Sent.linkVertical(packet1Received);
    link.setType(EdgeType.NETWORK);
    link = packet2Sent.linkVertical(packet2Received);
    link.setType(EdgeType.NETWORK);
    // kernel worker on server side
    worker = serverWorker;
    assertNotNull(worker);
    expected.add(worker, new TmfVertex(30));
    expected.append(worker, new TmfVertex(33), EdgeType.RUNNING);
    GraphOps.checkEquality(expected, graph);
    /* Test the critical path */
    // Build the expected critical path
    expected = new TmfGraph();
    // Client worker
    worker = workerMap.get(clientThread);
    assertNotNull(worker);
    expected.add(worker, new TmfVertex(10));
    expected.append(worker, new TmfVertex(13), EdgeType.RUNNING);
    packet1Sent = new TmfVertex(15);
    expected.append(worker, packet1Sent, EdgeType.RUNNING);
    packet2Received = new TmfVertex(70);
    expected.add(worker, packet2Received);
    expected.append(worker, new TmfVertex(75), EdgeType.PREEMPTED);
    expected.append(worker, new TmfVertex(90), EdgeType.RUNNING);
    expected.append(worker, new TmfVertex(95), EdgeType.RUNNING);
    // Server worker
    worker = workerMap.get(serverThread);
    assertNotNull(worker);
    packet1Received = new TmfVertex(35);
    expected.add(worker, packet1Received);
    expected.append(worker, new TmfVertex(40), EdgeType.PREEMPTED);
    packet2Sent = new TmfVertex(45);
    expected.append(worker, packet2Sent, EdgeType.RUNNING);
    link = packet1Sent.linkVertical(packet1Received);
    link.setType(EdgeType.NETWORK);
    link = packet2Sent.linkVertical(packet2Received);
    link.setType(EdgeType.NETWORK);
    // Execute the critical path module and compare equality
    CriticalPathModule critPathModule = new CriticalPathModule(module);
    try {
        critPathModule.setTrace(experiment);
        critPathModule.setParameter(CriticalPathModule.PARAM_WORKER, workerMap.get(clientThread));
        critPathModule.schedule();
        assertTrue(critPathModule.waitForCompletion());
        TmfGraph criticalPath = critPathModule.getCriticalPath();
        assertNotNull(criticalPath);
        GraphOps.checkEquality(expected, criticalPath);
    } finally {
        critPathModule.dispose();
    }
}
Also used : OsWorker(org.eclipse.tracecompass.analysis.os.linux.core.execution.graph.OsWorker) TmfEdge(org.eclipse.tracecompass.analysis.graph.core.base.TmfEdge) CriticalPathModule(org.eclipse.tracecompass.analysis.graph.core.criticalpath.CriticalPathModule) TmfVertex(org.eclipse.tracecompass.analysis.graph.core.base.TmfVertex) HashMap(java.util.HashMap) TmfGraph(org.eclipse.tracecompass.analysis.graph.core.base.TmfGraph) TmfGraphBuilderModule(org.eclipse.tracecompass.analysis.graph.core.building.TmfGraphBuilderModule) IGraphWorker(org.eclipse.tracecompass.analysis.graph.core.base.IGraphWorker)

Example 3 with CriticalPathModule

use of org.eclipse.tracecompass.analysis.graph.core.criticalpath.CriticalPathModule in project tracecompass by tracecompass.

the class DistributedCriticalPathTest method internalTestNetworkExchangeOneTrace.

private static void internalTestNetworkExchangeOneTrace(@NonNull ITmfTrace experiment) throws TmfAnalysisException {
    TmfGraphBuilderModule module = TmfTraceUtils.getAnalysisModuleOfClass(experiment, TmfGraphBuilderModule.class, TEST_ANALYSIS_ID);
    assertNotNull(module);
    TmfGraph graph = module.getGraph();
    assertNotNull(graph);
    Set<IGraphWorker> workers = graph.getWorkers();
    assertEquals(3, workers.size());
    // Prepare a worker map
    final int irqThread = 50;
    final int clientThread = 200;
    final int otherClient = 201;
    Map<Integer, IGraphWorker> workerMap = new HashMap<>();
    for (IGraphWorker worker : workers) {
        workerMap.put(((OsWorker) worker).getHostThread().getTid(), worker);
    }
    // Make the expected graph
    TmfGraph expected = new TmfGraph();
    // other thread on client side
    IGraphWorker worker = workerMap.get(otherClient);
    assertNotNull(worker);
    expected.add(worker, new TmfVertex(10));
    expected.append(worker, new TmfVertex(15), EdgeType.PREEMPTED);
    expected.append(worker, new TmfVertex(60), EdgeType.RUNNING);
    // client thread
    worker = workerMap.get(clientThread);
    assertNotNull(worker);
    expected.add(worker, new TmfVertex(10));
    TmfVertex packet1Sent = new TmfVertex(13);
    expected.append(worker, packet1Sent, EdgeType.RUNNING);
    expected.append(worker, new TmfVertex(15), EdgeType.RUNNING);
    TmfVertex packet2Received = new TmfVertex(70);
    expected.append(worker, packet2Received, EdgeType.NETWORK, "irq/30-handler");
    expected.append(worker, new TmfVertex(75), EdgeType.PREEMPTED);
    // irq thread
    worker = workerMap.get(irqThread);
    assertNotNull(worker);
    expected.add(worker, new TmfVertex(55));
    expected.append(worker, new TmfVertex(60), EdgeType.PREEMPTED);
    expected.append(worker, new TmfVertex(65), EdgeType.RUNNING);
    expected.append(worker, new TmfVertex(75), EdgeType.RUNNING);
    GraphOps.checkEquality(expected, graph);
    /* Test the critical path */
    // Build the expected graph: it should be the client thread only
    expected = new TmfGraph();
    worker = workerMap.get(clientThread);
    assertNotNull(worker);
    for (TmfVertex vertex : graph.getNodesOf(worker)) {
        expected.add(worker, vertex);
    }
    // Execute the critical path module and compare equality
    CriticalPathModule critPathModule = new CriticalPathModule(module);
    try {
        critPathModule.setTrace(experiment);
        critPathModule.setParameter(CriticalPathModule.PARAM_WORKER, workerMap.get(clientThread));
        critPathModule.schedule();
        assertTrue(critPathModule.waitForCompletion());
        TmfGraph criticalPath = critPathModule.getCriticalPath();
        assertNotNull(criticalPath);
        GraphOps.checkEquality(expected, criticalPath);
    } finally {
        critPathModule.dispose();
    }
}
Also used : OsWorker(org.eclipse.tracecompass.analysis.os.linux.core.execution.graph.OsWorker) CriticalPathModule(org.eclipse.tracecompass.analysis.graph.core.criticalpath.CriticalPathModule) TmfVertex(org.eclipse.tracecompass.analysis.graph.core.base.TmfVertex) HashMap(java.util.HashMap) TmfGraph(org.eclipse.tracecompass.analysis.graph.core.base.TmfGraph) TmfGraphBuilderModule(org.eclipse.tracecompass.analysis.graph.core.building.TmfGraphBuilderModule) IGraphWorker(org.eclipse.tracecompass.analysis.graph.core.base.IGraphWorker)

Example 4 with CriticalPathModule

use of org.eclipse.tracecompass.analysis.graph.core.criticalpath.CriticalPathModule in project tracecompass by tracecompass.

the class CriticalPathParameterProvider method getParameter.

@Override
public Object getParameter(String name) {
    if (name.equals(CriticalPathModule.PARAM_WORKER)) {
        final HostThread currentHostThread = fCurrentHostThread;
        if (currentHostThread == null) {
            return null;
        }
        /* Try to find the worker for the critical path */
        IAnalysisModule mod = getModule();
        if (mod instanceof CriticalPathModule) {
            // $NON-NLS-1$
            OsWorker worker = new OsWorker(currentHostThread, "", 0);
            return worker;
        }
    }
    return null;
}
Also used : HostThread(org.eclipse.tracecompass.analysis.os.linux.core.model.HostThread) OsWorker(org.eclipse.tracecompass.analysis.os.linux.core.execution.graph.OsWorker) CriticalPathModule(org.eclipse.tracecompass.analysis.graph.core.criticalpath.CriticalPathModule) IAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule)

Example 5 with CriticalPathModule

use of org.eclipse.tracecompass.analysis.graph.core.criticalpath.CriticalPathModule in project tracecompass by tracecompass.

the class DistributedCriticalPathTest method internalTestNetworkExchangeWithWifi.

private static void internalTestNetworkExchangeWithWifi(@NonNull ITmfTrace experiment) throws TmfAnalysisException {
    TmfGraphBuilderModule module = TmfTraceUtils.getAnalysisModuleOfClass(experiment, TmfGraphBuilderModule.class, TEST_ANALYSIS_ID);
    assertNotNull(module);
    TmfGraph graph = module.getGraph();
    assertNotNull(graph);
    Set<IGraphWorker> workers = graph.getWorkers();
    assertEquals(6, workers.size());
    // Prepare a worker map
    final int irqThread = 50;
    final int clientThread = 200;
    final int otherClient = 201;
    final int serverThread = 100;
    final int otherServer = 101;
    final int kernelThread = -1;
    Map<Integer, IGraphWorker> workerMap = new HashMap<>();
    for (IGraphWorker worker : workers) {
        workerMap.put(((OsWorker) worker).getHostThread().getTid(), worker);
    }
    // Build the expected graph
    TmfGraph expected = new TmfGraph();
    // other thread on client side
    IGraphWorker worker = workerMap.get(otherClient);
    assertNotNull(worker);
    expected.add(worker, new TmfVertex(10));
    expected.append(worker, new TmfVertex(15), EdgeType.PREEMPTED);
    expected.append(worker, new TmfVertex(60), EdgeType.RUNNING);
    // client thread
    worker = workerMap.get(clientThread);
    assertNotNull(worker);
    expected.add(worker, new TmfVertex(10));
    TmfVertex packet1Sent = new TmfVertex(13);
    expected.append(worker, packet1Sent, EdgeType.RUNNING);
    expected.append(worker, new TmfVertex(15), EdgeType.RUNNING);
    TmfVertex packet2Received = new TmfVertex(70);
    expected.append(worker, packet2Received, EdgeType.NETWORK, "irq/30-handler");
    expected.append(worker, new TmfVertex(75), EdgeType.PREEMPTED);
    // irq thread
    worker = workerMap.get(irqThread);
    assertNotNull(worker);
    expected.add(worker, new TmfVertex(55));
    expected.append(worker, new TmfVertex(60), EdgeType.PREEMPTED);
    expected.append(worker, new TmfVertex(65), EdgeType.RUNNING);
    expected.append(worker, new TmfVertex(75), EdgeType.RUNNING);
    // Other thread on server side
    worker = workerMap.get(otherServer);
    assertNotNull(worker);
    expected.add(worker, new TmfVertex(5));
    expected.append(worker, new TmfVertex(40), EdgeType.RUNNING);
    expected.append(worker, new TmfVertex(55), EdgeType.PREEMPTED);
    // Server thread
    worker = workerMap.get(serverThread);
    assertNotNull(worker);
    expected.add(worker, new TmfVertex(5));
    TmfVertex packet1Received = new TmfVertex(35);
    expected.append(worker, packet1Received, EdgeType.NETWORK);
    expected.append(worker, new TmfVertex(40), EdgeType.PREEMPTED);
    TmfVertex packet2Sent = new TmfVertex(45);
    expected.append(worker, packet2Sent, EdgeType.RUNNING);
    expected.append(worker, new TmfVertex(55), EdgeType.RUNNING);
    // Create the vertical links
    TmfEdge link = packet1Sent.linkVertical(packet1Received);
    link.setType(EdgeType.NETWORK);
    link = packet2Sent.linkVertical(packet2Received);
    link.setType(EdgeType.NETWORK);
    // kernel worker on server side
    worker = workerMap.get(kernelThread);
    assertNotNull(worker);
    expected.add(worker, new TmfVertex(30));
    expected.append(worker, new TmfVertex(33), EdgeType.RUNNING);
    GraphOps.checkEquality(expected, graph);
    /* Test the critical path */
    // Build the expected critical path
    expected = new TmfGraph();
    // Client worker
    worker = workerMap.get(clientThread);
    assertNotNull(worker);
    expected.add(worker, new TmfVertex(10));
    expected.append(worker, new TmfVertex(13), EdgeType.RUNNING);
    packet1Sent = new TmfVertex(15);
    expected.append(worker, packet1Sent, EdgeType.RUNNING);
    packet2Received = new TmfVertex(70);
    expected.add(worker, packet2Received);
    expected.append(worker, new TmfVertex(75), EdgeType.PREEMPTED);
    // Server worker
    worker = workerMap.get(serverThread);
    assertNotNull(worker);
    packet1Received = new TmfVertex(35);
    expected.add(worker, packet1Received);
    expected.append(worker, new TmfVertex(40), EdgeType.PREEMPTED);
    packet2Sent = new TmfVertex(45);
    expected.append(worker, packet2Sent, EdgeType.RUNNING);
    link = packet1Sent.linkVertical(packet1Received);
    link.setType(EdgeType.NETWORK);
    link = packet2Sent.linkVertical(packet2Received);
    link.setType(EdgeType.NETWORK);
    // Execute the critical path module and compare equality
    CriticalPathModule critPathModule = new CriticalPathModule(module);
    try {
        critPathModule.setTrace(experiment);
        critPathModule.setParameter(CriticalPathModule.PARAM_WORKER, workerMap.get(clientThread));
        critPathModule.schedule();
        assertTrue(critPathModule.waitForCompletion());
        TmfGraph criticalPath = critPathModule.getCriticalPath();
        assertNotNull(criticalPath);
        GraphOps.checkEquality(expected, criticalPath);
    } finally {
        critPathModule.dispose();
    }
}
Also used : OsWorker(org.eclipse.tracecompass.analysis.os.linux.core.execution.graph.OsWorker) TmfEdge(org.eclipse.tracecompass.analysis.graph.core.base.TmfEdge) CriticalPathModule(org.eclipse.tracecompass.analysis.graph.core.criticalpath.CriticalPathModule) TmfVertex(org.eclipse.tracecompass.analysis.graph.core.base.TmfVertex) HashMap(java.util.HashMap) TmfGraph(org.eclipse.tracecompass.analysis.graph.core.base.TmfGraph) TmfGraphBuilderModule(org.eclipse.tracecompass.analysis.graph.core.building.TmfGraphBuilderModule) IGraphWorker(org.eclipse.tracecompass.analysis.graph.core.base.IGraphWorker)

Aggregations

CriticalPathModule (org.eclipse.tracecompass.analysis.graph.core.criticalpath.CriticalPathModule)8 OsWorker (org.eclipse.tracecompass.analysis.os.linux.core.execution.graph.OsWorker)6 IGraphWorker (org.eclipse.tracecompass.analysis.graph.core.base.IGraphWorker)5 TmfGraph (org.eclipse.tracecompass.analysis.graph.core.base.TmfGraph)5 HashMap (java.util.HashMap)4 TmfVertex (org.eclipse.tracecompass.analysis.graph.core.base.TmfVertex)4 TmfGraphBuilderModule (org.eclipse.tracecompass.analysis.graph.core.building.TmfGraphBuilderModule)4 IAnalysisModule (org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule)3 TmfEdge (org.eclipse.tracecompass.analysis.graph.core.base.TmfEdge)2 TmfSignalHandler (org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)2 Collection (java.util.Collection)1 Phaser (java.util.concurrent.Phaser)1 HostThread (org.eclipse.tracecompass.analysis.os.linux.core.model.HostThread)1 TmfAnalysisException (org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException)1