diff options
author | Christian Grothoff <christian@grothoff.org> | 2018-05-01 11:53:00 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2018-05-01 11:53:00 +0200 |
commit | 8f0e0c9dfd1020c5a202cd1927054291c034ca20 (patch) | |
tree | 0e41ffe7a1863c00310e1433609dcd95fa224b64 | |
parent | 3b16879d89a65d3f3b386be76d15954d5423d532 (diff) | |
download | gnunet-8f0e0c9dfd1020c5a202cd1927054291c034ca20.tar.gz gnunet-8f0e0c9dfd1020c5a202cd1927054291c034ca20.zip |
add perf_ logic for namestore iterations, improve namestore insertion performance by 30
percent
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | src/namestore/Makefile.am | 41 | ||||
-rw-r--r-- | src/namestore/gnunet-service-namestore.c | 21 | ||||
-rw-r--r-- | src/namestore/perf_namestore_api_zone_iteration.c | 389 | ||||
-rw-r--r-- | src/namestore/test_namestore_api_flat.conf | 7 | ||||
-rw-r--r-- | src/namestore/test_namestore_api_postgres.conf | 7 | ||||
-rw-r--r-- | src/namestore/test_namestore_api_sqlite.conf | 4 | ||||
-rw-r--r-- | src/namestore/test_plugin_namestore.c | 2 |
8 files changed, 454 insertions, 20 deletions
diff --git a/.gitignore b/.gitignore index 3c739546f..b7dd58739 100644 --- a/.gitignore +++ b/.gitignore | |||
@@ -46,3 +46,6 @@ src/credential/gnunet-credential | |||
46 | src/credential/gnunet-service-credential | 46 | src/credential/gnunet-service-credential |
47 | src/identity-provider/gnunet-idp | 47 | src/identity-provider/gnunet-idp |
48 | *.patch | 48 | *.patch |
49 | src/namestore/perf_namestore_api_zone_iteration_flat | ||
50 | src/namestore/perf_namestore_api_zone_iteration_postgres | ||
51 | src/namestore/perf_namestore_api_zone_iteration_sqlite | ||
diff --git a/src/namestore/Makefile.am b/src/namestore/Makefile.am index 5f18506a7..b925261b7 100644 --- a/src/namestore/Makefile.am +++ b/src/namestore/Makefile.am | |||
@@ -20,29 +20,28 @@ if USE_COVERAGE | |||
20 | XLIBS = -lgcov | 20 | XLIBS = -lgcov |
21 | endif | 21 | endif |
22 | 22 | ||
23 | if HAVE_EXPERIMENTAL | ||
24 | FLAT_PLUGIN = libgnunet_plugin_namestore_flat.la | 23 | FLAT_PLUGIN = libgnunet_plugin_namestore_flat.la |
25 | if HAVE_TESTING | 24 | if HAVE_TESTING |
26 | FLAT_TESTS = test_plugin_namestore_flat | 25 | FLAT_TESTS = test_plugin_namestore_flat \ |
27 | endif | 26 | perf_namestore_api_zone_iteration_flat |
28 | endif | 27 | endif |
29 | 28 | ||
30 | if HAVE_SQLITE | 29 | if HAVE_SQLITE |
31 | SQLITE_PLUGIN = libgnunet_plugin_namestore_sqlite.la | 30 | SQLITE_PLUGIN = libgnunet_plugin_namestore_sqlite.la |
32 | if HAVE_TESTING | 31 | if HAVE_TESTING |
33 | SQLITE_TESTS = test_plugin_namestore_sqlite | 32 | SQLITE_TESTS = test_plugin_namestore_sqlite \ |
33 | perf_namestore_api_zone_iteration_sqlite | ||
34 | endif | 34 | endif |
35 | endif | 35 | endif |
36 | 36 | ||
37 | if HAVE_POSTGRESQL | 37 | if HAVE_POSTGRESQL |
38 | # postgres doesn't even build yet; thus: experimental! | ||
39 | POSTGRES_PLUGIN = libgnunet_plugin_namestore_postgres.la | 38 | POSTGRES_PLUGIN = libgnunet_plugin_namestore_postgres.la |
40 | if HAVE_TESTING | 39 | if HAVE_TESTING |
41 | POSTGRES_TESTS = test_plugin_namestore_postgres | 40 | POSTGRES_TESTS = test_plugin_namestore_postgres \ |
41 | perf_namestore_api_zone_iteration_postgres | ||
42 | endif | 42 | endif |
43 | endif | 43 | endif |
44 | 44 | ||
45 | # testcases do not even build yet; thus: experimental! | ||
46 | if HAVE_TESTING | 45 | if HAVE_TESTING |
47 | TESTING_TESTS = \ | 46 | TESTING_TESTS = \ |
48 | test_namestore_api_store.nc \ | 47 | test_namestore_api_store.nc \ |
@@ -81,7 +80,6 @@ test_namestore_api_zone_iteration_specific_zone.log: test_namestore_api_zone_ite | |||
81 | test_namestore_api_zone_iteration_stop.log: test_namestore_api_monitoring.log | 80 | test_namestore_api_zone_iteration_stop.log: test_namestore_api_monitoring.log |
82 | test_namestore_api_monitoring.log: test_namestore_api_monitoring_existing.log | 81 | test_namestore_api_monitoring.log: test_namestore_api_monitoring_existing.log |
83 | 82 | ||
84 | |||
85 | if HAVE_SQLITE | 83 | if HAVE_SQLITE |
86 | check_PROGRAMS = \ | 84 | check_PROGRAMS = \ |
87 | $(SQLITE_TESTS) \ | 85 | $(SQLITE_TESTS) \ |
@@ -341,6 +339,30 @@ test_namestore_api_zone_iteration_nc_LDADD = \ | |||
341 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 339 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
342 | libgnunetnamestore.la | 340 | libgnunetnamestore.la |
343 | 341 | ||
342 | perf_namestore_api_zone_iteration_postgres_SOURCES = \ | ||
343 | perf_namestore_api_zone_iteration.c | ||
344 | perf_namestore_api_zone_iteration_postgres_LDADD = \ | ||
345 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
346 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
347 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | ||
348 | libgnunetnamestore.la | ||
349 | |||
350 | perf_namestore_api_zone_iteration_sqlite_SOURCES = \ | ||
351 | perf_namestore_api_zone_iteration.c | ||
352 | perf_namestore_api_zone_iteration_sqlite_LDADD = \ | ||
353 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
354 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
355 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | ||
356 | libgnunetnamestore.la | ||
357 | |||
358 | perf_namestore_api_zone_iteration_flat_SOURCES = \ | ||
359 | perf_namestore_api_zone_iteration.c | ||
360 | perf_namestore_api_zone_iteration_flat_LDADD = \ | ||
361 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
362 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
363 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | ||
364 | libgnunetnamestore.la | ||
365 | |||
344 | test_namestore_api_zone_iteration_nick_nc_SOURCES = \ | 366 | test_namestore_api_zone_iteration_nick_nc_SOURCES = \ |
345 | test_namestore_api_zone_iteration_nick.c | 367 | test_namestore_api_zone_iteration_nick.c |
346 | test_namestore_api_zone_iteration_nick_nc_LDADD = \ | 368 | test_namestore_api_zone_iteration_nick_nc_LDADD = \ |
@@ -391,6 +413,9 @@ check_SCRIPTS = \ | |||
391 | 413 | ||
392 | EXTRA_DIST = \ | 414 | EXTRA_DIST = \ |
393 | test_namestore_api.conf \ | 415 | test_namestore_api.conf \ |
416 | test_namestore_api_postgres.conf \ | ||
417 | test_namestore_api_sqlite.conf \ | ||
418 | test_namestore_api_flat.conf \ | ||
394 | test_plugin_namestore_sqlite.conf \ | 419 | test_plugin_namestore_sqlite.conf \ |
395 | test_plugin_namestore_postgres.conf \ | 420 | test_plugin_namestore_postgres.conf \ |
396 | test_plugin_namestore_flat.conf \ | 421 | test_plugin_namestore_flat.conf \ |
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c index e3936a7cc..0456e5c15 100644 --- a/src/namestore/gnunet-service-namestore.c +++ b/src/namestore/gnunet-service-namestore.c | |||
@@ -1032,7 +1032,8 @@ check_record_store (void *cls, | |||
1032 | GNUNET_break (0); | 1032 | GNUNET_break (0); |
1033 | return GNUNET_SYSERR; | 1033 | return GNUNET_SYSERR; |
1034 | } | 1034 | } |
1035 | if ((0 == name_len) || (name_len > MAX_NAME_LEN)) | 1035 | if ( (0 == name_len) || |
1036 | (name_len > MAX_NAME_LEN) ) | ||
1036 | { | 1037 | { |
1037 | GNUNET_break (0); | 1038 | GNUNET_break (0); |
1038 | return GNUNET_SYSERR; | 1039 | return GNUNET_SYSERR; |
@@ -1066,7 +1067,6 @@ handle_record_store (void *cls, | |||
1066 | const char *rd_ser; | 1067 | const char *rd_ser; |
1067 | unsigned int rd_count; | 1068 | unsigned int rd_count; |
1068 | int res; | 1069 | int res; |
1069 | struct GNUNET_CRYPTO_EcdsaPublicKey pubkey; | ||
1070 | struct ZoneMonitor *zm; | 1070 | struct ZoneMonitor *zm; |
1071 | 1071 | ||
1072 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1072 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1093,8 +1093,6 @@ handle_record_store (void *cls, | |||
1093 | } | 1093 | } |
1094 | 1094 | ||
1095 | /* Extracting and converting private key */ | 1095 | /* Extracting and converting private key */ |
1096 | GNUNET_CRYPTO_ecdsa_key_get_public (&rp_msg->private_key, | ||
1097 | &pubkey); | ||
1098 | conv_name = GNUNET_GNSRECORD_string_to_lowercase (name_tmp); | 1096 | conv_name = GNUNET_GNSRECORD_string_to_lowercase (name_tmp); |
1099 | if (NULL == conv_name) | 1097 | if (NULL == conv_name) |
1100 | { | 1098 | { |
@@ -1105,11 +1103,9 @@ handle_record_store (void *cls, | |||
1105 | return; | 1103 | return; |
1106 | } | 1104 | } |
1107 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1105 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1108 | "Creating %u records for name `%s' in zone `%s'\n", | 1106 | "Creating %u records for name `%s'\n", |
1109 | (unsigned int) rd_count, | 1107 | (unsigned int) rd_count, |
1110 | conv_name, | 1108 | conv_name); |
1111 | GNUNET_GNSRECORD_z2s (&pubkey)); | ||
1112 | |||
1113 | if ( (0 == rd_count) && | 1109 | if ( (0 == rd_count) && |
1114 | (GNUNET_NO == | 1110 | (GNUNET_NO == |
1115 | GSN_database->iterate_records (GSN_database->cls, | 1111 | GSN_database->iterate_records (GSN_database->cls, |
@@ -1150,7 +1146,8 @@ handle_record_store (void *cls, | |||
1150 | { | 1146 | { |
1151 | for (zm = monitor_head; NULL != zm; zm = zm->next) | 1147 | for (zm = monitor_head; NULL != zm; zm = zm->next) |
1152 | { | 1148 | { |
1153 | if ( (0 == memcmp (&rp_msg->private_key, &zm->zone, | 1149 | if ( (0 == memcmp (&rp_msg->private_key, |
1150 | &zm->zone, | ||
1154 | sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))) || | 1151 | sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))) || |
1155 | (0 == memcmp (&zm->zone, | 1152 | (0 == memcmp (&zm->zone, |
1156 | &zero, | 1153 | &zero, |
@@ -1363,7 +1360,7 @@ struct ZoneIterationProcResult | |||
1363 | 1360 | ||
1364 | /** | 1361 | /** |
1365 | * Process results for zone iteration from database | 1362 | * Process results for zone iteration from database |
1366 | * | 1363 | * |
1367 | * @param cls struct ZoneIterationProcResult | 1364 | * @param cls struct ZoneIterationProcResult |
1368 | * @param seq sequence number of the record | 1365 | * @param seq sequence number of the record |
1369 | * @param zone_key the zone key | 1366 | * @param zone_key the zone key |
@@ -1446,6 +1443,10 @@ run_zone_iteration_round (struct ZoneIteration *zi, | |||
1446 | memset (&proc, | 1443 | memset (&proc, |
1447 | 0, | 1444 | 0, |
1448 | sizeof (proc)); | 1445 | sizeof (proc)); |
1446 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1447 | "Asked to return up to %llu records at position %llu\n", | ||
1448 | (unsigned long long) limit, | ||
1449 | (unsigned long long) zi->seq); | ||
1449 | proc.zi = zi; | 1450 | proc.zi = zi; |
1450 | proc.limit = limit; | 1451 | proc.limit = limit; |
1451 | start = GNUNET_TIME_absolute_get (); | 1452 | start = GNUNET_TIME_absolute_get (); |
diff --git a/src/namestore/perf_namestore_api_zone_iteration.c b/src/namestore/perf_namestore_api_zone_iteration.c new file mode 100644 index 000000000..8b5c53576 --- /dev/null +++ b/src/namestore/perf_namestore_api_zone_iteration.c | |||
@@ -0,0 +1,389 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2013, 2018 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | ||
20 | /** | ||
21 | * @file namestore/perf_namestore_api_zone_iteration.c | ||
22 | * @brief testcase for zone iteration functionality: iterate all zones | ||
23 | * @author Christian Grothoff | ||
24 | */ | ||
25 | #include "platform.h" | ||
26 | #include "gnunet_namestore_service.h" | ||
27 | #include "gnunet_testing_lib.h" | ||
28 | #include "namestore.h" | ||
29 | |||
30 | /** | ||
31 | * A #BENCHMARK_SIZE of 1000 takes less than a minute on a reasonably | ||
32 | * modern system, so 30 minutes should be OK even for very, very | ||
33 | * slow systems. | ||
34 | */ | ||
35 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 30) | ||
36 | |||
37 | /** | ||
38 | * The runtime of the benchmark is expected to be linear | ||
39 | * for the iteration phase with a *good* database. The FLAT | ||
40 | * database uses a quadratic retrieval algorithm, | ||
41 | * hence it should be quadratic in the size. | ||
42 | */ | ||
43 | #define BENCHMARK_SIZE 1000 | ||
44 | |||
45 | /** | ||
46 | * Maximum record size | ||
47 | */ | ||
48 | #define MAX_REC_SIZE 500 | ||
49 | |||
50 | /** | ||
51 | * How big are the blocks we fetch? Note that the first block is | ||
52 | * always just 1 record set per current API. Smaller block | ||
53 | * sizes will make quadratic iteration-by-offset penalties | ||
54 | * more pronounced. | ||
55 | */ | ||
56 | #define BLOCK_SIZE 100 | ||
57 | |||
58 | static struct GNUNET_NAMESTORE_Handle *nsh; | ||
59 | |||
60 | static struct GNUNET_SCHEDULER_Task *timeout_task; | ||
61 | |||
62 | static struct GNUNET_SCHEDULER_Task *t; | ||
63 | |||
64 | static struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey; | ||
65 | |||
66 | static struct GNUNET_NAMESTORE_ZoneIterator *zi; | ||
67 | |||
68 | static struct GNUNET_NAMESTORE_QueueEntry *qe; | ||
69 | |||
70 | static int res; | ||
71 | |||
72 | static char *directory; | ||
73 | |||
74 | static unsigned int off; | ||
75 | |||
76 | static unsigned int left_until_next; | ||
77 | |||
78 | static uint8_t seen[1 + BENCHMARK_SIZE / 8]; | ||
79 | |||
80 | static struct GNUNET_TIME_Absolute start; | ||
81 | |||
82 | |||
83 | /** | ||
84 | * Terminate everything | ||
85 | * | ||
86 | * @param cls NULL | ||
87 | */ | ||
88 | static void | ||
89 | end (void *cls) | ||
90 | { | ||
91 | (void) cls; | ||
92 | if (NULL != qe) | ||
93 | { | ||
94 | GNUNET_NAMESTORE_cancel (qe); | ||
95 | qe = NULL; | ||
96 | } | ||
97 | if (NULL != zi) | ||
98 | { | ||
99 | GNUNET_NAMESTORE_zone_iteration_stop (zi); | ||
100 | zi = NULL; | ||
101 | } | ||
102 | if (NULL != nsh) | ||
103 | { | ||
104 | GNUNET_NAMESTORE_disconnect (nsh); | ||
105 | nsh = NULL; | ||
106 | } | ||
107 | if (NULL != t) | ||
108 | { | ||
109 | GNUNET_SCHEDULER_cancel (t); | ||
110 | t = NULL; | ||
111 | } | ||
112 | if (NULL != timeout_task) | ||
113 | { | ||
114 | GNUNET_SCHEDULER_cancel (timeout_task); | ||
115 | timeout_task = NULL; | ||
116 | } | ||
117 | if (NULL != privkey) | ||
118 | { | ||
119 | GNUNET_free (privkey); | ||
120 | privkey = NULL; | ||
121 | } | ||
122 | res = 1; | ||
123 | } | ||
124 | |||
125 | |||
126 | /** | ||
127 | * End with timeout. As this is a benchmark, we do not | ||
128 | * fail hard but return "skipped". | ||
129 | */ | ||
130 | static void | ||
131 | timeout (void *cls) | ||
132 | { | ||
133 | (void) cls; | ||
134 | timeout_task = NULL; | ||
135 | GNUNET_SCHEDULER_shutdown (); | ||
136 | res = 77; | ||
137 | } | ||
138 | |||
139 | |||
140 | static struct GNUNET_GNSRECORD_Data * | ||
141 | create_record (unsigned int count) | ||
142 | { | ||
143 | struct GNUNET_GNSRECORD_Data *rd; | ||
144 | |||
145 | rd = GNUNET_malloc (count + sizeof (struct GNUNET_GNSRECORD_Data)); | ||
146 | rd->expiration_time = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS).abs_value_us; | ||
147 | rd->record_type = count; | ||
148 | rd->data_size = count; | ||
149 | rd->data = (void *) &rd[1]; | ||
150 | rd->flags = 0; | ||
151 | memset (&rd[1], | ||
152 | 'a', | ||
153 | count); | ||
154 | return rd; | ||
155 | } | ||
156 | |||
157 | |||
158 | static void | ||
159 | zone_end (void *cls) | ||
160 | { | ||
161 | struct GNUNET_TIME_Relative delay; | ||
162 | |||
163 | zi = NULL; | ||
164 | delay = GNUNET_TIME_absolute_get_duration (start); | ||
165 | fprintf (stdout, | ||
166 | "Iterating over %u records took %s\n", | ||
167 | off, | ||
168 | GNUNET_STRINGS_relative_time_to_string (delay, | ||
169 | GNUNET_YES)); | ||
170 | if (BENCHMARK_SIZE == off) | ||
171 | { | ||
172 | res = 0; | ||
173 | } | ||
174 | else | ||
175 | { | ||
176 | GNUNET_break (0); | ||
177 | res = 1; | ||
178 | } | ||
179 | GNUNET_SCHEDULER_shutdown (); | ||
180 | } | ||
181 | |||
182 | |||
183 | static void | ||
184 | fail_cb (void *cls) | ||
185 | { | ||
186 | zi = NULL; | ||
187 | res = 2; | ||
188 | GNUNET_break (0); | ||
189 | GNUNET_SCHEDULER_shutdown (); | ||
190 | } | ||
191 | |||
192 | |||
193 | static void | ||
194 | zone_proc (void *cls, | ||
195 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | ||
196 | const char *label, | ||
197 | unsigned int rd_count, | ||
198 | const struct GNUNET_GNSRECORD_Data *rd) | ||
199 | { | ||
200 | struct GNUNET_GNSRECORD_Data *wrd; | ||
201 | unsigned int xoff; | ||
202 | |||
203 | GNUNET_assert (NULL != zone); | ||
204 | if (1 != sscanf (label, | ||
205 | "l%u", | ||
206 | &xoff)) | ||
207 | { | ||
208 | res = 3; | ||
209 | GNUNET_break (0); | ||
210 | GNUNET_SCHEDULER_shutdown (); | ||
211 | return; | ||
212 | } | ||
213 | if ( (xoff > BENCHMARK_SIZE) || | ||
214 | (0 != (seen[xoff / 8] & (1U << (xoff % 8)))) ) | ||
215 | { | ||
216 | res = 3; | ||
217 | GNUNET_break (0); | ||
218 | GNUNET_SCHEDULER_shutdown (); | ||
219 | return; | ||
220 | } | ||
221 | seen[xoff / 8] |= (1U << (xoff % 8)); | ||
222 | wrd = create_record (xoff % MAX_REC_SIZE); | ||
223 | if ( (rd->record_type != wrd->record_type) || | ||
224 | (rd->data_size != wrd->data_size) || | ||
225 | (rd->flags != wrd->flags) ) | ||
226 | { | ||
227 | res = 4; | ||
228 | GNUNET_break (0); | ||
229 | GNUNET_SCHEDULER_shutdown (); | ||
230 | GNUNET_free (wrd); | ||
231 | return; | ||
232 | } | ||
233 | if (0 != memcmp (rd->data, | ||
234 | wrd->data, | ||
235 | wrd->data_size)) | ||
236 | { | ||
237 | res = 4; | ||
238 | GNUNET_break (0); | ||
239 | GNUNET_SCHEDULER_shutdown (); | ||
240 | GNUNET_free (wrd); | ||
241 | return; | ||
242 | } | ||
243 | GNUNET_free (wrd); | ||
244 | if (0 != memcmp (zone, | ||
245 | privkey, | ||
246 | sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))) | ||
247 | { | ||
248 | res = 5; | ||
249 | GNUNET_break (0); | ||
250 | GNUNET_SCHEDULER_shutdown (); | ||
251 | return; | ||
252 | } | ||
253 | off++; | ||
254 | left_until_next--; | ||
255 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
256 | "Obtained record %u, expecting %u more until asking for mor explicitly\n", | ||
257 | off, | ||
258 | left_until_next); | ||
259 | if (0 == left_until_next) | ||
260 | { | ||
261 | left_until_next = BLOCK_SIZE; | ||
262 | GNUNET_NAMESTORE_zone_iterator_next (zi, | ||
263 | left_until_next); | ||
264 | } | ||
265 | } | ||
266 | |||
267 | |||
268 | static void | ||
269 | publish_record (void *cls); | ||
270 | |||
271 | |||
272 | static void | ||
273 | put_cont (void *cls, | ||
274 | int32_t success, | ||
275 | const char *emsg) | ||
276 | { | ||
277 | (void) cls; | ||
278 | qe = NULL; | ||
279 | GNUNET_assert (GNUNET_OK == success); | ||
280 | t = GNUNET_SCHEDULER_add_now (&publish_record, | ||
281 | NULL); | ||
282 | } | ||
283 | |||
284 | |||
285 | static void | ||
286 | publish_record (void *cls) | ||
287 | { | ||
288 | struct GNUNET_GNSRECORD_Data *rd; | ||
289 | char *label; | ||
290 | |||
291 | (void) cls; | ||
292 | t = NULL; | ||
293 | if (BENCHMARK_SIZE == off) | ||
294 | { | ||
295 | struct GNUNET_TIME_Relative delay; | ||
296 | |||
297 | delay = GNUNET_TIME_absolute_get_duration (start); | ||
298 | fprintf (stdout, | ||
299 | "Inserting %u records took %s\n", | ||
300 | off, | ||
301 | GNUNET_STRINGS_relative_time_to_string (delay, | ||
302 | GNUNET_YES)); | ||
303 | start = GNUNET_TIME_absolute_get (); | ||
304 | off = 0; | ||
305 | left_until_next = 1; | ||
306 | zi = GNUNET_NAMESTORE_zone_iteration_start (nsh, | ||
307 | NULL, | ||
308 | &fail_cb, | ||
309 | NULL, | ||
310 | &zone_proc, | ||
311 | NULL, | ||
312 | &zone_end, | ||
313 | NULL); | ||
314 | GNUNET_assert (NULL != zi); | ||
315 | return; | ||
316 | } | ||
317 | rd = create_record ((++off) % MAX_REC_SIZE); | ||
318 | GNUNET_asprintf (&label, | ||
319 | "l%u", | ||
320 | off); | ||
321 | qe = GNUNET_NAMESTORE_records_store (nsh, | ||
322 | privkey, | ||
323 | label, | ||
324 | 1, rd, | ||
325 | &put_cont, | ||
326 | NULL); | ||
327 | GNUNET_free (label); | ||
328 | GNUNET_free (rd); | ||
329 | } | ||
330 | |||
331 | |||
332 | static void | ||
333 | run (void *cls, | ||
334 | const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
335 | struct GNUNET_TESTING_Peer *peer) | ||
336 | { | ||
337 | directory = NULL; | ||
338 | GNUNET_assert (GNUNET_OK == | ||
339 | GNUNET_CONFIGURATION_get_value_string(cfg, | ||
340 | "PATHS", | ||
341 | "GNUNET_TEST_HOME", | ||
342 | &directory)); | ||
343 | GNUNET_DISK_directory_remove (directory); | ||
344 | GNUNET_SCHEDULER_add_shutdown (&end, | ||
345 | NULL); | ||
346 | timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, | ||
347 | &timeout, | ||
348 | NULL); | ||
349 | nsh = GNUNET_NAMESTORE_connect (cfg); | ||
350 | GNUNET_assert (NULL != nsh); | ||
351 | privkey = GNUNET_CRYPTO_ecdsa_key_create (); | ||
352 | GNUNET_assert (NULL != privkey); | ||
353 | start = GNUNET_TIME_absolute_get (); | ||
354 | t = GNUNET_SCHEDULER_add_now (&publish_record, | ||
355 | NULL); | ||
356 | } | ||
357 | |||
358 | |||
359 | int | ||
360 | main (int argc, | ||
361 | char *argv[]) | ||
362 | { | ||
363 | const char *plugin_name; | ||
364 | char *cfg_name; | ||
365 | |||
366 | plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); | ||
367 | GNUNET_asprintf (&cfg_name, | ||
368 | "test_namestore_api_%s.conf", | ||
369 | plugin_name); | ||
370 | res = 1; | ||
371 | if (0 != | ||
372 | GNUNET_TESTING_peer_run ("perf-namestore-api-zone-iteration", | ||
373 | cfg_name, | ||
374 | &run, | ||
375 | NULL)) | ||
376 | { | ||
377 | res = 1; | ||
378 | } | ||
379 | GNUNET_free (cfg_name); | ||
380 | if (NULL != directory) | ||
381 | { | ||
382 | GNUNET_DISK_directory_remove (directory); | ||
383 | GNUNET_free (directory); | ||
384 | } | ||
385 | return res; | ||
386 | } | ||
387 | |||
388 | |||
389 | /* end of perf_namestore_api_zone_iteration.c */ | ||
diff --git a/src/namestore/test_namestore_api_flat.conf b/src/namestore/test_namestore_api_flat.conf new file mode 100644 index 000000000..26e2f2c51 --- /dev/null +++ b/src/namestore/test_namestore_api_flat.conf | |||
@@ -0,0 +1,7 @@ | |||
1 | @INLINE@ test_namestore_api.conf | ||
2 | |||
3 | [namestore] | ||
4 | DATABASE = flat | ||
5 | |||
6 | [namecache] | ||
7 | DISABLE = YES | ||
diff --git a/src/namestore/test_namestore_api_postgres.conf b/src/namestore/test_namestore_api_postgres.conf new file mode 100644 index 000000000..259ce35e7 --- /dev/null +++ b/src/namestore/test_namestore_api_postgres.conf | |||
@@ -0,0 +1,7 @@ | |||
1 | @INLINE@ test_namestore_api.conf | ||
2 | |||
3 | [namestore] | ||
4 | DATABASE = postgres | ||
5 | |||
6 | [namecache] | ||
7 | DISABLE = YES | ||
diff --git a/src/namestore/test_namestore_api_sqlite.conf b/src/namestore/test_namestore_api_sqlite.conf new file mode 100644 index 000000000..72b609226 --- /dev/null +++ b/src/namestore/test_namestore_api_sqlite.conf | |||
@@ -0,0 +1,4 @@ | |||
1 | @INLINE@ test_namestore_api.conf | ||
2 | |||
3 | [namecache] | ||
4 | DISABLE = YES | ||
diff --git a/src/namestore/test_plugin_namestore.c b/src/namestore/test_plugin_namestore.c index ac2a0bba9..6bccd1706 100644 --- a/src/namestore/test_plugin_namestore.c +++ b/src/namestore/test_plugin_namestore.c | |||
@@ -207,7 +207,6 @@ main (int argc, | |||
207 | GNUNET_GETOPT_OPTION_END | 207 | GNUNET_GETOPT_OPTION_END |
208 | }; | 208 | }; |
209 | 209 | ||
210 | //GNUNET_DISK_directory_remove ("/tmp/gnunet-test-plugin-namestore-sqlite"); | ||
211 | GNUNET_log_setup ("test-plugin-namestore", | 210 | GNUNET_log_setup ("test-plugin-namestore", |
212 | "WARNING", | 211 | "WARNING", |
213 | NULL); | 212 | NULL); |
@@ -227,7 +226,6 @@ main (int argc, | |||
227 | FPRINTF (stderr, | 226 | FPRINTF (stderr, |
228 | "Missed some testcases: %d\n", | 227 | "Missed some testcases: %d\n", |
229 | ok); | 228 | ok); |
230 | //GNUNET_DISK_directory_remove ("/tmp/gnunet-test-plugin-namestore-sqlite"); | ||
231 | return ok; | 229 | return ok; |
232 | } | 230 | } |
233 | 231 | ||