GNUnet  0.11.x
Data Structures | Functions | Variables
gnunet-set-profiler.c File Reference

profiling tool for set More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_statistics_service.h"
#include "gnunet_set_service.h"
#include "gnunet_testbed_service.h"
Include dependency graph for gnunet-set-profiler.c:

Go to the source code of this file.

Data Structures

struct  SetInfo
 

Functions

static int map_remove_iterator (void *cls, const struct GNUNET_HashCode *key, void *value)
 
static int statistics_result (void *cls, const char *subsystem, const char *name, uint64_t value, int is_persistent)
 Callback function to process statistic values. More...
 
static void statistics_done (void *cls, int success)
 
static void check_all_done (void)
 
static void set_result_cb (void *cls, const struct GNUNET_SET_Element *element, uint64_t current_size, enum GNUNET_SET_Status status)
 
static void set_listen_cb (void *cls, const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_MessageHeader *context_msg, struct GNUNET_SET_Request *request)
 
static int set_insert_iterator (void *cls, const struct GNUNET_HashCode *key, void *value)
 
static void handle_shutdown (void *cls)
 
static void run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Peer *peer)
 
static void pre_run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
 
int main (int argc, char **argv)
 

Variables

static int ret
 
static unsigned int num_a = 5
 
static unsigned int num_b = 5
 
static unsigned int num_c = 20
 
static char * op_str = "union"
 
static const struct GNUNET_CONFIGURATION_Handleconfig
 
struct SetInfo info1
 
struct SetInfo info2
 
static struct GNUNET_CONTAINER_MultiHashMapcommon_sent
 
static struct GNUNET_HashCode app_id
 
static struct GNUNET_PeerIdentity local_peer
 
static struct GNUNET_SET_ListenHandleset_listener
 
static int byzantine
 
static unsigned int force_delta
 
static unsigned int force_full
 
static unsigned int element_size = 32
 
static struct GNUNET_STATISTICS_Handlestatistics
 Handle to the statistics service. More...
 
static char * statistics_filename
 The profiler will write statistics for all peers to the file with this name. More...
 
static FILE * statistics_file
 The profiler will write statistics for all peers to this file. More...
 

Detailed Description

profiling tool for set

Author
Florian Dold

Definition in file gnunet-set-profiler.c.

Function Documentation

◆ map_remove_iterator()

static int map_remove_iterator ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Definition at line 85 of file gnunet-set-profiler.c.

References GNUNET_assert, GNUNET_CONTAINER_multihashmap_remove_all(), GNUNET_OK, GNUNET_YES, m, and ret.

Referenced by check_all_done().

88 {
89  struct GNUNET_CONTAINER_MultiHashMap *m = cls;
90  int ret;
91 
92  GNUNET_assert (NULL != key);
93 
95  if (GNUNET_OK != ret)
96  printf ("spurious element\n");
97  return GNUNET_YES;
98 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
int GNUNET_CONTAINER_multihashmap_remove_all(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Remove all entries for the given key from the map.
Internal representation of the hash map.
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:104
static int ret
#define GNUNET_YES
Definition: gnunet_common.h:77
Here is the call graph for this function:
Here is the caller graph for this function:

◆ statistics_result()

static int statistics_result ( void *  cls,
const char *  subsystem,
const char *  name,
uint64_t  value,
int  is_persistent 
)
static

Callback function to process statistic values.

Parameters
clsclosure
subsystemname of subsystem that created the statistic
namethe name of the datum
valuethe current value
is_persistentGNUNET_YES if the value is persistent, GNUNET_NO if not
Returns
GNUNET_OK to continue, GNUNET_SYSERR to abort iteration

Definition at line 112 of file gnunet-set-profiler.c.

References GNUNET_OK, and statistics_file.

Referenced by check_all_done().

117 {
118  if (NULL != statistics_file)
119  {
120  fprintf (statistics_file, "%s\t%s\t%lu\n", subsystem, name, (unsigned
121  long) value);
122  }
123  return GNUNET_OK;
124 }
static char * subsystem
Set to subsystem that we're going to get stats for (or NULL for all).
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
static char * value
Value of the record to add/remove.
static FILE * statistics_file
The profiler will write statistics for all peers to this file.
const char * name
Here is the caller graph for this function:

◆ statistics_done()

static void statistics_done ( void *  cls,
int  success 
)
static

Definition at line 128 of file gnunet-set-profiler.c.

References GNUNET_assert, GNUNET_SCHEDULER_shutdown(), GNUNET_YES, and statistics_file.

Referenced by check_all_done().

130 {
131  GNUNET_assert (GNUNET_YES == success);
132  if (NULL != statistics_file)
133  fclose (statistics_file);
135 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:526
static FILE * statistics_file
The profiler will write statistics for all peers to this file.
#define GNUNET_YES
Definition: gnunet_common.h:77
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_all_done()

static void check_all_done ( void  )
static

Definition at line 139 of file gnunet-set-profiler.c.

References SetInfo::done, GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_CONTAINER_multihashmap_size(), GNUNET_NO, GNUNET_SCHEDULER_shutdown(), GNUNET_STATISTICS_get(), info1, info2, map_remove_iterator(), SetInfo::received, SetInfo::sent, statistics_done(), statistics_file, statistics_filename, and statistics_result().

Referenced by set_result_cb().

140 {
141  if ((info1.done == GNUNET_NO) || (info2.done == GNUNET_NO))
142  return;
143 
145  info2.sent);
147  info1.sent);
148 
149  printf ("set a: %d missing elements\n", GNUNET_CONTAINER_multihashmap_size (
150  info1.sent));
151  printf ("set b: %d missing elements\n", GNUNET_CONTAINER_multihashmap_size (
152  info2.sent));
153 
154  if (NULL == statistics_filename)
155  {
157  return;
158  }
159 
160  statistics_file = fopen (statistics_filename, "w");
161  GNUNET_STATISTICS_get (statistics, NULL, NULL,
163  &statistics_result, NULL);
164 }
static struct GNUNET_STATISTICS_Handle * statistics
Handle to the statistics service.
unsigned int GNUNET_CONTAINER_multihashmap_size(const struct GNUNET_CONTAINER_MultiHashMap *map)
Get the number of key-value pairs in the map.
#define GNUNET_NO
Definition: gnunet_common.h:78
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:526
static void statistics_done(void *cls, int success)
struct GNUNET_CONTAINER_MultiHashMap * received
static int map_remove_iterator(void *cls, const struct GNUNET_HashCode *key, void *value)
static int statistics_result(void *cls, const char *subsystem, const char *name, uint64_t value, int is_persistent)
Callback function to process statistic values.
static char * statistics_filename
The profiler will write statistics for all peers to the file with this name.
static FILE * statistics_file
The profiler will write statistics for all peers to this file.
struct SetInfo info1
struct GNUNET_STATISTICS_GetHandle * GNUNET_STATISTICS_get(struct GNUNET_STATISTICS_Handle *handle, const char *subsystem, const char *name, GNUNET_STATISTICS_Callback cont, GNUNET_STATISTICS_Iterator proc, void *cls)
Get statistic from the peer.
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
struct SetInfo info2
struct GNUNET_CONTAINER_MultiHashMap * sent
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_result_cb()

static void set_result_cb ( void *  cls,
const struct GNUNET_SET_Element element,
uint64_t  current_size,
enum GNUNET_SET_Status  status 
)
static

Definition at line 168 of file gnunet-set-profiler.c.

References check_all_done(), GNUNET_SET_Element::data, SetInfo::done, element_size, GNUNET_assert, GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE, GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_h2s(), GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_shutdown(), GNUNET_SET_STATUS_ADD_LOCAL, GNUNET_SET_STATUS_ADD_REMOTE, GNUNET_SET_STATUS_DONE, GNUNET_SET_STATUS_FAILURE, GNUNET_SET_STATUS_HALF_DONE, GNUNET_YES, SetInfo::id, SetInfo::oh, SetInfo::received, and GNUNET_SET_Element::size.

Referenced by run(), and set_listen_cb().

172 {
173  struct SetInfo *info = cls;
174  struct GNUNET_HashCode hash;
175 
176  GNUNET_assert (GNUNET_NO == info->done);
177  switch (status)
178  {
181  info->done = GNUNET_YES;
182  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "set %s done\n", info->id);
183  check_all_done ();
184  info->oh = NULL;
185  return;
186 
188  info->oh = NULL;
189  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "failure\n");
191  return;
192 
194  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "set %s: local element\n", info->id);
195  break;
196 
198  GNUNET_CRYPTO_hash (element->data, element->size, &hash);
199  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "set %s: remote element %s\n", info->id,
200  GNUNET_h2s (&hash));
201  // XXX: record and check
202  return;
203 
204  default:
205  GNUNET_assert (0);
206  }
207 
208  if (element->size != element_size)
209  {
211  "wrong element size: %u, expected %u\n",
212  element->size,
213  (unsigned int) sizeof(struct GNUNET_HashCode));
214  GNUNET_assert (0);
215  }
216 
217  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "set %s: got element (%s)\n",
218  info->id, GNUNET_h2s (element->data));
219  GNUNET_assert (NULL != element->data);
220  struct GNUNET_HashCode data_hash;
221  GNUNET_CRYPTO_hash (element->data, element_size, &data_hash);
223  &data_hash, NULL,
225 }
static unsigned int element_size
If a value with the given key exists, replace it.
Element should be added to the result set of the remote peer, i.e.
Element should be added to the result set of the local peer, i.e.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_NO
Definition: gnunet_common.h:78
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:526
Success, all elements have been sent (and received).
const void * data
Actual data of the element.
struct GNUNET_CONTAINER_MultiHashMap * received
The other peer refused to to the operation with us, or something went wrong.
Success, all elements have been returned (but the other peer might still be receiving some from us...
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:48
uint16_t status
See PRISM_STATUS_*-constants.
A 512-bit hashcode.
static void check_all_done(void)
int GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
uint16_t size
Number of bytes in the buffer pointed to by data.
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:77
struct GNUNET_SET_OperationHandle * oh
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_listen_cb()

static void set_listen_cb ( void *  cls,
const struct GNUNET_PeerIdentity other_peer,
const struct GNUNET_MessageHeader context_msg,
struct GNUNET_SET_Request request 
)
static

Definition at line 229 of file gnunet-set-profiler.c.

References byzantine, force_delta, force_full, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_SET_accept(), GNUNET_SET_commit(), GNUNET_SET_OPTION_BYZANTINE, GNUNET_SET_OPTION_FORCE_DELTA, GNUNET_SET_OPTION_FORCE_FULL, GNUNET_SET_RESULT_SYMMETRIC, info2, SetInfo::oh, SetInfo::set, set_result_cb(), and GNUNET_SET_Option::type.

Referenced by run().

233 {
234  /* max. 2 options plus terminator */
235  struct GNUNET_SET_Option opts[3] = { { 0 } };
236  unsigned int n_opts = 0;
237 
238  if (NULL == request)
239  {
241  "listener failed\n");
242  return;
243  }
244  GNUNET_assert (NULL == info2.oh);
246  "set listen cb called\n");
247  if (byzantine)
248  {
249  opts[n_opts++] = (struct GNUNET_SET_Option) { .type =
251  }
253  if (force_full)
254  {
255  opts[n_opts++] = (struct GNUNET_SET_Option) { .type =
257  }
258  if (force_delta)
259  {
260  opts[n_opts++] = (struct GNUNET_SET_Option) { .type =
262  }
263 
264  opts[n_opts].type = 0;
266  opts,
267  set_result_cb, &info2);
269 }
static int byzantine
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Do not use the optimized set operation, but send full sets.
static unsigned int force_full
enum GNUNET_SET_OptionType type
Type of the option.
Only use optimized set operations, even though for this particular set operation they might be much s...
Client gets notified of the required changes for both the local and the remote set.
Option for set operations.
int GNUNET_SET_commit(struct GNUNET_SET_OperationHandle *oh, struct GNUNET_SET_Handle *set)
Commit a set to be used with a set operation.
Definition: set_api.c:1128
struct GNUNET_SET_Handle * set
#define GNUNET_log(kind,...)
struct GNUNET_SET_OperationHandle * oh
static void set_result_cb(void *cls, const struct GNUNET_SET_Element *element, uint64_t current_size, enum GNUNET_SET_Status status)
static unsigned int force_delta
struct SetInfo info2
struct GNUNET_SET_OperationHandle * GNUNET_SET_accept(struct GNUNET_SET_Request *request, enum GNUNET_SET_ResultMode result_mode, struct GNUNET_SET_Option options[], GNUNET_SET_ResultIterator result_cb, void *result_cls)
Accept a request we got via GNUNET_SET_listen().
Definition: set_api.c:1085
Fail set operations when the other peer shows weird behavior that might by a Byzantine fault...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_insert_iterator()

static int set_insert_iterator ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Definition at line 273 of file gnunet-set-profiler.c.

References GNUNET_SET_Element::data, element_size, GNUNET_SET_Element::element_type, GNUNET_SET_add_element(), GNUNET_YES, GNUNET_SET_Element::size, and value.

Referenced by run().

276 {
277  struct GNUNET_SET_Handle *set = cls;
278  struct GNUNET_SET_Element el;
279 
280  el.element_type = 0;
281  el.data = value;
282  el.size = element_size;
283  GNUNET_SET_add_element (set, &el, NULL, NULL);
284  return GNUNET_YES;
285 }
static unsigned int element_size
int GNUNET_SET_add_element(struct GNUNET_SET_Handle *set, const struct GNUNET_SET_Element *element, GNUNET_SET_Continuation cont, void *cont_cls)
Add an element to the given set.
Definition: set_api.c:687
Element stored in a set.
static char * value
Value of the record to add/remove.
Opaque handle to a set.
Definition: set_api.c:49
#define GNUNET_YES
Definition: gnunet_common.h:77
static struct GNUNET_IDENTITY_EgoLookup * el
EgoLookup.
Definition: gnunet-abd.c:51
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_shutdown()

static void handle_shutdown ( void *  cls)
static

Definition at line 289 of file gnunet-set-profiler.c.

References GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_NO, GNUNET_SET_destroy(), GNUNET_SET_listen_cancel(), GNUNET_SET_operation_cancel(), GNUNET_STATISTICS_destroy(), info1, info2, SetInfo::oh, and SetInfo::set.

Referenced by run().

290 {
292  "Shutting down set profiler\n");
293  if (NULL != set_listener)
294  {
296  set_listener = NULL;
297  }
298  if (NULL != info1.oh)
299  {
301  info1.oh = NULL;
302  }
303  if (NULL != info2.oh)
304  {
306  info2.oh = NULL;
307  }
308  if (NULL != info1.set)
309  {
311  info1.set = NULL;
312  }
313  if (NULL != info2.set)
314  {
316  info2.set = NULL;
317  }
319 }
static struct GNUNET_STATISTICS_Handle * statistics
Handle to the statistics service.
#define GNUNET_NO
Definition: gnunet_common.h:78
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
void GNUNET_SET_destroy(struct GNUNET_SET_Handle *set)
Destroy the set handle, and free all associated resources.
Definition: set_api.c:772
static struct GNUNET_SET_ListenHandle * set_listener
void GNUNET_SET_listen_cancel(struct GNUNET_SET_ListenHandle *lh)
Cancel the given listen operation.
Definition: set_api.c:1051
struct SetInfo info1
struct GNUNET_SET_Handle * set
#define GNUNET_log(kind,...)
void GNUNET_SET_operation_cancel(struct GNUNET_SET_OperationHandle *oh)
Cancel the given set operation.
Definition: set_api.c:516
struct GNUNET_SET_OperationHandle * oh
struct SetInfo info2
Here is the call graph for this function:
Here is the caller graph for this function:

◆ run()

static void run ( void *  cls,
const struct GNUNET_CONFIGURATION_Handle cfg,
struct GNUNET_TESTING_Peer peer 
)
static

Definition at line 323 of file gnunet-set-profiler.c.

References app_id, byzantine, cfg, data, element_size, force_delta, force_full, GNUNET_assert, GNUNET_CONTAINER_multihashmap_create(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE, GNUNET_CRYPTO_get_peer_identity(), GNUNET_CRYPTO_hash(), GNUNET_CRYPTO_hash_create_random(), GNUNET_CRYPTO_QUALITY_STRONG, GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_block(), GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_malloc, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_shutdown(), GNUNET_SET_commit(), GNUNET_SET_create(), GNUNET_SET_destroy(), GNUNET_SET_listen(), GNUNET_SET_OPERATION_UNION, GNUNET_SET_OPTION_BYZANTINE, GNUNET_SET_OPTION_FORCE_DELTA, GNUNET_SET_OPTION_FORCE_FULL, GNUNET_SET_prepare(), GNUNET_SET_RESULT_SYMMETRIC, GNUNET_STATISTICS_create(), handle_shutdown(), SetInfo::id, info1, info2, local_peer, num_a, num_b, num_c, SetInfo::oh, SetInfo::received, ret, SetInfo::sent, SetInfo::set, set_insert_iterator(), set_listen_cb(), set_result_cb(), and GNUNET_SET_Option::type.

Referenced by pre_run().

326 {
327  unsigned int i;
328  struct GNUNET_HashCode hash;
329  /* max. 2 options plus terminator */
330  struct GNUNET_SET_Option opts[3] = { { 0 } };
331  unsigned int n_opts = 0;
332 
333  config = cfg;
334 
336 
338  {
339  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "could not retrieve host identity\n");
340  ret = 0;
341  return;
342  }
343 
344  statistics = GNUNET_STATISTICS_create ("set-profiler", cfg);
345 
347 
348  info1.id = "a";
349  info2.id = "b";
350 
354 
357 
358  for (i = 0; i < num_a; i++)
359  {
360  char *data = GNUNET_malloc (element_size);
362  GNUNET_CRYPTO_hash (data, element_size, &hash);
365  }
366 
367  for (i = 0; i < num_b; i++)
368  {
369  char *data = GNUNET_malloc (element_size);
371  GNUNET_CRYPTO_hash (data, element_size, &hash);
374  }
375 
376  for (i = 0; i < num_c; i++)
377  {
378  char *data = GNUNET_malloc (element_size);
380  GNUNET_CRYPTO_hash (data, element_size, &hash);
383  }
384 
386 
387  /* FIXME: also implement intersection etc. */
390 
392  info1.set);
394  info2.set);
396  info1.set);
398  info2.set);
399 
401  &app_id, set_listen_cb, NULL);
402 
403 
404  if (byzantine)
405  {
406  opts[n_opts++] = (struct GNUNET_SET_Option) { .type =
408  }
410  if (force_full)
411  {
412  opts[n_opts++] = (struct GNUNET_SET_Option) { .type =
414  }
415  if (force_delta)
416  {
417  opts[n_opts++] = (struct GNUNET_SET_Option) { .type =
419  }
420 
421  opts[n_opts].type = 0;
422 
425  opts,
426  set_result_cb, &info1);
429  info1.set = NULL;
430 }
static struct GNUNET_STATISTICS_Handle * statistics
Handle to the statistics service.
struct GNUNET_SET_ListenHandle * GNUNET_SET_listen(const struct GNUNET_CONFIGURATION_Handle *cfg, enum GNUNET_SET_OperationType op_type, const struct GNUNET_HashCode *app_id, GNUNET_SET_ListenCallback listen_cb, void *listen_cls)
Wait for set operation requests for the given application ID.
Definition: set_api.c:1017
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static unsigned int element_size
static int byzantine
If a value with the given key exists, replace it.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received, or when GNUNET_SCHEDULER_shutdown() is being invoked.
Definition: scheduler.c:1300
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
struct GNUNET_SET_Handle * GNUNET_SET_create(const struct GNUNET_CONFIGURATION_Handle *cfg, enum GNUNET_SET_OperationType op)
Create an empty set, supporting the specified operation.
Definition: set_api.c:657
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Do not use the optimized set operation, but send full sets.
static void set_listen_cb(void *cls, const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_MessageHeader *context_msg, struct GNUNET_SET_Request *request)
static unsigned int num_b
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
static struct GNUNET_HashCode app_id
struct GNUNET_SET_OperationHandle * GNUNET_SET_prepare(const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_HashCode *app_id, const struct GNUNET_MessageHeader *context_msg, enum GNUNET_SET_ResultMode result_mode, struct GNUNET_SET_Option options[], GNUNET_SET_ResultIterator result_cb, void *result_cls)
Prepare a set operation to be evaluated with another peer.
Definition: set_api.c:813
static struct GNUNET_PeerIdentity local_peer
static unsigned int force_full
enum GNUNET_SET_OptionType type
Type of the option.
void GNUNET_SET_destroy(struct GNUNET_SET_Handle *set)
Destroy the set handle, and free all associated resources.
Definition: set_api.c:772
struct GNUNET_CONTAINER_MultiHashMap * received
Only use optimized set operations, even though for this particular set operation they might be much s...
void GNUNET_CRYPTO_hash_create_random(enum GNUNET_CRYPTO_Quality mode, struct GNUNET_HashCode *result)
Create a random hash code.
Definition: crypto_hash.c:144
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:48
static unsigned int num_a
static const struct GNUNET_CONFIGURATION_Handle * config
static int set_insert_iterator(void *cls, const struct GNUNET_HashCode *key, void *value)
static struct GNUNET_SET_ListenHandle * set_listener
static int ret
A 512-bit hashcode.
Client gets notified of the required changes for both the local and the remote set.
static unsigned int num_c
Option for set operations.
int GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
static void handle_shutdown(void *cls)
struct SetInfo info1
int GNUNET_SET_commit(struct GNUNET_SET_OperationHandle *oh, struct GNUNET_SET_Handle *set)
Commit a set to be used with a set operation.
Definition: set_api.c:1128
struct GNUNET_SET_Handle * set
#define GNUNET_log(kind,...)
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
void GNUNET_CRYPTO_random_block(enum GNUNET_CRYPTO_Quality mode, void *buffer, size_t length)
Fill block with a random values.
int GNUNET_CRYPTO_get_peer_identity(const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_PeerIdentity *dst)
Retrieve the identity of the host&#39;s peer.
struct GNUNET_SET_OperationHandle * oh
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
Set union, return all elements that are in at least one of the sets.
static struct GNUNET_CONTAINER_MultiHashMap * common_sent
uint32_t data
The data value.
static void set_result_cb(void *cls, const struct GNUNET_SET_Element *element, uint64_t current_size, enum GNUNET_SET_Status status)
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
#define GNUNET_malloc(size)
Wrapper around malloc.
static unsigned int force_delta
struct SetInfo info2
struct GNUNET_CONTAINER_MultiHashMap * sent
Fail set operations when the other peer shows weird behavior that might by a Byzantine fault...
High-quality operations are desired.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pre_run()

static void pre_run ( void *  cls,
char *const *  args,
const char *  cfgfile,
const struct GNUNET_CONFIGURATION_Handle cfg 
)
static

Definition at line 434 of file gnunet-set-profiler.c.

References GNUNET_TESTING_peer_run(), ret, and run().

Referenced by main().

436 {
437  if (0 != GNUNET_TESTING_peer_run ("set-profiler",
438  cfgfile,
439  &run, NULL))
440  ret = 2;
441 }
int GNUNET_TESTING_peer_run(const char *testdir, const char *cfgfilename, GNUNET_TESTING_TestMain tm, void *tm_cls)
Start a single peer and run a test using the testing library.
Definition: testing.c:1598
static int ret
static void run(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Peer *peer)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 445 of file gnunet-set-profiler.c.

References byzantine, element_size, force_delta, force_full, gettext_noop, GNUNET_GETOPT_OPTION_END, GNUNET_GETOPT_option_filename(), GNUNET_GETOPT_option_flag(), GNUNET_GETOPT_option_string(), GNUNET_GETOPT_option_uint(), GNUNET_PROGRAM_run2(), GNUNET_YES, num_a, num_b, num_c, op_str, pre_run(), ret, and statistics_filename.

446 {
449  "num-first",
450  NULL,
451  gettext_noop ("number of values"),
452  &num_a),
453 
455  "num-second",
456  NULL,
457  gettext_noop ("number of values"),
458  &num_b),
459 
461  "byzantine",
462  gettext_noop ("use byzantine mode"),
463  &byzantine),
464 
466  "force-full",
467  NULL,
468  gettext_noop ("force sending full set"),
469  &force_full),
470 
472  "force-delta",
473  NULL,
474  gettext_noop ("number delta operation"),
475  &force_delta),
476 
478  "num-common",
479  NULL,
480  gettext_noop ("number of values"),
481  &num_c),
482 
484  "operation",
485  NULL,
486  gettext_noop ("operation to execute"),
487  &op_str),
488 
490  "element-size",
491  NULL,
492  gettext_noop ("element size"),
493  &element_size),
494 
496  "statistics",
497  "FILENAME",
498  gettext_noop ("write statistics to file"),
500 
502  };
503 
504  GNUNET_PROGRAM_run2 (argc, argv, "gnunet-set-profiler",
505  "help",
506  options, &pre_run, NULL, GNUNET_YES);
507  return ret;
508 }
static unsigned int element_size
static int byzantine
int GNUNET_PROGRAM_run2(int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls, int run_without_scheduler)
Run a standard GNUnet command startup sequence (initialize loggers and configuration, parse options).
Definition: program.c:141
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
static unsigned int num_b
static char * op_str
Definition of a command line option.
static unsigned int force_full
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_string(char shortName, const char *name, const char *argumentHelp, const char *description, char **str)
Allow user to specify a string.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_filename(char shortName, const char *name, const char *argumentHelp, const char *description, char **str)
Allow user to specify a filename (automatically path expanded).
static unsigned int num_a
static int ret
static unsigned int num_c
static char * statistics_filename
The profiler will write statistics for all peers to the file with this name.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_flag(char shortName, const char *name, const char *description, int *val)
Allow user to specify a flag (which internally means setting an integer to 1/GNUNET_YES/GNUNET_OK.
#define GNUNET_YES
Definition: gnunet_common.h:77
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_uint(char shortName, const char *name, const char *argumentHelp, const char *description, unsigned int *val)
Allow user to specify an unsigned int.
static void pre_run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
static unsigned int force_delta
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:

Variable Documentation

◆ ret

int ret
static

Definition at line 33 of file gnunet-set-profiler.c.

Referenced by main(), map_remove_iterator(), pre_run(), and run().

◆ num_a

unsigned int num_a = 5
static

Definition at line 35 of file gnunet-set-profiler.c.

Referenced by main(), and run().

◆ num_b

unsigned int num_b = 5
static

Definition at line 36 of file gnunet-set-profiler.c.

Referenced by main(), and run().

◆ num_c

unsigned int num_c = 20
static

Definition at line 37 of file gnunet-set-profiler.c.

Referenced by main(), and run().

◆ op_str

char* op_str = "union"
static

Definition at line 39 of file gnunet-set-profiler.c.

Referenced by main().

◆ config

const struct GNUNET_CONFIGURATION_Handle* config
static

◆ info1

struct SetInfo info1

◆ info2

struct SetInfo info2

◆ common_sent

struct GNUNET_CONTAINER_MultiHashMap* common_sent
static

Definition at line 53 of file gnunet-set-profiler.c.

◆ app_id

struct GNUNET_HashCode app_id
static

Definition at line 55 of file gnunet-set-profiler.c.

Referenced by GNUNET_SET_listen(), GNUNET_SET_prepare(), and run().

◆ local_peer

struct GNUNET_PeerIdentity local_peer
static

Definition at line 57 of file gnunet-set-profiler.c.

Referenced by run().

◆ set_listener

struct GNUNET_SET_ListenHandle* set_listener
static

Definition at line 59 of file gnunet-set-profiler.c.

◆ byzantine

int byzantine
static

Definition at line 61 of file gnunet-set-profiler.c.

Referenced by main(), run(), and set_listen_cb().

◆ force_delta

unsigned int force_delta
static

Definition at line 62 of file gnunet-set-profiler.c.

Referenced by main(), run(), and set_listen_cb().

◆ force_full

unsigned int force_full
static

Definition at line 63 of file gnunet-set-profiler.c.

Referenced by main(), run(), and set_listen_cb().

◆ element_size

unsigned int element_size = 32
static

◆ statistics

struct GNUNET_STATISTICS_Handle* statistics
static

Handle to the statistics service.

Definition at line 69 of file gnunet-set-profiler.c.

◆ statistics_filename

char* statistics_filename
static

The profiler will write statistics for all peers to the file with this name.

Definition at line 75 of file gnunet-set-profiler.c.

Referenced by check_all_done(), and main().

◆ statistics_file

FILE* statistics_file
static

The profiler will write statistics for all peers to this file.

Definition at line 81 of file gnunet-set-profiler.c.

Referenced by check_all_done(), statistics_done(), and statistics_result().