[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r27096 - gnunet/src/mesh
From: |
gnunet |
Subject: |
[GNUnet-SVN] r27096 - gnunet/src/mesh |
Date: |
Fri, 10 May 2013 19:20:46 +0200 |
Author: bartpolot
Date: 2013-05-10 19:20:46 +0200 (Fri, 10 May 2013)
New Revision: 27096
Modified:
gnunet/src/mesh/gnunet-service-mesh-new.c
gnunet/src/mesh/mesh2.h
gnunet/src/mesh/mesh_common.c
Log:
- Change hash to speed up 16/32 bit lookups
Modified: gnunet/src/mesh/gnunet-service-mesh-new.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh-new.c 2013-05-10 16:30:03 UTC (rev
27095)
+++ gnunet/src/mesh/gnunet-service-mesh-new.c 2013-05-10 17:20:46 UTC (rev
27096)
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- (C) 2001-2012 Christian Grothoff (and other contributing authors)
+ (C) 2001-2013 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
@@ -511,7 +511,8 @@
struct GNUNET_SERVER_Client *handle;
/**
- * Messages that this client has declared interest in
+ * Messages that this client has declared interest in.
+ * Indexed by a GMC_hash32 (type), contains *Client.
*/
struct GNUNET_CONTAINER_MultiHashMap *types;
@@ -1005,10 +1006,9 @@
*
* @return GNUNET_YES or GNUNET_NO, depending on subscription status
*
- * FIXME: use of crypto_hash slows it down
- * The hash function alone takes 8-10us out of the ~55us for the whole
+ * A real hash function alone takes 8-10us out of the ~55us for the whole
* process of retransmitting the message from one local client to another.
- * Find faster implementation!
+ * GMC_hash32 aim to imporve this speed.
*/
static int
client_is_subscribed (uint16_t message_type, struct MeshClient *c)
@@ -1018,7 +1018,7 @@
if (NULL == c->types)
return GNUNET_NO;
- GNUNET_CRYPTO_hash (&message_type, sizeof (uint16_t), &hc);
+ GMC_hash32 ((uint32_t) message_type, &hc);
return GNUNET_CONTAINER_multihashmap_contains (c->types, &hc);
}
@@ -4654,7 +4654,7 @@
{
u16 = ntohs (t[i]);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " msg type: %u\n", u16);
- GNUNET_CRYPTO_hash (&u16, sizeof (u16), &hc); // FIXME pseudo hash
+ GMC_hash32 ((uint32_t) u16, &hc);
/* store in clients hashmap */
GNUNET_CONTAINER_multihashmap_put (c->types, &hc, c,
Modified: gnunet/src/mesh/mesh2.h
===================================================================
--- gnunet/src/mesh/mesh2.h 2013-05-10 16:30:03 UTC (rev 27095)
+++ gnunet/src/mesh/mesh2.h 2013-05-10 17:20:46 UTC (rev 27096)
@@ -319,6 +319,18 @@
/**
+ * Expand a 32 bit value (message type) into a hash for a MultiHashMap (fast).
+ * WARNING: do not use for anything other than MultiHashMap!
+ * does not alter anything other than bits used by idx_of !
+ *
+ * @param i 32 bit integer value.
+ * @param h Hash code to fill.
+ */
+void
+GMC_hash32 (uint32_t i, struct GNUNET_HashCode *h);
+
+
+/**
* Convert a message type into a string to help debug
* Generated with:
* FIND: "#define ([^ ]+)[ ]*([0-9]+)"
Modified: gnunet/src/mesh/mesh_common.c
===================================================================
--- gnunet/src/mesh/mesh_common.c 2013-05-10 16:30:03 UTC (rev 27095)
+++ gnunet/src/mesh/mesh_common.c 2013-05-10 17:20:46 UTC (rev 27096)
@@ -27,14 +27,6 @@
#include "mesh.h"
-/**
- * Check if one pid is bigger than other, accounting for overflow.
- *
- * @param bigger Argument that should be bigger.
- * @param smaller Argument that should be smaller.
- *
- * @return True if bigger (arg1) has a higher value than smaller (arg 2).
- */
int
GMC_is_pid_bigger (uint32_t bigger, uint32_t smaller)
{
@@ -42,14 +34,7 @@
(bigger > smaller && GNUNET_NO == PID_OVERFLOW(bigger, smaller)));
}
-/**
- * Get the higher ACK value out of two values, taking in account overflow.
- *
- * @param a First ACK value.
- * @param b Second ACK value.
- *
- * @return Highest ACK value from the two.
- */
+
uint32_t
GMC_max_pid (uint32_t a, uint32_t b)
{
@@ -59,14 +44,6 @@
}
-/**
- * Get the lower ACK value out of two values, taking in account overflow.
- *
- * @param a First ACK value.
- * @param b Second ACK value.
- *
- * @return Lowest ACK value from the two.
- */
uint32_t
GMC_min_pid (uint32_t a, uint32_t b)
{
@@ -75,7 +52,13 @@
return a;
}
+void
+GMC_hash32 (uint32_t i, struct GNUNET_HashCode *h)
+{
+ *(unsigned int *) h = i;
+}
+
#if !defined(GNUNET_CULL_LOGGING)
const char *
GNUNET_MESH_DEBUG_M2S (uint16_t m)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r27096 - gnunet/src/mesh,
gnunet <=