[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r30082 - gnunet/src/mesh
From: |
gnunet |
Subject: |
[GNUnet-SVN] r30082 - gnunet/src/mesh |
Date: |
Thu, 10 Oct 2013 13:11:32 +0200 |
Author: bartpolot
Date: 2013-10-10 13:11:32 +0200 (Thu, 10 Oct 2013)
New Revision: 30082
Modified:
gnunet/src/mesh/gnunet-service-mesh_connection.c
gnunet/src/mesh/gnunet-service-mesh_peer.h
Log:
Calculate outgoing connection performance
Modified: gnunet/src/mesh/gnunet-service-mesh_connection.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_connection.c 2013-10-10 09:59:29 UTC
(rev 30081)
+++ gnunet/src/mesh/gnunet-service-mesh_connection.c 2013-10-10 11:11:32 UTC
(rev 30082)
@@ -106,11 +106,30 @@
struct GNUNET_TIME_Relative poll_time;
};
+/**
+ * Keep a record of the last messages sent on this connection.
+ */
struct MeshConnectionPerformance
{
- double secsperbyte[AVG_MSGS];
+ /**
+ * Circular buffer for storing measurements.
+ */
+ double usecsperbyte[AVG_MSGS];
- unsigned int idx;
+ /**
+ * Running average of @c usecsperbyte.
+ */
+ double avg;
+
+ /**
+ * How many values of @c usecsperbyte are valid.
+ */
+ uint16_t size;
+
+ /**
+ * Index of the next "free" position in @c usecsperbyte.
+ */
+ uint16_t idx;
};
@@ -383,16 +402,15 @@
t = connection->t;
LOG (GNUNET_ERROR_TYPE_DEBUG, "Send connection ack\n");
- queue_add (NULL,
- GNUNET_MESSAGE_TYPE_MESH_CONNECTION_ACK,
- sizeof (struct GNUNET_MESH_ConnectionACK),
- connection,
- NULL,
- fwd);
+ GMP_queue_add (NULL,
+ GNUNET_MESSAGE_TYPE_MESH_CONNECTION_ACK,
+ sizeof (struct GNUNET_MESH_ConnectionACK),
+ connection, NULL, fwd,
+ &message_sent, sizeof (struct GNUNET_MESH_ConnectionACK));
if (MESH_TUNNEL_NEW == t->state)
- tunnel_change_state (t, MESH_TUNNEL_WAITING);
+ GMT_change_state (t, MESH_TUNNEL_WAITING);
if (MESH_CONNECTION_READY != connection->state)
- connection_change_state (connection, MESH_CONNECTION_SENT);
+ GMC_change_state (connection, MESH_CONNECTION_SENT);
}
@@ -885,7 +903,9 @@
/**
- *
+ * Add the connection to the list of both neighbors.
+ *
+ * @param c Connection.
*/
static void
register_neighbors (struct MeshConnection *c)
@@ -910,7 +930,9 @@
/**
- *
+ * Remove the connection from the list of both neighbors.
+ *
+ * @param c Connection.
*/
static void
unregister_neighbors (struct MeshConnection *c)
@@ -926,6 +948,49 @@
}
+/**
+ * Callback called when a queued message is sent.
+ *
+ * Calculates the average time
+ *
+ * @param cls Closure.
+ * @param c Connection this message was on.
+ * @param wait Time spent waiting for core (only the time for THIS message)
+ */
+static void
+message_sent (void *cls,
+ struct MeshConnection *c,
+ struct GNUNET_TIME_Relative wait)
+{
+ struct MeshConnectionPerformance *p;
+ size_t size = (size_t) cls;
+ double usecsperbyte;
+
+ if (NULL == c->perf)
+ return; /* Only endpoints are interested in this. */
+
+ p = c->perf;
+ usecsperbyte = ((double) wait.rel_value_us) / size;
+ if (p->size == AVG_MSGS)
+ {
+ /* Array is full. Substract oldest value, add new one and store. */
+ p->avg -= (p->usecsperbyte[p->idx] / AVG_MSGS);
+ p->usecsperbyte[p->idx] = usecsperbyte;
+ p->avg += (p->usecsperbyte[p->idx] / AVG_MSGS);
+ }
+ else
+ {
+ /* Array not yet full. Add current value to avg and store. */
+ p->usecsperbyte[p->idx] = usecsperbyte;
+ p->avg *= p->size;
+ p->avg += p->usecsperbyte[p->idx];
+ p->size++;
+ p->avg /= p->size;
+ }
+ p->idx = (p->idx + 1) % AVG_MSGS;
+}
+
+
/******************************************************************************/
/******************************** API
***********************************/
/******************************************************************************/
@@ -1149,8 +1214,7 @@
tunnel_send_queued_data (c->t, GNUNET_YES);
if (3 <= tunnel_count_connections (c->t) && NULL != c->t->peer->dhtget)
{
- GNUNET_DHT_get_stop (c->t->peer->dhtget);
- c->t->peer->dhtget = NULL;
+ GMP_stop_search (c->t->peer);
}
return GNUNET_OK;
}
@@ -2034,12 +2098,7 @@
GNUNET_break (0);
}
- GMP_queue_add (data,
- type,
- size,
- c,
- ch,
- fwd);
+ GMP_queue_add (data, type, size, c, ch, fwd, &message_sent, (void *) size);
}
Modified: gnunet/src/mesh/gnunet-service-mesh_peer.h
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_peer.h 2013-10-10 09:59:29 UTC (rev
30081)
+++ gnunet/src/mesh/gnunet-service-mesh_peer.h 2013-10-10 11:11:32 UTC (rev
30082)
@@ -135,6 +135,12 @@
int
GMP_remove_connection (struct MeshPeer *peer, struct MeshConnection *c);
+void
+GMP_start_search (struct MeshPeer *peer);
+
+void
+GMP_start_search (struct MeshPeer *peer);
+
/**
* Get the Full ID of a peer.
*
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r30082 - gnunet/src/mesh,
gnunet <=