GNUnet  0.10.x
Data Structures | Macros | Enumerations | Functions | Variables
gnunet-gns-benchmark.c File Reference

issue many queries to GNS and compute performance statistics More...

#include "platform.h"
#include <gnunet_util_lib.h>
#include <gnunet_gnsrecord_lib.h>
#include <gnunet_gns_service.h>
Include dependency graph for gnunet-gns-benchmark.c:

Go to the source code of this file.

Data Structures

struct  Request
 Request we should make. More...
 

Macros

#define DEF_REQUEST_DELAY   GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 1)
 How long do we wait at least between requests by default? More...
 
#define DEF_TIMEOUT   GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 1)
 How long do we wait until we consider a request failed by default? More...
 

Enumerations

enum  RequestCategory { RC_SHARED = 0, RC_PRIVATE = 1, RC_MAX = 2 }
 We distinguish between different categories of requests, for which we track statistics separately. More...
 

Functions

static void free_request (struct Request *req)
 Free req and data structures reachable from it. More...
 
static void process_result (void *cls, int gns_tld, uint32_t rd_count, const struct GNUNET_GNSRECORD_Data *rd)
 Function called with the result of a GNS resolution. More...
 
static void process_queue (void *cls)
 Process request from the queue. More...
 
static int compare_req (const void *c1, const void *c2)
 Compare two requests by latency for qsort(). More...
 
static void do_shutdown (void *cls)
 Output statistics, then clean up and terminate the process. More...
 
static void queue (const char *hostname, enum RequestCategory cat)
 Add hostname to the list of requests to be made. More...
 
static void process_stdin (void *cls)
 Begin processing hostnames from stdin. More...
 
static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
 Process requests from the queue, then if the queue is not empty, try again. More...
 
int main (int argc, char *const *argv)
 Call with list of names with numeric category to query. More...
 

Variables

static struct GNUNET_GNS_Handlegns
 GNS handle. More...
 
static unsigned int lookups [RC_MAX]
 Number of lookups we performed overall per category. More...
 
static unsigned int replies [RC_MAX]
 Number of replies we got per category. More...
 
static unsigned int failures [RC_MAX]
 Number of replies we got per category. More...
 
static struct GNUNET_TIME_Relative latency_sum [RC_MAX]
 Sum of the observed latencies of successful queries, per category. More...
 
static struct Requestact_head
 Active requests are kept in a DLL. More...
 
static struct Requestact_tail
 Active requests are kept in a DLL. More...
 
static struct Requestsucc_head
 Completed successful requests are kept in a DLL. More...
 
static struct Requestsucc_tail
 Completed successful requests are kept in a DLL. More...
 
static struct Requesttodo_head
 Yet to be started requests are kept in a DLL. More...
 
static struct Requesttodo_tail
 Yet to be started requests are kept in a DLL. More...
 
static struct GNUNET_SCHEDULER_Taskt
 Main task. More...
 
static struct GNUNET_TIME_Relative request_delay
 Delay between requests. More...
 
static struct GNUNET_TIME_Relative timeout
 Timeout for requests. More...
 
static unsigned int active_cnt
 Number of requests we have concurrently active. More...
 
static int g2d
 Look for GNS2DNS records specifically? More...
 

Detailed Description

issue many queries to GNS and compute performance statistics

Author
Christian Grothoff

Definition in file gnunet-gns-benchmark.c.

Macro Definition Documentation

◆ DEF_REQUEST_DELAY

#define DEF_REQUEST_DELAY   GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 1)

How long do we wait at least between requests by default?

Definition at line 34 of file gnunet-gns-benchmark.c.

Referenced by main().

◆ DEF_TIMEOUT

How long do we wait until we consider a request failed by default?

Definition at line 39 of file gnunet-gns-benchmark.c.

Referenced by main().

Enumeration Type Documentation

◆ RequestCategory

We distinguish between different categories of requests, for which we track statistics separately.

However, this process does not change how it acts based on the category.

Enumerator
RC_SHARED 
RC_PRIVATE 
RC_MAX 

Must be last and match number of categories.

Definition at line 48 of file gnunet-gns-benchmark.c.

49 {
50  RC_SHARED = 0,
51  RC_PRIVATE = 1,
55  RC_MAX = 2
56 };
Must be last and match number of categories.

Function Documentation

◆ free_request()

static void free_request ( struct Request req)
static

Free req and data structures reachable from it.

Parameters
reqrequest to free

Definition at line 195 of file gnunet-gns-benchmark.c.

References GNUNET_free, GNUNET_GNS_lookup_with_tld_cancel(), and Request::lr.

Referenced by do_shutdown(), and process_queue().

196 {
197  if (NULL != req->lr)
199  GNUNET_free (req);
200 }
void * GNUNET_GNS_lookup_with_tld_cancel(struct GNUNET_GNS_LookupWithTldRequest *ltr)
Cancel pending lookup request.
Definition: gns_tld_api.c:330
struct GNUNET_GNS_LookupWithTldRequest * lr
Socket used to make the request, NULL if not active.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_result()

static void process_result ( void *  cls,
int  gns_tld,
uint32_t  rd_count,
const struct GNUNET_GNSRECORD_Data rd 
)
static

Function called with the result of a GNS resolution.

Parameters
clsclosure with the struct Request
gns_tldGNUNET_YES if GNS lookup was attempted
rd_countnumber of records in rd
rdthe records in reply

Definition at line 212 of file gnunet-gns-benchmark.c.

References active_cnt, Request::cat, GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_relative_add(), Request::hostname, Request::latency, latency_sum, Request::lr, Request::op_start_time, and replies.

Referenced by process_queue().

216 {
217  struct Request *req = cls;
218 
219  (void) gns_tld;
220  (void) rd_count;
221  (void) rd;
222  active_cnt--;
224  "Got response for request `%s'\n",
225  req->hostname);
226  req->lr = NULL;
229  act_tail,
230  req);
232  succ_tail,
233  req);
234  replies[req->cat]++;
235  latency_sum[req->cat]
237  req->latency);
238 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
char * hostname
Hostname we are resolving.
enum RequestCategory cat
Category of the request.
static unsigned int replies[RC_MAX]
Number of replies we got per category.
static struct Request * succ_head
Completed successful requests are kept in a DLL.
static struct GNUNET_TIME_Relative latency_sum[RC_MAX]
Sum of the observed latencies of successful queries, per category.
Request we should make.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_add(struct GNUNET_TIME_Relative a1, struct GNUNET_TIME_Relative a2)
Add relative times together.
Definition: time.c:576
struct GNUNET_GNS_LookupWithTldRequest * lr
Socket used to make the request, NULL if not active.
struct GNUNET_TIME_Absolute op_start_time
While we are fetching the record, the value is set to the starting time of the GNS operation...
static struct Request * act_tail
Active requests are kept in a DLL.
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition: time.c:373
struct GNUNET_TIME_Relative latency
Observed latency, set once we got a reply.
#define GNUNET_log(kind,...)
static unsigned int active_cnt
Number of requests we have concurrently active.
static struct Request * act_head
Active requests are kept in a DLL.
static struct Request * succ_tail
Completed successful requests are kept in a DLL.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_queue()

static void process_queue ( void *  cls)
static

Process request from the queue.

Parameters
clsNULL

Definition at line 247 of file gnunet-gns-benchmark.c.

References active_cnt, Request::cat, failures, free_request(), g2d, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_GNS_LO_DEFAULT, GNUNET_GNS_lookup_with_tld(), GNUNET_GNSRECORD_TYPE_ANY, GNUNET_GNSRECORD_TYPE_GNS2DNS, GNUNET_log, GNUNET_SCHEDULER_add_at(), GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_shutdown(), GNUNET_TIME_absolute_add(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_duration(), Request::hostname, lookups, Request::lr, Request::op_start_time, process_result(), GNUNET_TIME_Relative::rel_value_us, request_delay, and timeout.

Referenced by process_stdin().

248 {
249  struct Request *req;
251 
252  (void) cls;
253  t = NULL;
254  /* check for expired requests */
255  while (NULL != (req = act_head))
256  {
259  break;
261  act_tail,
262  req);
264  "Failing request `%s' due to timeout\n",
265  req->hostname);
266  failures[req->cat]++;
267  active_cnt--;
268  free_request (req);
269  }
270  if (NULL == (req = todo_head))
271  {
272  struct GNUNET_TIME_Absolute at;
273 
274  if (NULL == (req = act_head))
275  {
277  return;
278  }
280  timeout);
281  t = GNUNET_SCHEDULER_add_at (at,
282  &process_queue,
283  NULL);
284  return;
285  }
287  todo_tail,
288  req);
290  act_tail,
291  req);
292  lookups[req->cat]++;
293  active_cnt++;
296  "Starting request `%s' (%u in parallel)\n",
297  req->hostname,
298  active_cnt);
300  req->hostname,
301  g2d
306  req);
308  &process_queue,
309  NULL);
310 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
static void free_request(struct Request *req)
Free req and data structures reachable from it.
static struct Request * todo_head
Yet to be started requests are kept in a DLL.
uint64_t rel_value_us
The actual value.
char * hostname
Hostname we are resolving.
static void process_result(void *cls, int gns_tld, uint32_t rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Function called with the result of a GNS resolution.
#define GNUNET_GNSRECORD_TYPE_ANY
Record type indicating any record/&#39;*&#39;.
static struct GNUNET_TIME_Relative request_delay
Delay between requests.
static struct Request * todo_tail
Yet to be started requests are kept in a DLL.
struct GNUNET_GNS_LookupWithTldRequest * GNUNET_GNS_lookup_with_tld(struct GNUNET_GNS_Handle *handle, const char *name, uint32_t type, enum GNUNET_GNS_LocalOptions options, GNUNET_GNS_LookupResultProcessor2 proc, void *proc_cls)
Perform an asynchronous lookup operation on the GNS, determining the zone using the TLD of the given ...
Definition: gns_tld_api.c:242
static unsigned int failures[RC_MAX]
Number of replies we got per category.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_add(struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Relative duration)
Add a given relative duration to the given start time.
Definition: time.c:393
enum RequestCategory cat
Category of the request.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:524
static struct GNUNET_GNS_Handle * gns
GNS handle.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1246
#define GNUNET_GNSRECORD_TYPE_GNS2DNS
Record type for delegation to DNS.
static void process_queue(void *cls)
Process request from the queue.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
static unsigned int lookups[RC_MAX]
Number of lookups we performed overall per category.
static struct GNUNET_SCHEDULER_Task * t
Main task.
static struct GNUNET_TIME_Relative timeout
Timeout for requests.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
Request we should make.
struct GNUNET_GNS_LookupWithTldRequest * lr
Socket used to make the request, NULL if not active.
struct GNUNET_TIME_Absolute op_start_time
While we are fetching the record, the value is set to the starting time of the GNS operation...
static struct Request * act_tail
Active requests are kept in a DLL.
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition: time.c:373
#define GNUNET_log(kind,...)
static struct GNUNET_TIME_Relative duration
How long do we run the test?
static int g2d
Look for GNS2DNS records specifically?
Time for absolute times used by GNUnet, in microseconds.
static unsigned int active_cnt
Number of requests we have concurrently active.
Defaults, look in cache, then in DHT.
static struct Request * act_head
Active requests are kept in a DLL.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_at(struct GNUNET_TIME_Absolute at, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run at the specified time.
Definition: scheduler.c:1223
Time for relative time used by GNUnet, in microseconds.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ compare_req()

static int compare_req ( const void *  c1,
const void *  c2 
)
static

Compare two requests by latency for qsort().

Parameters
c1pointer to struct Request *
c2pointer to struct Request *
Returns
-1 if c1<c2, 1 if c1>c2, 0 if c1==c2.

Definition at line 321 of file gnunet-gns-benchmark.c.

References Request::latency, and GNUNET_TIME_Relative::rel_value_us.

Referenced by do_shutdown().

323 {
324  const struct Request *r1 = *(void **) c1;
325  const struct Request *r2 = *(void **) c2;
326 
328  return -1;
330  return 1;
331  return 0;
332 }
uint64_t rel_value_us
The actual value.
Request we should make.
struct GNUNET_TIME_Relative latency
Observed latency, set once we got a reply.
Here is the caller graph for this function:

◆ do_shutdown()

static void do_shutdown ( void *  cls)
static

Output statistics, then clean up and terminate the process.

Parameters
clsNULL

Definition at line 341 of file gnunet-gns-benchmark.c.

References Request::cat, compare_req(), failures, free_request(), GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_GNS_disconnect(), GNUNET_new_array, GNUNET_SCHEDULER_cancel(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_relative_divide(), GNUNET_YES, Request::latency, latency_sum, lookups, Request::next, RC_MAX, replies, and rp.

Referenced by run().

342 {
343  struct Request *req;
344  struct Request **ra[RC_MAX];
345  unsigned int rp[RC_MAX];
346 
347  (void) cls;
348  for (enum RequestCategory rc = 0;rc < RC_MAX;rc++)
349  {
350  ra[rc] = GNUNET_new_array (replies[rc],
351  struct Request *);
352  rp[rc] = 0;
353  }
354  for (req = succ_head;NULL != req; req = req->next)
355  {
356  GNUNET_assert (rp[req->cat] < replies[req->cat]);
357  ra[req->cat][rp[req->cat]++] = req;
358  }
359  for (enum RequestCategory rc = 0;rc < RC_MAX;rc++)
360  {
361  unsigned int off;
362 
363  fprintf (stdout,
364  "Category %u\n",
365  rc);
366  fprintf (stdout,
367  "\tlookups: %u replies: %u failures: %u\n",
368  lookups[rc],
369  replies[rc],
370  failures[rc]);
371  if (0 == rp[rc])
372  continue;
373  qsort (ra[rc],
374  rp[rc],
375  sizeof (struct Request *),
376  &compare_req);
378  replies[rc]);
379  fprintf (stdout,
380  "\taverage: %s\n",
382  GNUNET_YES));
383  off = rp[rc] * 50 / 100;
384  fprintf (stdout,
385  "\tmedian(50): %s\n",
387  GNUNET_YES));
388  off = rp[rc] * 75 / 100;
389  fprintf (stdout,
390  "\tquantile(75): %s\n",
392  GNUNET_YES));
393  off = rp[rc] * 90 / 100;
394  fprintf (stdout,
395  "\tquantile(90): %s\n",
397  GNUNET_YES));
398  off = rp[rc] * 99 / 100;
399  fprintf (stdout,
400  "\tquantile(99): %s\n",
402  GNUNET_YES));
403  GNUNET_free (ra[rc]);
404  }
405  if (NULL != t)
406  {
408  t = NULL;
409  }
410  while (NULL != (req = act_head))
411  {
413  act_tail,
414  req);
415  free_request (req);
416  }
417  while (NULL != (req = succ_head))
418  {
420  succ_tail,
421  req);
422  free_request (req);
423  }
424  while (NULL != (req = todo_head))
425  {
427  todo_tail,
428  req);
429  free_request (req);
430  }
431  if (NULL != gns)
432  {
434  gns = NULL;
435  }
436 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
static void free_request(struct Request *req)
Free req and data structures reachable from it.
static struct Request * todo_head
Yet to be started requests are kept in a DLL.
static int compare_req(const void *c1, const void *c2)
Compare two requests by latency for qsort().
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static struct Request * todo_tail
Yet to be started requests are kept in a DLL.
static unsigned int failures[RC_MAX]
Number of replies we got per category.
enum RequestCategory cat
Category of the request.
static struct GNUNET_GNS_Handle * gns
GNS handle.
static unsigned int replies[RC_MAX]
Number of replies we got per category.
void GNUNET_GNS_disconnect(struct GNUNET_GNS_Handle *handle)
Shutdown connection with the GNS service.
Definition: gns_api.c:285
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:727
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
static struct Request * succ_head
Completed successful requests are kept in a DLL.
static struct GNUNET_TIME_Relative latency_sum[RC_MAX]
Sum of the observed latencies of successful queries, per category.
static unsigned int lookups[RC_MAX]
Number of lookups we performed overall per category.
static struct GNUNET_SCHEDULER_Task * t
Main task.
Request we should make.
RequestCategory
We distinguish between different categories of requests, for which we track statistics separately...
static struct Request * act_tail
Active requests are kept in a DLL.
struct GNUNET_TIME_Relative latency
Observed latency, set once we got a reply.
struct Request * next
Requests are kept in a DLL.
Must be last and match number of categories.
static char * rp
Relying party.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_divide(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Divide relative time by a given factor.
Definition: time.c:525
#define GNUNET_YES
Definition: gnunet_common.h:80
static struct Request * act_head
Active requests are kept in a DLL.
static struct Request * succ_tail
Completed successful requests are kept in a DLL.
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
Here is the call graph for this function:
Here is the caller graph for this function:

◆ queue()

static void queue ( const char *  hostname,
enum RequestCategory  cat 
)
static

Add hostname to the list of requests to be made.

Parameters
hostnamename to resolve
catcategory of the hostname

Definition at line 446 of file gnunet-gns-benchmark.c.

References Request::cat, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_malloc, GNUNET_memcpy, and Request::hostname.

Referenced by process_stdin().

448 {
449  struct Request *req;
450  const char *dot;
451  size_t hlen;
452 
453  dot = strchr (hostname,
454  (unsigned char) '.');
455  if (NULL == dot)
456  {
458  "Refusing invalid hostname `%s' (lacks '.')\n",
459  hostname);
460  return;
461  }
462  hlen = strlen (hostname) + 1;
463  req = GNUNET_malloc (sizeof (struct Request) + hlen);
464  req->cat = cat;
465  req->hostname = (char *) &req[1];
466  GNUNET_memcpy (&req[1],
467  hostname,
468  hlen);
470  todo_tail,
471  req);
472 }
static struct Request * todo_head
Yet to be started requests are kept in a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
char * hostname
Hostname we are resolving.
static struct Request * todo_tail
Yet to be started requests are kept in a DLL.
enum RequestCategory cat
Category of the request.
#define GNUNET_memcpy(dst, src, n)
Request we should make.
static char * hostname
Our hostname; we give this to all the peers we start.
#define GNUNET_log(kind,...)
#define GNUNET_malloc(size)
Wrapper around malloc.
Here is the caller graph for this function:

◆ process_stdin()

static void process_stdin ( void *  cls)
static

Begin processing hostnames from stdin.

Parameters
clsNULL

Definition at line 481 of file gnunet-gns-benchmark.c.

References Request::cat, GNUNET_SCHEDULER_add_now(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_duration(), GNUNET_YES, Request::hn, process_queue(), queue(), and RC_MAX.

Referenced by run().

482 {
483  static struct GNUNET_TIME_Absolute last;
484  static uint64_t idot;
485  unsigned int cat;
486  char hn[256];
487  char in[270];
488 
489  (void) cls;
490  t = NULL;
491  while (NULL !=
492  fgets (in,
493  sizeof (in),
494  stdin))
495  {
496  if (strlen(in) > 0)
497  hn[strlen(in)-1] = '\0'; /* eat newline */
498  if ( (2 != sscanf (in,
499  "%u %255s",
500  &cat,
501  hn)) ||
502  (cat >= RC_MAX) )
503  {
504  fprintf (stderr,
505  "Malformed input line `%s', skipping\n",
506  in);
507  continue;
508  }
509  if (0 == idot)
510  last = GNUNET_TIME_absolute_get ();
511  idot++;
512  if (0 == idot % 100000)
513  {
515 
517  last = GNUNET_TIME_absolute_get ();
518  fprintf (stderr,
519  "Read 100000 domain names in %s\n",
521  GNUNET_YES));
522  }
523  queue (hn,
524  (enum RequestCategory) cat);
525  }
526  fprintf (stderr,
527  "Done reading %llu domain names\n",
528  (unsigned long long) idot);
530  NULL);
531 }
static struct GNUNET_TIME_Relative delta
Definition: speedup.c:35
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1273
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:727
static void queue(const char *hostname, enum RequestCategory cat)
Add hostname to the list of requests to be made.
static void process_queue(void *cls)
Process request from the queue.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
static struct GNUNET_SCHEDULER_Task * t
Main task.
RequestCategory
We distinguish between different categories of requests, for which we track statistics separately...
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition: time.c:373
Must be last and match number of categories.
Time for absolute times used by GNUnet, in microseconds.
#define GNUNET_YES
Definition: gnunet_common.h:80
Time for relative time used by GNUnet, in microseconds.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ run()

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

Process requests from the queue, then if the queue is not empty, try again.

Parameters
clsNULL
argsremaining command-line arguments
cfgfilename of the configuration file used (for saving, can be NULL!)
cfgconfiguration

Definition at line 544 of file gnunet-gns-benchmark.c.

References do_shutdown(), GNUNET_break, GNUNET_GNS_connect(), GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), and process_stdin().

Referenced by main().

548 {
549  (void) cls;
550  (void) args;
551  (void) cfgfile;
553  NULL);
554  gns = GNUNET_GNS_connect (cfg);
555  if (NULL == gns)
556  {
557  GNUNET_break (0);
559  return;
560  }
562  NULL);
563 }
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:1293
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:524
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct GNUNET_GNS_Handle * gns
GNS handle.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1273
static void process_stdin(void *cls)
Begin processing hostnames from stdin.
static void do_shutdown(void *cls)
Output statistics, then clean up and terminate the process.
struct GNUNET_GNS_Handle * GNUNET_GNS_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the connection with the GNS service.
Definition: gns_api.c:263
static struct GNUNET_SCHEDULER_Task * t
Main task.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char *const *  argv 
)

Call with list of names with numeric category to query.

Parameters
argcunused
argvunused
Returns
0 on success

Definition at line 574 of file gnunet-gns-benchmark.c.

References DEF_REQUEST_DELAY, DEF_TIMEOUT, g2d, gettext_noop, GNUNET_free, GNUNET_GETOPT_OPTION_END, GNUNET_GETOPT_option_flag(), GNUNET_GETOPT_option_relative_time(), GNUNET_OK, GNUNET_PROGRAM_run(), GNUNET_STRINGS_get_utf8_args(), request_delay, ret, run(), and timeout.

576 {
577  int ret = 0;
580  "delay",
581  "RELATIVETIME",
582  gettext_noop ("how long to wait between queries"),
583  &request_delay),
585  "timeout",
586  "RELATIVETIME",
587  gettext_noop ("how long to wait for an answer"),
588  &timeout),
590  "g2d",
591  gettext_noop ("look for GNS2DNS records instead of ANY"),
592  &g2d),
594  };
595 
596  if (GNUNET_OK !=
597  GNUNET_STRINGS_get_utf8_args (argc, argv,
598  &argc, &argv))
599  return 2;
602  if (GNUNET_OK !=
603  GNUNET_PROGRAM_run (argc,
604  argv,
605  "gnunet-gns-benchmark",
606  "resolve GNS names and measure performance",
607  options,
608  &run,
609  NULL))
610  ret = 1;
611  GNUNET_free ((void*) argv);
612  return ret;
613 }
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_relative_time(char shortName, const char *name, const char *argumentHelp, const char *description, struct GNUNET_TIME_Relative *val)
Allow user to specify a struct GNUNET_TIME_Relative (using human-readable "fancy" time)...
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
Process requests from the queue, then if the queue is not empty, try again.
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
int GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
Definition: strings.c:1521
static struct GNUNET_TIME_Relative request_delay
Delay between requests.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
Definition of a command line option.
static int ret
Final status code.
Definition: gnunet-arm.c:89
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
#define DEF_REQUEST_DELAY
How long do we wait at least between requests by default?
static struct GNUNET_TIME_Relative timeout
Timeout for requests.
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 DEF_TIMEOUT
How long do we wait until we consider a request failed by default?
int GNUNET_PROGRAM_run(int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration, parse options).
Definition: program.c:361
static int g2d
Look for GNS2DNS records specifically?
#define GNUNET_free(ptr)
Wrapper around free.
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:

Variable Documentation

◆ gns

struct GNUNET_GNS_Handle* gns
static

GNS handle.

Definition at line 111 of file gnunet-gns-benchmark.c.

◆ lookups

unsigned int lookups[RC_MAX]
static

Number of lookups we performed overall per category.

Definition at line 116 of file gnunet-gns-benchmark.c.

Referenced by do_shutdown(), and process_queue().

◆ replies

unsigned int replies[RC_MAX]
static

Number of replies we got per category.

Definition at line 121 of file gnunet-gns-benchmark.c.

Referenced by do_shutdown(), and process_result().

◆ failures

unsigned int failures[RC_MAX]
static

Number of replies we got per category.

Definition at line 126 of file gnunet-gns-benchmark.c.

Referenced by do_shutdown(), and process_queue().

◆ latency_sum

struct GNUNET_TIME_Relative latency_sum[RC_MAX]
static

Sum of the observed latencies of successful queries, per category.

Definition at line 132 of file gnunet-gns-benchmark.c.

Referenced by do_shutdown(), and process_result().

◆ act_head

struct Request* act_head
static

Active requests are kept in a DLL.

Definition at line 137 of file gnunet-gns-benchmark.c.

◆ act_tail

struct Request* act_tail
static

Active requests are kept in a DLL.

Definition at line 142 of file gnunet-gns-benchmark.c.

◆ succ_head

struct Request* succ_head
static

Completed successful requests are kept in a DLL.

Definition at line 147 of file gnunet-gns-benchmark.c.

◆ succ_tail

struct Request* succ_tail
static

Completed successful requests are kept in a DLL.

Definition at line 152 of file gnunet-gns-benchmark.c.

◆ todo_head

struct Request* todo_head
static

Yet to be started requests are kept in a DLL.

Definition at line 157 of file gnunet-gns-benchmark.c.

◆ todo_tail

struct Request* todo_tail
static

Yet to be started requests are kept in a DLL.

Definition at line 162 of file gnunet-gns-benchmark.c.

◆ t

struct GNUNET_SCHEDULER_Task* t
static

Main task.

Definition at line 167 of file gnunet-gns-benchmark.c.

◆ request_delay

struct GNUNET_TIME_Relative request_delay
static

Delay between requests.

Definition at line 172 of file gnunet-gns-benchmark.c.

Referenced by main(), and process_queue().

◆ timeout

struct GNUNET_TIME_Relative timeout
static

Timeout for requests.

Definition at line 177 of file gnunet-gns-benchmark.c.

Referenced by main(), and process_queue().

◆ active_cnt

unsigned int active_cnt
static

Number of requests we have concurrently active.

Definition at line 182 of file gnunet-gns-benchmark.c.

Referenced by process_queue(), and process_result().

◆ g2d

int g2d
static

Look for GNS2DNS records specifically?

Definition at line 187 of file gnunet-gns-benchmark.c.

Referenced by main(), and process_queue().