Add a module to evaluate the quality of synchronization
authorBenjamin Poirier <benjamin.poirier@polymtl.ca>
Wed, 28 Oct 2009 19:10:53 +0000 (15:10 -0400)
committerBenjamin Poirier <benjamin.poirier@polymtl.ca>
Fri, 18 Dec 2009 19:03:25 +0000 (14:03 -0500)
Prints information about message inversions.

Signed-off-by: Benjamin Poirier <benjamin.poirier@polymtl.ca>
lttv/lttv/Makefile.am
lttv/lttv/sync/Makefile.am
lttv/lttv/sync/event_analysis_eval.c [new file with mode: 0644]
lttv/lttv/sync/event_analysis_eval.h [new file with mode: 0644]
lttv/modules/text/sync_chain_batch.c

index b758b4343bd48d255faf514957266545ef7048b1..f81466f17237613944bb4c114d70d87d68d4fe0a 100644 (file)
@@ -60,10 +60,11 @@ lttv_real_SOURCES = \
        sync/event_processing_lttng_common.c\
        sync/event_processing_lttng_standard.c\
        sync/event_processing_lttng_null.c\
-       sync/event_matching_broadcast.c\
        sync/event_matching_tcp.c\
+       sync/event_matching_broadcast.c\
        sync/event_analysis_linreg.c\
-       sync/event_analysis_chull.c
+       sync/event_analysis_chull.c\
+       sync/event_analysis_eval.c
 
 lttvinclude_HEADERS = \
        attribute.h\
index 5c7ead0a2b89df7e389714dd7482c22fade06692..7c28a54879a17596bd28ea4de8e23523f1ef98cd 100644 (file)
@@ -9,4 +9,5 @@ unittest_SOURCES = \
        event_matching_broadcast.c\
        event_matching_tcp.c\
        event_analysis_linreg.c\
-       event_analysis_chull.c
+       event_analysis_chull.c\
+       event_analysis_eval.c
diff --git a/lttv/lttv/sync/event_analysis_eval.c b/lttv/lttv/sync/event_analysis_eval.c
new file mode 100644 (file)
index 0000000..9ee0f47
--- /dev/null
@@ -0,0 +1,265 @@
+/* This file is part of the Linux Trace Toolkit viewer
+ * Copyright (C) 2009 Benjamin Poirier <benjamin.poirier@polymtl.ca>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License Version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+
+#include "sync_chain_lttv.h"
+
+#include "event_analysis_eval.h"
+
+
+// Functions common to all analysis modules
+static void initAnalysisEval(SyncState* const syncState);
+static void destroyAnalysisEval(SyncState* const syncState);
+
+static void analyzeMessageEval(SyncState* const syncState, Message* const
+       message);
+static void analyzeExchangeEval(SyncState* const syncState, Exchange* const
+       exchange);
+static void analyzeBroadcastEval(SyncState* const syncState, Broadcast* const
+       broadcast);
+static GArray* finalizeAnalysisEval(SyncState* const syncState);
+static void printAnalysisStatsEval(SyncState* const syncState);
+
+// Functions specific to this module
+static void registerAnalysisEval() __attribute__((constructor (102)));
+
+
+static AnalysisModule analysisModuleEval= {
+       .name= "eval",
+       .initAnalysis= &initAnalysisEval,
+       .destroyAnalysis= &destroyAnalysisEval,
+       .analyzeMessage= &analyzeMessageEval,
+       .analyzeExchange= &analyzeExchangeEval,
+       .analyzeBroadcast= &analyzeBroadcastEval,
+       .finalizeAnalysis= &finalizeAnalysisEval,
+       .printAnalysisStats= &printAnalysisStatsEval,
+       .writeAnalysisGraphsPlots= NULL,
+       .writeAnalysisGraphsOptions= NULL,
+};
+
+
+/*
+ * Analysis module registering function
+ */
+static void registerAnalysisEval()
+{
+       g_queue_push_tail(&analysisModules, &analysisModuleEval);
+}
+
+
+/*
+ * Analysis init function
+ *
+ * This function is called at the beginning of a synchronization run for a set
+ * of traces.
+ *
+ * Args:
+ *   syncState     container for synchronization data.
+ */
+static void initAnalysisEval(SyncState* const syncState)
+{
+       AnalysisDataEval* analysisData;
+       unsigned int i;
+
+       analysisData= malloc(sizeof(AnalysisDataEval));
+       syncState->analysisData= analysisData;
+
+       //readRttInfo(&analysisData->rttInfo, optionEvalRttFile);
+
+       if (syncState->stats)
+       {
+               analysisData->stats= malloc(sizeof(AnalysisStatsEval));
+               analysisData->stats->broadcastDiffSum= 0.;
+
+               analysisData->stats->allStats= malloc(syncState->traceNb *
+                       sizeof(TracePairStats*));
+               for (i= 0; i < syncState->traceNb; i++)
+               {
+                       analysisData->stats->allStats[i]= calloc(syncState->traceNb,
+                               sizeof(TracePairStats));
+               }
+       }
+}
+
+
+/*
+ * Analysis destroy function
+ *
+ * Free the analysis specific data structures
+ *
+ * Args:
+ *   syncState     container for synchronization data.
+ */
+static void destroyAnalysisEval(SyncState* const syncState)
+{
+       unsigned int i;
+       AnalysisDataEval* analysisData;
+
+       analysisData= (AnalysisDataEval*) syncState->analysisData;
+
+       if (analysisData == NULL || analysisData->rttInfo == NULL)
+       {
+               return;
+       }
+
+       //g_hash_table_destroy(analysisData->rttInfo);
+       analysisData->rttInfo= NULL;
+
+       if (syncState->stats)
+       {
+               for (i= 0; i < syncState->traceNb; i++)
+               {
+                       free(analysisData->stats->allStats[i]);
+               }
+               free(analysisData->stats->allStats);
+               free(analysisData->stats);
+       }
+
+       free(syncState->analysisData);
+       syncState->analysisData= NULL;
+}
+
+
+/*
+ * Perform analysis on an event pair.
+ *
+ * Args:
+ *   syncState     container for synchronization data
+ *   message       structure containing the events
+ */
+static void analyzeMessageEval(SyncState* const syncState, Message* const message)
+{
+       AnalysisDataEval* analysisData;
+
+       analysisData= (AnalysisDataEval*) syncState->analysisData;
+}
+
+
+/*
+ * Perform analysis on multiple messages
+ *
+ * Args:
+ *   syncState     container for synchronization data
+ *   exchange      structure containing the messages
+ */
+static void analyzeExchangeEval(SyncState* const syncState, Exchange* const exchange)
+{
+       AnalysisDataEval* analysisData;
+
+       analysisData= (AnalysisDataEval*) syncState->analysisData;
+}
+
+
+/*
+ * Perform analysis on muliple events
+ *
+ * Args:
+ *   syncState     container for synchronization data
+ *   broadcast     structure containing the events
+ */
+static void analyzeBroadcastEval(SyncState* const syncState, Broadcast* const broadcast)
+{
+       AnalysisDataEval* analysisData;
+
+       analysisData= (AnalysisDataEval*) syncState->analysisData;
+}
+
+
+/*
+ * Finalize the factor calculations
+ *
+ * Since this module does not really calculate factors, identity factors are
+ * returned.
+ *
+ * Args:
+ *   syncState     container for synchronization data.
+ *
+ * Returns:
+ *   Factors[traceNb] synchronization factors for each trace
+ */
+static GArray* finalizeAnalysisEval(SyncState* const syncState)
+{
+       GArray* factors;
+       unsigned int i;
+
+       factors= g_array_sized_new(FALSE, FALSE, sizeof(Factors),
+               syncState->traceNb);
+       g_array_set_size(factors, syncState->traceNb);
+       for (i= 0; i < syncState->traceNb; i++)
+       {
+               Factors* e;
+
+               e= &g_array_index(factors, Factors, i);
+               e->drift= 1.;
+               e->offset= 0.;
+       }
+
+       return factors;
+}
+
+
+/*
+ * Print statistics related to analysis. Must be called after
+ * finalizeAnalysis.
+ *
+ * Args:
+ *   syncState     container for synchronization data.
+ */
+static void printAnalysisStatsEval(SyncState* const syncState)
+{
+       AnalysisDataEval* analysisData;
+       unsigned int i, j;
+
+       if (!syncState->stats)
+       {
+               return;
+       }
+
+       analysisData= (AnalysisDataEval*) syncState->analysisData;
+
+       printf("Synchronization evaluation analysis stats:\n");
+       printf("\tsum of broadcast differential delays: %g\n",
+               analysisData->stats->broadcastDiffSum);
+
+       printf("\tIndividual evaluation:\n"
+               "\t\tTrace pair  Inversions  Too fast    (No RTT info)\n");
+
+       for (i= 0; i < syncState->traceNb; i++)
+       {
+               for (j= i + 1; j < syncState->traceNb; j++)
+               {
+                       TracePairStats* tpStats;
+                       const char* format= "\t\t%3d - %-3d   %-10u  %-10u  %u\n";
+
+                       tpStats= &analysisData->stats->allStats[i][j];
+
+                       printf(format, i, j, tpStats->inversionNb, tpStats->tooFastNb,
+                               tpStats->noRTTInfoNb);
+
+                       tpStats= &analysisData->stats->allStats[j][i];
+
+                       printf(format, j, i, tpStats->inversionNb, tpStats->tooFastNb,
+                               tpStats->noRTTInfoNb);
+               }
+       }
+}
diff --git a/lttv/lttv/sync/event_analysis_eval.h b/lttv/lttv/sync/event_analysis_eval.h
new file mode 100644 (file)
index 0000000..7ecdb33
--- /dev/null
@@ -0,0 +1,48 @@
+/* This file is part of the Linux Trace Toolkit viewer
+ * Copyright (C) 2009 Benjamin Poirier <benjamin.poirier@polymtl.ca>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License Version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ */
+
+#ifndef EVENT_ANALYSIS_EVAL_H
+#define EVENT_ANALYSIS_EVAL_H
+
+#include <glib.h>
+
+#include "data_structures.h"
+
+
+typedef struct
+{
+       unsigned int inversionNb,
+               tooFastNb,
+               noRTTInfoNb;
+} TracePairStats;
+
+typedef struct
+{
+       double broadcastDiffSum;
+       TracePairStats** allStats;
+} AnalysisStatsEval;
+
+typedef struct
+{
+       // double* rttInfo[saddr][daddr]
+       GHashTable* rttInfo;
+
+       AnalysisStatsEval* stats;
+} AnalysisDataEval;
+
+#endif
index 3a4bc0dff42909940be1644131f5e98231609463..86f3c657b27680cc977cafff86078c5a217dc477 100644 (file)
@@ -343,7 +343,8 @@ void setupSyncChain(LttvTracesetContext* const traceSetContext)
        syncState->matchingModule= (MatchingModule*) result->data;
 
        syncState->analysisData= NULL;
-       result= g_queue_find_custom(&analysisModules, "chull", &gcfCompareAnalysis);
+       result= g_queue_find_custom(&analysisModules, "eval",
+               &gcfCompareAnalysis);
        syncState->analysisModule= (AnalysisModule*) result->data;
 
        syncState->processingModule->initProcessing(syncState, traceSetContext);
This page took 0.027878 seconds and 4 git commands to generate.