aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-05-01 15:28:02 +0200
committerChristian Grothoff <christian@grothoff.org>2018-05-01 15:28:02 +0200
commit0c7ee9c2b1ad1290df54b0e394e2ede79575f671 (patch)
tree91fed2b0c6b96178b27278643cbd7de06e0b0394 /src
parenta5e3e870f27c8ef3a3cd5d59a686a3050f9c64fb (diff)
downloadgnunet-0c7ee9c2b1ad1290df54b0e394e2ede79575f671.tar.gz
gnunet-0c7ee9c2b1ad1290df54b0e394e2ede79575f671.zip
lots more statistics for zoneimport/namestore
Diffstat (limited to 'src')
-rw-r--r--src/namestore/Makefile.am1
-rw-r--r--src/namestore/gnunet-service-namestore.c2
-rw-r--r--src/namestore/gnunet-zoneimport.c196
3 files changed, 181 insertions, 18 deletions
diff --git a/src/namestore/Makefile.am b/src/namestore/Makefile.am
index b1faae862..fa85cc060 100644
--- a/src/namestore/Makefile.am
+++ b/src/namestore/Makefile.am
@@ -144,6 +144,7 @@ gnunet_zoneimport_SOURCES = \
144 gnunet-zoneimport.c 144 gnunet-zoneimport.c
145gnunet_zoneimport_LDADD = \ 145gnunet_zoneimport_LDADD = \
146 libgnunetnamestore.la \ 146 libgnunetnamestore.la \
147 $(top_builddir)/src/statistics/libgnunetstatistics.la \
147 $(top_builddir)/src/identity/libgnunetidentity.la \ 148 $(top_builddir)/src/identity/libgnunetidentity.la \
148 $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ 149 $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \
149 $(top_builddir)/src/dns/libgnunetdnsparser.la \ 150 $(top_builddir)/src/dns/libgnunetdnsparser.la \
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c
index 2172ed0c7..7934ea6ce 100644
--- a/src/namestore/gnunet-service-namestore.c
+++ b/src/namestore/gnunet-service-namestore.c
@@ -469,7 +469,7 @@ get_nick_record (const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone)
469 (NULL == nick) ) 469 (NULL == nick) )
470 { 470 {
471 GNUNET_CRYPTO_ecdsa_key_get_public (zone, &pub); 471 GNUNET_CRYPTO_ecdsa_key_get_public (zone, &pub);
472 GNUNET_log (GNUNET_ERROR_TYPE_INFO | GNUNET_ERROR_TYPE_BULK, 472 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
473 "No nick name set for zone `%s'\n", 473 "No nick name set for zone `%s'\n",
474 GNUNET_GNSRECORD_z2s (&pub)); 474 GNUNET_GNSRECORD_z2s (&pub));
475 return NULL; 475 return NULL;
diff --git a/src/namestore/gnunet-zoneimport.c b/src/namestore/gnunet-zoneimport.c
index 55779e06a..f8e382760 100644
--- a/src/namestore/gnunet-zoneimport.c
+++ b/src/namestore/gnunet-zoneimport.c
@@ -28,6 +28,7 @@
28#include <gnunet_dnsparser_lib.h> 28#include <gnunet_dnsparser_lib.h>
29#include <gnunet_gnsrecord_lib.h> 29#include <gnunet_gnsrecord_lib.h>
30#include <gnunet_namestore_service.h> 30#include <gnunet_namestore_service.h>
31#include <gnunet_statistics_service.h>
31#include <gnunet_identity_service.h> 32#include <gnunet_identity_service.h>
32 33
33 34
@@ -177,11 +178,19 @@ struct Request
177 /** 178 /**
178 * At what time does the (earliest) of the returned records 179 * At what time does the (earliest) of the returned records
179 * for this name expire? At this point, we need to re-fetch 180 * for this name expire? At this point, we need to re-fetch
180 * the record. 181 * the record.
181 */ 182 */
182 struct GNUNET_TIME_Absolute expires; 183 struct GNUNET_TIME_Absolute expires;
183 184
184 /** 185 /**
186 * While we are fetching the record, the value is set to the
187 * starting time of the DNS operation. While doing a
188 * NAMESTORE store, again set to the start time of the
189 * NAMESTORE operation.
190 */
191 struct GNUNET_TIME_Absolute op_start_time;
192
193 /**
185 * How often did we issue this query? (And failed, reset 194 * How often did we issue this query? (And failed, reset
186 * to zero once we were successful.) 195 * to zero once we were successful.)
187 */ 196 */
@@ -205,6 +214,11 @@ static struct GNUNET_IDENTITY_Handle *id;
205static struct GNUNET_NAMESTORE_Handle *ns; 214static struct GNUNET_NAMESTORE_Handle *ns;
206 215
207/** 216/**
217 * Handle to the statistics service.
218 */
219static struct GNUNET_STATISTICS_Handle *stats;
220
221/**
208 * Context for DNS resolution. 222 * Context for DNS resolution.
209 */ 223 */
210static struct GNUNET_DNSSTUB_Context *ctx; 224static struct GNUNET_DNSSTUB_Context *ctx;
@@ -225,6 +239,11 @@ static unsigned int pending_rs;
225static unsigned int lookups; 239static unsigned int lookups;
226 240
227/** 241/**
242 * Number of records we had cached.
243 */
244static unsigned int cached;
245
246/**
228 * How many hostnames did we reject (malformed). 247 * How many hostnames did we reject (malformed).
229 */ 248 */
230static unsigned int rejects; 249static unsigned int rejects;
@@ -240,6 +259,11 @@ static unsigned int failures;
240static unsigned int records; 259static unsigned int records;
241 260
242/** 261/**
262 * Number of record sets given to namestore.
263 */
264static unsigned int record_sets;
265
266/**
243 * Heap of all requests to perform, sorted by 267 * Heap of all requests to perform, sorted by
244 * the time we should next do the request (i.e. by expires). 268 * the time we should next do the request (i.e. by expires).
245 */ 269 */
@@ -289,6 +313,27 @@ static struct Zone *zone_tail;
289static uint64_t ns_iterator_trigger_next; 313static uint64_t ns_iterator_trigger_next;
290 314
291/** 315/**
316 * Number of DNS requests counted in latency total.
317 */
318static uint64_t total_dns_latency_cnt;
319
320/**
321 * Sum of DNS latencies observed.
322 */
323static struct GNUNET_TIME_Relative total_dns_latency;
324
325/**
326 * Number of NAMESTORE requests counted in latency total.
327 */
328static uint64_t total_ns_latency_cnt;
329
330/**
331 * Sum of NAMESTORE latencies observed.
332 */
333static struct GNUNET_TIME_Relative total_ns_latency;
334
335
336/**
292 * Callback for #for_all_records 337 * Callback for #for_all_records
293 * 338 *
294 * @param cls closure 339 * @param cls closure
@@ -925,11 +970,33 @@ store_completed_cb (void *cls,
925 struct Request *req = cls; 970 struct Request *req = cls;
926 971
927 req->qe = NULL; 972 req->qe = NULL;
973 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
974 "Stored record set in database (%d)\n",
975 success);
928 pending_rs--; 976 pending_rs--;
977 {
978 struct GNUNET_TIME_Relative ns_latency;
979
980 ns_latency = GNUNET_TIME_absolute_get_duration (req->op_start_time);
981 total_ns_latency = GNUNET_TIME_relative_add (total_ns_latency,
982 ns_latency);
983 total_ns_latency_cnt++;
984 if (0 == (total_ns_latency_cnt % 1000))
985 {
986 GNUNET_STATISTICS_update (stats,
987 "# average NAMESTORE PUT latency (μs)",
988 total_ns_latency.rel_value_us / total_ns_latency_cnt,
989 GNUNET_NO);
990 GNUNET_STATISTICS_update (stats,
991 "# NAMESTORE PUTs",
992 total_ns_latency_cnt,
993 GNUNET_NO);
994 }
995 }
996
929 if (NULL == t) 997 if (NULL == t)
930 t = GNUNET_SCHEDULER_add_delayed (SERIES_DELAY, 998 t = GNUNET_SCHEDULER_add_now (&process_queue,
931 &process_queue, 999 NULL);
932 NULL);
933 if (GNUNET_SYSERR == success) 1000 if (GNUNET_SYSERR == success)
934 { 1001 {
935 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1002 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -987,16 +1054,23 @@ process_result (void *cls,
987 req); 1054 req);
988 pending--; 1055 pending--;
989 if (NULL == t) 1056 if (NULL == t)
990 t = GNUNET_SCHEDULER_add_delayed (SERIES_DELAY, 1057 t = GNUNET_SCHEDULER_add_now (&process_queue,
991 &process_queue, 1058 NULL);
992 NULL);
993 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1059 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
994 "Stub gave up on DNS reply for `%s'\n", 1060 "Stub gave up on DNS reply for `%s'\n",
995 req->hostname); 1061 req->hostname);
1062 GNUNET_STATISTICS_update (stats,
1063 "# DNS lookups timed out",
1064 1,
1065 GNUNET_NO);
996 if (req->issue_num > MAX_RETRIES) 1066 if (req->issue_num > MAX_RETRIES)
997 { 1067 {
998 failures++; 1068 failures++;
999 free_request (req); 1069 free_request (req);
1070 GNUNET_STATISTICS_update (stats,
1071 "# requests given up on",
1072 1,
1073 GNUNET_NO);
1000 return; 1074 return;
1001 } 1075 }
1002 req->rs = NULL; 1076 req->rs = NULL;
@@ -1007,6 +1081,10 @@ process_result (void *cls,
1007 { 1081 {
1008 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1082 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1009 "DNS ID did not match request, ignoring reply\n"); 1083 "DNS ID did not match request, ignoring reply\n");
1084 GNUNET_STATISTICS_update (stats,
1085 "# DNS ID missmatches",
1086 1,
1087 GNUNET_NO);
1010 return; 1088 return;
1011 } 1089 }
1012 GNUNET_CONTAINER_DLL_remove (req_head, 1090 GNUNET_CONTAINER_DLL_remove (req_head,
@@ -1022,21 +1100,24 @@ process_result (void *cls,
1022 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1100 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1023 "Failed to parse DNS reply for `%s'\n", 1101 "Failed to parse DNS reply for `%s'\n",
1024 req->hostname); 1102 req->hostname);
1103 GNUNET_STATISTICS_update (stats,
1104 "# DNS parser errors",
1105 1,
1106 GNUNET_NO);
1107 if (NULL == t)
1108 t = GNUNET_SCHEDULER_add_now (&process_queue,
1109 NULL);
1025 if (req->issue_num > MAX_RETRIES) 1110 if (req->issue_num > MAX_RETRIES)
1026 { 1111 {
1027 failures++; 1112 failures++;
1028 insert_sorted (req); 1113 free_request (req);
1029 if (NULL == t) 1114 GNUNET_STATISTICS_update (stats,
1030 t = GNUNET_SCHEDULER_add_delayed (SERIES_DELAY, 1115 "# requests given up on",
1031 &process_queue, 1116 1,
1032 NULL); 1117 GNUNET_NO);
1033 return; 1118 return;
1034 } 1119 }
1035 insert_sorted (req); 1120 insert_sorted (req);
1036 if (NULL == t)
1037 t = GNUNET_SCHEDULER_add_delayed (SERIES_DELAY,
1038 &process_queue,
1039 NULL);
1040 return; 1121 return;
1041 } 1122 }
1042 /* import new records */ 1123 /* import new records */
@@ -1054,6 +1135,25 @@ process_result (void *cls,
1054 GNUNET_DNSPARSER_free_packet (p); 1135 GNUNET_DNSPARSER_free_packet (p);
1055 /* count records found, determine minimum expiration time */ 1136 /* count records found, determine minimum expiration time */
1056 req->expires = GNUNET_TIME_UNIT_FOREVER_ABS; 1137 req->expires = GNUNET_TIME_UNIT_FOREVER_ABS;
1138 {
1139 struct GNUNET_TIME_Relative dns_latency;
1140
1141 dns_latency = GNUNET_TIME_absolute_get_duration (req->op_start_time);
1142 total_dns_latency = GNUNET_TIME_relative_add (total_dns_latency,
1143 dns_latency);
1144 total_dns_latency_cnt++;
1145 if (0 == (total_dns_latency_cnt % 1000))
1146 {
1147 GNUNET_STATISTICS_update (stats,
1148 "# average DNS latency (μs)",
1149 total_dns_latency.rel_value_us / total_dns_latency_cnt,
1150 GNUNET_NO);
1151 GNUNET_STATISTICS_update (stats,
1152 "# DNS replies",
1153 total_dns_latency_cnt,
1154 GNUNET_NO);
1155 }
1156 }
1057 rd_count = 0; 1157 rd_count = 0;
1058 for (rec = req->rec_head; NULL != rec; rec = rec->next) 1158 for (rec = req->rec_head; NULL != rec; rec = rec->next)
1059 { 1159 {
@@ -1073,6 +1173,8 @@ process_result (void *cls,
1073 if (0 == rd_count) 1173 if (0 == rd_count)
1074 req->expires 1174 req->expires
1075 = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_DAYS); 1175 = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_DAYS);
1176 else
1177 record_sets++;
1076 /* convert records to namestore import format */ 1178 /* convert records to namestore import format */
1077 { 1179 {
1078 struct GNUNET_GNSRECORD_Data rd[GNUNET_NZL(rd_count)]; 1180 struct GNUNET_GNSRECORD_Data rd[GNUNET_NZL(rd_count)];
@@ -1082,6 +1184,7 @@ process_result (void *cls,
1082 for (rec = req->rec_head; NULL != rec; rec =rec->next) 1184 for (rec = req->rec_head; NULL != rec; rec =rec->next)
1083 rd[off++] = rec->grd; 1185 rd[off++] = rec->grd;
1084 pending_rs++; 1186 pending_rs++;
1187 req->op_start_time = GNUNET_TIME_absolute_get ();
1085 req->qe = GNUNET_NAMESTORE_records_store (ns, 1188 req->qe = GNUNET_NAMESTORE_records_store (ns,
1086 &req->zone->key, 1189 &req->zone->key,
1087 get_label (req), 1190 get_label (req),
@@ -1143,6 +1246,7 @@ process_queue (void *cls)
1143 free_request (req); 1246 free_request (req);
1144 continue; 1247 continue;
1145 } 1248 }
1249 req->op_start_time = GNUNET_TIME_absolute_get ();
1146 req->rs = GNUNET_DNSSTUB_resolve (ctx, 1250 req->rs = GNUNET_DNSSTUB_resolve (ctx,
1147 raw, 1251 raw,
1148 raw_size, 1252 raw_size,
@@ -1157,10 +1261,21 @@ process_queue (void *cls)
1157 break; 1261 break;
1158 } 1262 }
1159 if (pending + pending_rs >= THRESH) 1263 if (pending + pending_rs >= THRESH)
1264 {
1265 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1266 "Stopped processing queue (%u+%u/%u)]\n",
1267 pending,
1268 pending_rs,
1269 THRESH);
1160 return; /* wait for replies */ 1270 return; /* wait for replies */
1271 }
1161 req = GNUNET_CONTAINER_heap_peek (req_heap); 1272 req = GNUNET_CONTAINER_heap_peek (req_heap);
1162 if (NULL == req) 1273 if (NULL == req)
1274 {
1275 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1276 "Stopped processing queue: empty queue\n");
1163 return; 1277 return;
1278 }
1164 if (GNUNET_TIME_absolute_get_remaining (req->expires).rel_value_us > 0) 1279 if (GNUNET_TIME_absolute_get_remaining (req->expires).rel_value_us > 0)
1165 { 1280 {
1166 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1281 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -1281,6 +1396,11 @@ do_shutdown (void *cls)
1281 GNUNET_free (zone->domain); 1396 GNUNET_free (zone->domain);
1282 GNUNET_free (zone); 1397 GNUNET_free (zone);
1283 } 1398 }
1399 if (NULL != stats)
1400 {
1401 GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
1402 stats = NULL;
1403 }
1284} 1404}
1285 1405
1286 1406
@@ -1323,9 +1443,16 @@ ns_lookup_result_cb (void *cls,
1323 char *fqdn; 1443 char *fqdn;
1324 1444
1325 ns_iterator_trigger_next--; 1445 ns_iterator_trigger_next--;
1446 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1447 "Obtained NAMESTORE reply, %llu left in round\n",
1448 (unsigned long long) ns_iterator_trigger_next);
1326 if (0 == ns_iterator_trigger_next) 1449 if (0 == ns_iterator_trigger_next)
1327 { 1450 {
1328 ns_iterator_trigger_next = NS_BATCH_SIZE; 1451 ns_iterator_trigger_next = NS_BATCH_SIZE;
1452 GNUNET_STATISTICS_update (stats,
1453 "# NAMESTORE records requested",
1454 ns_iterator_trigger_next,
1455 GNUNET_NO);
1329 GNUNET_NAMESTORE_zone_iterator_next (zone_it, 1456 GNUNET_NAMESTORE_zone_iterator_next (zone_it,
1330 ns_iterator_trigger_next); 1457 ns_iterator_trigger_next);
1331 } 1458 }
@@ -1377,6 +1504,7 @@ ns_lookup_result_cb (void *cls,
1377 { 1504 {
1378 unsigned int pos = 0; 1505 unsigned int pos = 0;
1379 1506
1507 cached++;
1380 req->expires = GNUNET_TIME_UNIT_FOREVER_ABS; 1508 req->expires = GNUNET_TIME_UNIT_FOREVER_ABS;
1381 for (struct Record *rec = req->rec_head; 1509 for (struct Record *rec = req->rec_head;
1382 NULL != rec; 1510 NULL != rec;
@@ -1522,12 +1650,24 @@ iterate_zones (void *cls)
1522 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1650 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1523 "Finished iteration over zone `%s'!\n", 1651 "Finished iteration over zone `%s'!\n",
1524 last->domain); 1652 last->domain);
1653 /* subtract left-overs from previous iteration */
1654 GNUNET_STATISTICS_update (stats,
1655 "# NAMESTORE records requested",
1656 (long long) (- ns_iterator_trigger_next),
1657 GNUNET_NO);
1658 ns_iterator_trigger_next = 0;
1525 } 1659 }
1526 GNUNET_assert (NULL != zone_tail); 1660 GNUNET_assert (NULL != zone_tail);
1527 if (zone_tail == last) 1661 if (zone_tail == last)
1528 { 1662 {
1529 /* Done iterating over relevant zones in NAMESTORE, move 1663 /* Done iterating over relevant zones in NAMESTORE, move
1530 rest of hash map to work queue as well. */ 1664 rest of hash map to work queue as well. */
1665 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1666 "Finished all NAMESTORE iterations!\n");
1667 GNUNET_STATISTICS_set (stats,
1668 "# NAMESTORE lookups without reply",
1669 GNUNET_CONTAINER_multihashmap_size (ns_pending),
1670 GNUNET_NO);
1531 GNUNET_CONTAINER_multihashmap_iterate (ns_pending, 1671 GNUNET_CONTAINER_multihashmap_iterate (ns_pending,
1532 &move_to_queue, 1672 &move_to_queue,
1533 NULL); 1673 NULL);
@@ -1542,7 +1682,16 @@ iterate_zones (void *cls)
1542 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1682 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1543 "Starting iteration over zone `%s'!\n", 1683 "Starting iteration over zone `%s'!\n",
1544 last->domain); 1684 last->domain);
1685 /* subtract left-overs from previous iteration */
1686 GNUNET_STATISTICS_update (stats,
1687 "# NAMESTORE records requested",
1688 1,
1689 GNUNET_NO);
1545 ns_iterator_trigger_next = 1; 1690 ns_iterator_trigger_next = 1;
1691 GNUNET_STATISTICS_update (stats,
1692 "# zones iterated",
1693 1,
1694 GNUNET_NO);
1546 zone_it = GNUNET_NAMESTORE_zone_iteration_start (ns, 1695 zone_it = GNUNET_NAMESTORE_zone_iteration_start (ns,
1547 &last->key, 1696 &last->key,
1548 &ns_lookup_error_cb, 1697 &ns_lookup_error_cb,
@@ -1594,10 +1743,18 @@ process_stdin (void *cls)
1594 "Imported 1000 records in %s\n", 1743 "Imported 1000 records in %s\n",
1595 GNUNET_STRINGS_relative_time_to_string (delta, 1744 GNUNET_STRINGS_relative_time_to_string (delta,
1596 GNUNET_YES)); 1745 GNUNET_YES));
1746 GNUNET_STATISTICS_set (stats,
1747 "# domain names provided",
1748 pdot,
1749 GNUNET_NO);
1597 } 1750 }
1598 queue (hn); 1751 queue (hn);
1599 } 1752 }
1600 fprintf (stderr, "\n"); 1753 fprintf (stderr, "\n");
1754 GNUNET_STATISTICS_set (stats,
1755 "# domain names provided",
1756 pdot,
1757 GNUNET_NO);
1601 iterate_zones (NULL); 1758 iterate_zones (NULL);
1602} 1759}
1603 1760
@@ -1691,6 +1848,8 @@ run (void *cls,
1691 (void) cls; 1848 (void) cls;
1692 (void) args; 1849 (void) args;
1693 (void) cfgfile; 1850 (void) cfgfile;
1851 stats = GNUNET_STATISTICS_create ("zoneimport",
1852 cfg);
1694 req_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); 1853 req_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
1695 ns_pending = GNUNET_CONTAINER_multihashmap_create (1024, 1854 ns_pending = GNUNET_CONTAINER_multihashmap_create (1024,
1696 GNUNET_NO); 1855 GNUNET_NO);
@@ -1763,9 +1922,12 @@ main (int argc,
1763 NULL); 1922 NULL);
1764 GNUNET_free ((void*) argv); 1923 GNUNET_free ((void*) argv);
1765 fprintf (stderr, 1924 fprintf (stderr,
1766 "Rejected %u names, did %u lookups, found %u records, %u lookups failed, %u/%u pending on shutdown\n", 1925 "Rejected %u names, had %u cached, did %u lookups, stored %u record sets\n"
1926 "Found %u records, %u lookups failed, %u/%u pending on shutdown\n",
1767 rejects, 1927 rejects,
1928 cached,
1768 lookups, 1929 lookups,
1930 record_sets,
1769 records, 1931 records,
1770 failures, 1932 failures,
1771 pending, 1933 pending,