Commit 00e6ed4b authored by Nigel Kukard's avatar Nigel Kukard
Browse files

* Improved the way avergare throughput is calculated over time

* Improved packet processing efficiency
parent edcd553a
...@@ -321,8 +321,26 @@ static int processPktQueue(struct runnerData_t *runnerData, struct pktQueue_t *p ...@@ -321,8 +321,26 @@ static int processPktQueue(struct runnerData_t *runnerData, struct pktQueue_t *p
// 2 seconds // 2 seconds
if (flow->curThroughputAge >= 2000000) if (flow->curThroughputAge >= 2000000)
{ {
flow->curThroughputAge -= 2000000; float delta;
flow->curThroughput = flow->curThroughputAge / 1000000.0 * flow->curThroughput;
// flow->curThroughputAge -= 2000000;
// Get the fraction of time passed since last update
delta = flow->curThroughputAge / 1000000.0;
// Calculate throughput
flow->curThroughput /= delta;
// Calculate average queue size
flow->avgQueueSize = (flow->avgQueueSize + flow->curQueueSize) / delta;
/*
fprintf(stderr,"%s: curThroughput: %f, avgQueueSize: %li, delta: %f\n",
flow->flowName,
flow->curThroughput,
flow->avgQueueSize,
delta);
*/
flow->curThroughputAge = 0;
} }
// Set this as the last time we updated our throughput // Set this as the last time we updated our throughput
...@@ -446,9 +464,6 @@ static int processPktQueue(struct runnerData_t *runnerData, struct pktQueue_t *p ...@@ -446,9 +464,6 @@ static int processPktQueue(struct runnerData_t *runnerData, struct pktQueue_t *p
void *flowRunner(void *data) void *flowRunner(void *data)
{ {
struct runnerData_t *runnerData = (struct runnerData_t*) data; struct runnerData_t *runnerData = (struct runnerData_t*) data;
GList *queueChangeList[NUM_PRIO_BANDS];
int i, pktsProcessed = 0;
GTimeVal mytime;
// Our processing function // Our processing function
...@@ -459,19 +474,21 @@ void *flowRunner(void *data) ...@@ -459,19 +474,21 @@ void *flowRunner(void *data)
// Check if we found a flow with a queue // Check if we found a flow with a queue
pktsProcessed += processPktQueue(aRunnerData,pktQueue); // NOTE: The function below returns the number of packets processed
processPktQueue(aRunnerData,pktQueue);
} }
// Allocate queue change list
for (i = 0; i < NUM_PRIO_BANDS; i++)
queueChangeList[i] = NULL;
logMessage(LOG_DEBUG, "Flow runner started...\n"); logMessage(LOG_DEBUG, "Flow runner started...\n");
// Loop when we get a signal // Loop when we get a signal
while (1) while (1)
{ {
GTimeVal mytime;
unsigned char i;
GList *queueChangeList = NULL;
g_mutex_lock(runnerData->bandSignalLock); g_mutex_lock(runnerData->bandSignalLock);
// If the queue has changed proceed // If the queue has changed proceed
...@@ -486,15 +503,14 @@ void *flowRunner(void *data) ...@@ -486,15 +503,14 @@ void *flowRunner(void *data)
// Hijack the queue change list items // Hijack the queue change list items
for (i = 0; i < NUM_PRIO_BANDS; i++) for (i = 0; i < NUM_PRIO_BANDS; i++)
{ {
// Copy list item over
queueChangeList[i] = runnerData->queueChangeList[i];
// Zero runner data if it is non-NULL // Zero runner data if it is non-NULL
if (runnerData->queueChangeList[i]) if (runnerData->queueChangeList[i])
{ {
runnerData->queueChangeList[i] = NULL; // Copy list item over
queueChangeList = g_list_concat(queueChangeList,runnerData->queueChangeList[i]);
// Blank used list... copy uses directly
runnerData->queueChangeList[i] = NULL;
} }
else
queueChangeList[i] = NULL;
} }
runnerData->queueChanged = 0; runnerData->queueChanged = 0;
...@@ -502,15 +518,11 @@ void *flowRunner(void *data) ...@@ -502,15 +518,11 @@ void *flowRunner(void *data)
g_mutex_unlock(runnerData->bandSignalLock); g_mutex_unlock(runnerData->bandSignalLock);
// Process all list // Process list if it is non-NULL
for (i = 0; i < NUM_PRIO_BANDS; i++) if (queueChangeList)
{ {
// Process list if it is non-NULL g_list_foreach(queueChangeList,processQueue,runnerData);
if (queueChangeList[i]) g_list_free(queueChangeList);
{
g_list_foreach(queueChangeList[i],processQueue,runnerData);
g_list_free(queueChangeList[i]);
}
} }
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment