diff options
author | Florian Dold <florian.dold@gmail.com> | 2015-10-07 22:01:03 +0000 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2015-10-07 22:01:03 +0000 |
commit | 383814672c031e49c4dffca0a69af3b0973d2248 (patch) | |
tree | 1c889a53a32ce6fd5786e23cd4f45e7de06db403 | |
parent | af432574e5009cc4748e512f6b78b43f40fdc19c (diff) | |
download | gnunet-383814672c031e49c4dffca0a69af3b0973d2248.tar.gz gnunet-383814672c031e49c4dffca0a69af3b0973d2248.zip |
statistics in set profiler, temp. fix for salt
-rw-r--r-- | src/set/Makefile.am | 1 | ||||
-rw-r--r-- | src/set/gnunet-service-set.c | 7 | ||||
-rw-r--r-- | src/set/gnunet-service-set_union.c | 13 | ||||
-rw-r--r-- | src/set/gnunet-set-profiler.c | 61 | ||||
-rw-r--r-- | src/set/ibf.c | 8 | ||||
-rw-r--r-- | src/set/test_set.conf | 2 |
6 files changed, 71 insertions, 21 deletions
diff --git a/src/set/Makefile.am b/src/set/Makefile.am index 5da0c564a..b4595d0e7 100644 --- a/src/set/Makefile.am +++ b/src/set/Makefile.am | |||
@@ -29,6 +29,7 @@ gnunet_set_profiler_SOURCES = \ | |||
29 | gnunet-set-profiler.c | 29 | gnunet-set-profiler.c |
30 | gnunet_set_profiler_LDADD = \ | 30 | gnunet_set_profiler_LDADD = \ |
31 | $(top_builddir)/src/util/libgnunetutil.la \ | 31 | $(top_builddir)/src/util/libgnunetutil.la \ |
32 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | ||
32 | libgnunetset.la \ | 33 | libgnunetset.la \ |
33 | $(top_builddir)/src/testing/libgnunettesting.la \ | 34 | $(top_builddir)/src/testing/libgnunettesting.la \ |
34 | $(GN_LIBINTL) | 35 | $(GN_LIBINTL) |
diff --git a/src/set/gnunet-service-set.c b/src/set/gnunet-service-set.c index cc172974e..cfddef6fb 100644 --- a/src/set/gnunet-service-set.c +++ b/src/set/gnunet-service-set.c | |||
@@ -827,12 +827,13 @@ execute_add (struct Set *set, | |||
827 | 827 | ||
828 | msg = (const struct GNUNET_SET_ElementMessage *) m; | 828 | msg = (const struct GNUNET_SET_ElementMessage *) m; |
829 | el.size = ntohs (m->size) - sizeof *msg; | 829 | el.size = ntohs (m->size) - sizeof *msg; |
830 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
831 | "Client inserts element of size %u\n", | ||
832 | el.size); | ||
833 | el.data = &msg[1]; | 830 | el.data = &msg[1]; |
834 | el.element_type = ntohs (msg->element_type); | 831 | el.element_type = ntohs (msg->element_type); |
835 | GNUNET_SET_element_hash (&el, &hash); | 832 | GNUNET_SET_element_hash (&el, &hash); |
833 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
834 | "Client inserts element %s of size %u\n", | ||
835 | GNUNET_h2s (&hash), | ||
836 | el.size); | ||
836 | 837 | ||
837 | ee = GNUNET_CONTAINER_multihashmap_get (set->content->elements, | 838 | ee = GNUNET_CONTAINER_multihashmap_get (set->content->elements, |
838 | &hash); | 839 | &hash); |
diff --git a/src/set/gnunet-service-set_union.c b/src/set/gnunet-service-set_union.c index 04fbba348..1c5dfe3fb 100644 --- a/src/set/gnunet-service-set_union.c +++ b/src/set/gnunet-service-set_union.c | |||
@@ -341,6 +341,10 @@ get_ibf_key (const struct GNUNET_HashCode *src, | |||
341 | { | 341 | { |
342 | struct IBF_Key key; | 342 | struct IBF_Key key; |
343 | 343 | ||
344 | /* FIXME: Ensure that the salt is handled correctly. | ||
345 | This is a quick fix so that consensus works for now. */ | ||
346 | salt = 0; | ||
347 | |||
344 | GNUNET_CRYPTO_kdf (&key, sizeof (key), | 348 | GNUNET_CRYPTO_kdf (&key, sizeof (key), |
345 | src, sizeof *src, | 349 | src, sizeof *src, |
346 | &salt, sizeof (salt), | 350 | &salt, sizeof (salt), |
@@ -499,7 +503,7 @@ init_key_to_element_iterator (void *cls, | |||
499 | */ | 503 | */ |
500 | static void | 504 | static void |
501 | prepare_ibf (struct Operation *op, | 505 | prepare_ibf (struct Operation *op, |
502 | uint16_t size) | 506 | uint32_t size) |
503 | { | 507 | { |
504 | if (NULL == op->state->key_to_element) | 508 | if (NULL == op->state->key_to_element) |
505 | { | 509 | { |
@@ -540,6 +544,12 @@ send_ibf (struct Operation *op, | |||
540 | "sending ibf of size %u\n", | 544 | "sending ibf of size %u\n", |
541 | 1<<ibf_order); | 545 | 1<<ibf_order); |
542 | 546 | ||
547 | { | ||
548 | char name[64] = { 0 }; | ||
549 | snprintf (name, sizeof (name), "# sent IBF (order %u)", ibf_order); | ||
550 | GNUNET_STATISTICS_update (_GSS_statistics, name, 1, GNUNET_NO); | ||
551 | } | ||
552 | |||
543 | ibf = op->state->local_ibf; | 553 | ibf = op->state->local_ibf; |
544 | 554 | ||
545 | while (buckets_sent < (1 << ibf_order)) | 555 | while (buckets_sent < (1 << ibf_order)) |
@@ -1116,7 +1126,6 @@ handle_p2p_elements (void *cls, | |||
1116 | "# repeated elements", | 1126 | "# repeated elements", |
1117 | 1, | 1127 | 1, |
1118 | GNUNET_NO); | 1128 | GNUNET_NO); |
1119 | GNUNET_break (0); | ||
1120 | GNUNET_free (ee); | 1129 | GNUNET_free (ee); |
1121 | } | 1130 | } |
1122 | else | 1131 | else |
diff --git a/src/set/gnunet-set-profiler.c b/src/set/gnunet-set-profiler.c index 2ee1b762d..4b6a1e202 100644 --- a/src/set/gnunet-set-profiler.c +++ b/src/set/gnunet-set-profiler.c | |||
@@ -25,6 +25,7 @@ | |||
25 | */ | 25 | */ |
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "gnunet_util_lib.h" | 27 | #include "gnunet_util_lib.h" |
28 | #include "gnunet_statistics_service.h" | ||
28 | #include "gnunet_set_service.h" | 29 | #include "gnunet_set_service.h" |
29 | #include "gnunet_testbed_service.h" | 30 | #include "gnunet_testbed_service.h" |
30 | 31 | ||
@@ -35,6 +36,8 @@ static unsigned int num_a = 5; | |||
35 | static unsigned int num_b = 5; | 36 | static unsigned int num_b = 5; |
36 | static unsigned int num_c = 20; | 37 | static unsigned int num_c = 20; |
37 | 38 | ||
39 | static unsigned int dump_statistics; | ||
40 | |||
38 | static char *op_str = "union"; | 41 | static char *op_str = "union"; |
39 | 42 | ||
40 | const static struct GNUNET_CONFIGURATION_Handle *config; | 43 | const static struct GNUNET_CONFIGURATION_Handle *config; |
@@ -57,6 +60,8 @@ static struct GNUNET_PeerIdentity local_peer; | |||
57 | 60 | ||
58 | static struct GNUNET_SET_ListenHandle *set_listener; | 61 | static struct GNUNET_SET_ListenHandle *set_listener; |
59 | 62 | ||
63 | static struct GNUNET_STATISTICS_Handle *statistics; | ||
64 | |||
60 | 65 | ||
61 | static int | 66 | static int |
62 | map_remove_iterator (void *cls, | 67 | map_remove_iterator (void *cls, |
@@ -76,6 +81,37 @@ map_remove_iterator (void *cls, | |||
76 | } | 81 | } |
77 | 82 | ||
78 | 83 | ||
84 | /** | ||
85 | * Callback function to process statistic values. | ||
86 | * | ||
87 | * @param cls closure | ||
88 | * @param subsystem name of subsystem that created the statistic | ||
89 | * @param name the name of the datum | ||
90 | * @param value the current value | ||
91 | * @param is_persistent #GNUNET_YES if the value is persistent, #GNUNET_NO if not | ||
92 | * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration | ||
93 | */ | ||
94 | static int | ||
95 | statistics_result (void *cls, | ||
96 | const char *subsystem, | ||
97 | const char *name, | ||
98 | uint64_t value, | ||
99 | int is_persistent) | ||
100 | { | ||
101 | printf ("stat %s/%s=%lu\n", subsystem, name, (unsigned long) value); | ||
102 | return GNUNET_OK; | ||
103 | } | ||
104 | |||
105 | |||
106 | static void | ||
107 | statistics_done (void *cls, | ||
108 | int success) | ||
109 | { | ||
110 | GNUNET_assert (GNUNET_YES == success); | ||
111 | printf("dumped statistics\n"); | ||
112 | GNUNET_SCHEDULER_shutdown (); | ||
113 | } | ||
114 | |||
79 | static void | 115 | static void |
80 | check_all_done (void) | 116 | check_all_done (void) |
81 | { | 117 | { |
@@ -88,7 +124,14 @@ check_all_done (void) | |||
88 | printf ("set a: %d missing elements\n", GNUNET_CONTAINER_multihashmap_size (info1.sent)); | 124 | printf ("set a: %d missing elements\n", GNUNET_CONTAINER_multihashmap_size (info1.sent)); |
89 | printf ("set b: %d missing elements\n", GNUNET_CONTAINER_multihashmap_size (info2.sent)); | 125 | printf ("set b: %d missing elements\n", GNUNET_CONTAINER_multihashmap_size (info2.sent)); |
90 | 126 | ||
91 | GNUNET_SCHEDULER_shutdown (); | 127 | if (0 == dump_statistics) |
128 | { | ||
129 | GNUNET_SCHEDULER_shutdown (); | ||
130 | return; | ||
131 | } | ||
132 | |||
133 | GNUNET_STATISTICS_get (statistics, NULL, NULL, GNUNET_TIME_UNIT_FOREVER_REL, | ||
134 | statistics_done, statistics_result, NULL); | ||
92 | } | 135 | } |
93 | 136 | ||
94 | 137 | ||
@@ -215,6 +258,7 @@ handle_shutdown (void *cls, | |||
215 | GNUNET_SET_destroy (info2.set); | 258 | GNUNET_SET_destroy (info2.set); |
216 | info2.set = NULL; | 259 | info2.set = NULL; |
217 | } | 260 | } |
261 | GNUNET_STATISTICS_destroy (statistics, GNUNET_NO); | ||
218 | } | 262 | } |
219 | 263 | ||
220 | 264 | ||
@@ -225,7 +269,6 @@ run (void *cls, | |||
225 | { | 269 | { |
226 | unsigned int i; | 270 | unsigned int i; |
227 | struct GNUNET_HashCode hash; | 271 | struct GNUNET_HashCode hash; |
228 | struct GNUNET_HashCode hashhash; | ||
229 | 272 | ||
230 | config = cfg; | 273 | config = cfg; |
231 | 274 | ||
@@ -236,6 +279,8 @@ run (void *cls, | |||
236 | return; | 279 | return; |
237 | } | 280 | } |
238 | 281 | ||
282 | statistics = GNUNET_STATISTICS_create ("set-profiler", cfg); | ||
283 | |||
239 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, handle_shutdown, NULL); | 284 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, handle_shutdown, NULL); |
240 | 285 | ||
241 | info1.id = "a"; | 286 | info1.id = "a"; |
@@ -251,9 +296,6 @@ run (void *cls, | |||
251 | for (i = 0; i < num_a; i++) | 296 | for (i = 0; i < num_a; i++) |
252 | { | 297 | { |
253 | GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_STRONG, &hash); | 298 | GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_STRONG, &hash); |
254 | GNUNET_CRYPTO_hash (&hash, sizeof (struct GNUNET_HashCode), &hashhash); | ||
255 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Set a: Created element %s\n", | ||
256 | GNUNET_h2s (&hashhash)); | ||
257 | GNUNET_CONTAINER_multihashmap_put (info1.sent, &hash, NULL, | 299 | GNUNET_CONTAINER_multihashmap_put (info1.sent, &hash, NULL, |
258 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE); | 300 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE); |
259 | } | 301 | } |
@@ -261,9 +303,6 @@ run (void *cls, | |||
261 | for (i = 0; i < num_b; i++) | 303 | for (i = 0; i < num_b; i++) |
262 | { | 304 | { |
263 | GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_STRONG, &hash); | 305 | GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_STRONG, &hash); |
264 | GNUNET_CRYPTO_hash (&hash, sizeof (struct GNUNET_HashCode), &hashhash); | ||
265 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Set b: Created element %s\n", | ||
266 | GNUNET_h2s (&hashhash)); | ||
267 | GNUNET_CONTAINER_multihashmap_put (info2.sent, &hash, NULL, | 306 | GNUNET_CONTAINER_multihashmap_put (info2.sent, &hash, NULL, |
268 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE); | 307 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE); |
269 | } | 308 | } |
@@ -271,9 +310,6 @@ run (void *cls, | |||
271 | for (i = 0; i < num_c; i++) | 310 | for (i = 0; i < num_c; i++) |
272 | { | 311 | { |
273 | GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_STRONG, &hash); | 312 | GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_STRONG, &hash); |
274 | GNUNET_CRYPTO_hash (&hash, sizeof (struct GNUNET_HashCode), &hashhash); | ||
275 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Set c: Created element %s\n", | ||
276 | GNUNET_h2s (&hashhash)); | ||
277 | GNUNET_CONTAINER_multihashmap_put (common_sent, &hash, NULL, | 313 | GNUNET_CONTAINER_multihashmap_put (common_sent, &hash, NULL, |
278 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE); | 314 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE); |
279 | } | 315 | } |
@@ -328,6 +364,9 @@ main (int argc, char **argv) | |||
328 | { 'x', "operation", NULL, | 364 | { 'x', "operation", NULL, |
329 | gettext_noop ("operation to execute"), | 365 | gettext_noop ("operation to execute"), |
330 | GNUNET_YES, &GNUNET_GETOPT_set_string, &op_str }, | 366 | GNUNET_YES, &GNUNET_GETOPT_set_string, &op_str }, |
367 | { 's', "statistics", NULL, | ||
368 | gettext_noop ("dump statistics to stdout after completion"), | ||
369 | GNUNET_NO, &GNUNET_GETOPT_set_one, &dump_statistics }, | ||
331 | GNUNET_GETOPT_OPTION_END | 370 | GNUNET_GETOPT_OPTION_END |
332 | }; | 371 | }; |
333 | GNUNET_PROGRAM_run2 (argc, argv, "gnunet-set-profiler", | 372 | GNUNET_PROGRAM_run2 (argc, argv, "gnunet-set-profiler", |
diff --git a/src/set/ibf.c b/src/set/ibf.c index 83cbafc65..19d15a5b2 100644 --- a/src/set/ibf.c +++ b/src/set/ibf.c | |||
@@ -76,12 +76,12 @@ ibf_create (uint32_t size, uint8_t hash_num) | |||
76 | { | 76 | { |
77 | struct InvertibleBloomFilter *ibf; | 77 | struct InvertibleBloomFilter *ibf; |
78 | 78 | ||
79 | /* TODO: use malloc_large */ | 79 | GNUNET_assert (0 != size); |
80 | 80 | ||
81 | ibf = GNUNET_new (struct InvertibleBloomFilter); | 81 | ibf = GNUNET_new (struct InvertibleBloomFilter); |
82 | ibf->count = GNUNET_malloc (size * sizeof (uint8_t)); | 82 | ibf->count = GNUNET_malloc_large (size * sizeof (uint8_t)); |
83 | ibf->key_sum = GNUNET_malloc (size * sizeof (struct IBF_Key)); | 83 | ibf->key_sum = GNUNET_malloc_large (size * sizeof (struct IBF_Key)); |
84 | ibf->key_hash_sum = GNUNET_malloc (size * sizeof (struct IBF_KeyHash)); | 84 | ibf->key_hash_sum = GNUNET_malloc_large (size * sizeof (struct IBF_KeyHash)); |
85 | ibf->size = size; | 85 | ibf->size = size; |
86 | ibf->hash_num = hash_num; | 86 | ibf->hash_num = hash_num; |
87 | 87 | ||
diff --git a/src/set/test_set.conf b/src/set/test_set.conf index ae7708c2d..30ccbde55 100644 --- a/src/set/test_set.conf +++ b/src/set/test_set.conf | |||
@@ -5,7 +5,7 @@ GNUNET_TEST_HOME = /tmp/test-gnunet-set/ | |||
5 | 5 | ||
6 | [set] | 6 | [set] |
7 | AUTOSTART = YES | 7 | AUTOSTART = YES |
8 | #PREFIX = valgrind | 8 | PREFIX = valgrind |
9 | #PREFIX = valgrind --leak-check=full | 9 | #PREFIX = valgrind --leak-check=full |
10 | #PREFIX = gdbserver :1234 | 10 | #PREFIX = gdbserver :1234 |
11 | OPTIONS = -L INFO | 11 | OPTIONS = -L INFO |