From cdce23b31002139312fbf30f7afa0808a825d841 Mon Sep 17 00:00:00 2001 From: Benjamin Poirier Date: Wed, 28 Oct 2009 15:10:53 -0400 Subject: [PATCH] Add a module to evaluate the quality of synchronization Prints information about message inversions. Signed-off-by: Benjamin Poirier --- lttv/lttv/Makefile.am | 5 +- lttv/lttv/sync/Makefile.am | 3 +- lttv/lttv/sync/event_analysis_eval.c | 265 +++++++++++++++++++++++++++ lttv/lttv/sync/event_analysis_eval.h | 48 +++++ lttv/modules/text/sync_chain_batch.c | 3 +- 5 files changed, 320 insertions(+), 4 deletions(-) create mode 100644 lttv/lttv/sync/event_analysis_eval.c create mode 100644 lttv/lttv/sync/event_analysis_eval.h diff --git a/lttv/lttv/Makefile.am b/lttv/lttv/Makefile.am index b758b434..f81466f1 100644 --- a/lttv/lttv/Makefile.am +++ b/lttv/lttv/Makefile.am @@ -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\ diff --git a/lttv/lttv/sync/Makefile.am b/lttv/lttv/sync/Makefile.am index 5c7ead0a..7c28a548 100644 --- a/lttv/lttv/sync/Makefile.am +++ b/lttv/lttv/sync/Makefile.am @@ -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 index 00000000..9ee0f47f --- /dev/null +++ b/lttv/lttv/sync/event_analysis_eval.c @@ -0,0 +1,265 @@ +/* This file is part of the Linux Trace Toolkit viewer + * Copyright (C) 2009 Benjamin Poirier + * + * 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 +#endif + +#include + +#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 index 00000000..7ecdb336 --- /dev/null +++ b/lttv/lttv/sync/event_analysis_eval.h @@ -0,0 +1,48 @@ +/* This file is part of the Linux Trace Toolkit viewer + * Copyright (C) 2009 Benjamin Poirier + * + * 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 + +#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 diff --git a/lttv/modules/text/sync_chain_batch.c b/lttv/modules/text/sync_chain_batch.c index 3a4bc0df..86f3c657 100644 --- a/lttv/modules/text/sync_chain_batch.c +++ b/lttv/modules/text/sync_chain_batch.c @@ -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); -- 2.34.1