[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet] branch master updated: try to fix BF size mess cre
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet] branch master updated: try to fix BF size mess created by original BLOCK API change |
Date: |
Wed, 22 Feb 2017 11:40:49 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository gnunet.
The following commit(s) were added to refs/heads/master by this push:
new ac95589b0 try to fix BF size mess created by original BLOCK API change
ac95589b0 is described below
commit ac95589b0c3f54a7991b1461028fdb5e47c887db
Author: Christian Grothoff <address@hidden>
AuthorDate: Wed Feb 22 11:40:46 2017 +0100
try to fix BF size mess created by original BLOCK API change
---
src/dht/gnunet-service-dht_clients.c | 4 ++-
src/dht/gnunet-service-dht_neighbours.c | 6 +++-
src/dht/plugin_block_dht.c | 57 ++++++++++++++++++++++++++++++---
src/fs/plugin_block_fs.c | 3 +-
4 files changed, 62 insertions(+), 8 deletions(-)
diff --git a/src/dht/gnunet-service-dht_clients.c
b/src/dht/gnunet-service-dht_clients.c
index a42356e5f..c304f2e54 100644
--- a/src/dht/gnunet-service-dht_clients.c
+++ b/src/dht/gnunet-service-dht_clients.c
@@ -374,7 +374,9 @@ transmit_request (struct ClientQueryRecord *cqr)
GNUNET_CRYPTO_random_u32
(GNUNET_CRYPTO_QUALITY_WEAK,
UINT32_MAX),
NULL,
- 0);
+ 0,
+ "seen-set-size",
+ cqr->seen_replies_count);
GNUNET_BLOCK_group_set_seen (bg,
cqr->seen_replies,
cqr->seen_replies_count);
diff --git a/src/dht/gnunet-service-dht_neighbours.c
b/src/dht/gnunet-service-dht_neighbours.c
index 975872f1b..6eef05c20 100644
--- a/src/dht/gnunet-service-dht_neighbours.c
+++ b/src/dht/gnunet-service-dht_neighbours.c
@@ -661,7 +661,9 @@ send_find_peer_message (void *cls)
GNUNET_CRYPTO_random_u32
(GNUNET_CRYPTO_QUALITY_WEAK,
UINT32_MAX),
NULL,
- 0);
+ 0,
+ "filter-size",
+ DHT_BLOOM_SIZE);
GNUNET_CONTAINER_multipeermap_iterate (all_connected_peers,
&add_known_to_bloom,
bg);
@@ -2087,6 +2089,8 @@ handle_dht_p2p_get (void *cls,
type,
get->bf_mutator,
&xquery[xquery_size],
+ reply_bf_size,
+ "filter-size",
reply_bf_size);
/* remember request for routing replies */
GDS_ROUTING_add (peer->id,
diff --git a/src/dht/plugin_block_dht.c b/src/dht/plugin_block_dht.c
index 168497440..869ec1554 100644
--- a/src/dht/plugin_block_dht.c
+++ b/src/dht/plugin_block_dht.c
@@ -34,9 +34,41 @@
#define DEBUG_DHT GNUNET_EXTRA_LOGGING
/**
- * How big is the BF we use for DHT blocks?
+ * Number of bits we set per entry in the bloomfilter.
+ * Do not change!
*/
-#define DHT_BF_SIZE 8
+#define BLOOMFILTER_K 16
+
+
+/**
+ * How many bytes should a bloomfilter be if we have already seen
+ * entry_count responses? Note that #GNUNET_CONSTANTS_BLOOMFILTER_K
+ * gives us the number of bits set per entry. Furthermore, we should
+ * not re-size the filter too often (to keep it cheap).
+ *
+ * Since other peers will also add entries but not resize the filter,
+ * we should generally pick a slightly larger size than what the
+ * strict math would suggest.
+ *
+ * @param entry_count expected number of entries in the Bloom filter
+ * @return must be a power of two and smaller or equal to 2^15.
+ */
+static size_t
+compute_bloomfilter_size (unsigned int entry_count)
+{
+ size_t size;
+ unsigned int ideal = (entry_count * BLOOMFILTER_K) / 4;
+ uint16_t max = 1 << 15;
+
+ if (entry_count > max)
+ return max;
+ size = 8;
+ while ((size < max) && (size < ideal))
+ size *= 2;
+ if (size > max)
+ return max;
+ return size;
+}
/**
@@ -59,9 +91,26 @@ block_plugin_dht_create_group (void *cls,
size_t raw_data_size,
va_list va)
{
+ unsigned int bf_size;
+ const char *guard;
+
+ guard = va_arg (va, const char *);
+ if (0 != memcmp (guard,
+ "seen-set-size",
+ strlen ("seen-set-size")))
+ bf_size = compute_bloomfilter_size (va_arg (va, unsigned int));
+ else if (0 == memcmp (va_arg (va, const char *),
+ "filter-size",
+ strlen ("filter-size")))
+ bf_size = va_arg (va, unsigned int);
+ else
+ {
+ GNUNET_break (0);
+ bf_size = 8;
+ }
return GNUNET_BLOCK_GROUP_bf_create (cls,
- DHT_BF_SIZE,
- GNUNET_CONSTANTS_BLOOMFILTER_K,
+ bf_size,
+ BLOOMFILTER_K,
type,
nonce,
raw_data,
diff --git a/src/fs/plugin_block_fs.c b/src/fs/plugin_block_fs.c
index 6c574fca2..5ccbd237e 100644
--- a/src/fs/plugin_block_fs.c
+++ b/src/fs/plugin_block_fs.c
@@ -28,7 +28,6 @@
#include "gnunet_fs_service.h"
#include "block_fs.h"
#include "gnunet_signatures.h"
-#include "gnunet_constants.h"
#include "gnunet_block_group_lib.h"
@@ -56,7 +55,7 @@ static size_t
compute_bloomfilter_size (unsigned int entry_count)
{
size_t size;
- unsigned int ideal = (entry_count * GNUNET_CONSTANTS_BLOOMFILTER_K) / 4;
+ unsigned int ideal = (entry_count * BLOOMFILTER_K) / 4;
uint16_t max = 1 << 15;
if (entry_count > max)
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [gnunet] branch master updated: try to fix BF size mess created by original BLOCK API change,
gnunet <=