diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-04-04 19:13:09 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-04-04 19:13:09 +0000 |
commit | 156cd49553ba04254af64a883a54a933c57313df (patch) | |
tree | 405ac3eda3103ba69fe259681f5e0a60470f1e84 /src/datastore | |
parent | ccbca5bb868adb98e9a95f6e3dea8dfc9012515a (diff) | |
download | gnunet-156cd49553ba04254af64a883a54a933c57313df.tar.gz gnunet-156cd49553ba04254af64a883a54a933c57313df.zip |
fixes
Diffstat (limited to 'src/datastore')
-rw-r--r-- | src/datastore/test_plugin_datastore.c | 246 | ||||
-rw-r--r-- | src/datastore/test_plugin_datastore_data_mysql.conf | 2 | ||||
-rw-r--r-- | src/datastore/test_plugin_datastore_data_postgres.conf | 2 | ||||
-rw-r--r-- | src/datastore/test_plugin_datastore_data_sqlite.conf | 2 |
4 files changed, 141 insertions, 111 deletions
diff --git a/src/datastore/test_plugin_datastore.c b/src/datastore/test_plugin_datastore.c index eed3d978b..830616369 100644 --- a/src/datastore/test_plugin_datastore.c +++ b/src/datastore/test_plugin_datastore.c | |||
@@ -38,12 +38,12 @@ | |||
38 | */ | 38 | */ |
39 | #define MAX_SIZE 1024LL * 1024 * 128 | 39 | #define MAX_SIZE 1024LL * 1024 * 128 |
40 | 40 | ||
41 | #define ITERATIONS 10 | 41 | #define ITERATIONS 2 |
42 | 42 | ||
43 | /** | 43 | /** |
44 | * Number of put operations equivalent to 1/10th of MAX_SIZE | 44 | * Number of put operations to perform. |
45 | */ | 45 | */ |
46 | #define PUT_10 (MAX_SIZE / 32 / 1024 / ITERATIONS) | 46 | #define PUT_10 10 |
47 | 47 | ||
48 | static unsigned long long stored_bytes; | 48 | static unsigned long long stored_bytes; |
49 | 49 | ||
@@ -57,24 +57,24 @@ static int ok; | |||
57 | 57 | ||
58 | enum RunPhase | 58 | enum RunPhase |
59 | { | 59 | { |
60 | RP_DONE = 0, | 60 | RP_ERROR = 0, |
61 | RP_PUT, | 61 | RP_PUT, |
62 | RP_LP_GET, | 62 | RP_GET, |
63 | RP_AE_GET, | 63 | RP_UPDATE, |
64 | RP_ZA_GET | 64 | RP_ITER_ZERO, |
65 | RP_REPL_GET, | ||
66 | RP_EXPI_GET, | ||
67 | RP_DROP | ||
65 | }; | 68 | }; |
66 | 69 | ||
67 | 70 | ||
68 | struct CpsRunContext | 71 | struct CpsRunContext |
69 | { | 72 | { |
70 | unsigned int i; | ||
71 | struct GNUNET_TIME_Absolute start; | ||
72 | struct GNUNET_TIME_Absolute end; | ||
73 | const struct GNUNET_CONFIGURATION_Handle *cfg; | 73 | const struct GNUNET_CONFIGURATION_Handle *cfg; |
74 | struct GNUNET_DATASTORE_PluginFunctions * api; | 74 | struct GNUNET_DATASTORE_PluginFunctions * api; |
75 | const char *msg; | ||
76 | enum RunPhase phase; | 75 | enum RunPhase phase; |
77 | unsigned int cnt; | 76 | unsigned int cnt; |
77 | unsigned int i; | ||
78 | }; | 78 | }; |
79 | 79 | ||
80 | 80 | ||
@@ -90,16 +90,28 @@ static void | |||
90 | disk_utilization_change_cb (void *cls, | 90 | disk_utilization_change_cb (void *cls, |
91 | int delta) | 91 | int delta) |
92 | { | 92 | { |
93 | /* do nothing */ | ||
94 | } | ||
95 | |||
96 | |||
97 | static void | ||
98 | gen_key (int i, | ||
99 | GNUNET_HashCode *key) | ||
100 | { | ||
101 | memset (key, 0, sizeof (GNUNET_HashCode)); | ||
102 | key->bits[0] = (unsigned int) i; | ||
103 | GNUNET_CRYPTO_hash (key, sizeof (GNUNET_HashCode), key); | ||
93 | } | 104 | } |
94 | 105 | ||
95 | 106 | ||
96 | static void | 107 | static void |
97 | putValue (struct GNUNET_DATASTORE_PluginFunctions * api, int i, int k) | 108 | put_value (struct GNUNET_DATASTORE_PluginFunctions * api, |
109 | int i, | ||
110 | int k) | ||
98 | { | 111 | { |
99 | char value[65536]; | 112 | char value[65536]; |
100 | size_t size; | 113 | size_t size; |
101 | static GNUNET_HashCode key; | 114 | GNUNET_HashCode key; |
102 | static int ic; | ||
103 | char *msg; | 115 | char *msg; |
104 | unsigned int prio; | 116 | unsigned int prio; |
105 | 117 | ||
@@ -111,8 +123,7 @@ putValue (struct GNUNET_DATASTORE_PluginFunctions * api, int i, int k) | |||
111 | size = size - (size & 7); /* always multiple of 8 */ | 123 | size = size - (size & 7); /* always multiple of 8 */ |
112 | 124 | ||
113 | /* generate random key */ | 125 | /* generate random key */ |
114 | key.bits[0] = (unsigned int) GNUNET_TIME_absolute_get ().abs_value; | 126 | gen_key (i, &key); |
115 | GNUNET_CRYPTO_hash (&key, sizeof (GNUNET_HashCode), &key); | ||
116 | memset (value, i, size); | 127 | memset (value, i, size); |
117 | if (i > 255) | 128 | if (i > 255) |
118 | memset (value, i - 255, size / 2); | 129 | memset (value, i - 255, size / 2); |
@@ -123,7 +134,7 @@ putValue (struct GNUNET_DATASTORE_PluginFunctions * api, int i, int k) | |||
123 | &key, | 134 | &key, |
124 | size, | 135 | size, |
125 | value, | 136 | value, |
126 | i /* type */, | 137 | i + 1 /* type */, |
127 | prio, | 138 | prio, |
128 | i /* anonymity */, | 139 | i /* anonymity */, |
129 | 0 /* replication */, | 140 | 0 /* replication */, |
@@ -137,99 +148,83 @@ putValue (struct GNUNET_DATASTORE_PluginFunctions * api, int i, int k) | |||
137 | GNUNET_free_non_null (msg); | 148 | GNUNET_free_non_null (msg); |
138 | return; | 149 | return; |
139 | } | 150 | } |
140 | ic++; | ||
141 | stored_bytes += size; | 151 | stored_bytes += size; |
142 | stored_ops++; | 152 | stored_ops++; |
143 | stored_entries++; | 153 | stored_entries++; |
144 | } | 154 | } |
145 | 155 | ||
156 | |||
146 | static void | 157 | static void |
147 | test (void *cls, | 158 | test (void *cls, |
148 | const struct GNUNET_SCHEDULER_TaskContext *tc); | 159 | const struct GNUNET_SCHEDULER_TaskContext *tc); |
149 | 160 | ||
150 | 161 | ||
151 | static int | 162 | static int |
152 | iterateDummy (void *cls, | 163 | iterate_one_shot (void *cls, |
153 | void *next_cls, | 164 | void *next_cls, |
154 | const GNUNET_HashCode * key, | 165 | const GNUNET_HashCode * key, |
155 | uint32_t size, | 166 | uint32_t size, |
156 | const void *data, | 167 | const void *data, |
157 | enum GNUNET_BLOCK_Type type, | 168 | enum GNUNET_BLOCK_Type type, |
158 | uint32_t priority, | 169 | uint32_t priority, |
159 | uint32_t anonymity, | 170 | uint32_t anonymity, |
160 | struct GNUNET_TIME_Absolute | 171 | struct GNUNET_TIME_Absolute |
161 | expiration, | 172 | expiration, |
162 | uint64_t uid) | 173 | uint64_t uid) |
163 | { | 174 | { |
164 | struct CpsRunContext *crc = cls; | 175 | struct CpsRunContext *crc = cls; |
165 | 176 | ||
166 | if (key == NULL) | 177 | GNUNET_assert (NULL == next_cls); |
167 | { | 178 | GNUNET_assert (key != NULL); |
168 | crc->end = GNUNET_TIME_absolute_get(); | 179 | crc->phase++; |
169 | printf (crc->msg, | ||
170 | crc->i, | ||
171 | (unsigned long long) (crc->end.abs_value - crc->start.abs_value), | ||
172 | crc->cnt); | ||
173 | if (crc->phase != RP_ZA_GET) | ||
174 | { | ||
175 | crc->phase++; | ||
176 | } | ||
177 | else | ||
178 | { | ||
179 | if (crc->i == ITERATIONS) | ||
180 | crc->phase = RP_DONE; | ||
181 | else | ||
182 | crc->phase = RP_PUT; | ||
183 | } | ||
184 | crc->cnt = 0; | ||
185 | crc->start = GNUNET_TIME_absolute_get (); | ||
186 | GNUNET_SCHEDULER_add_now (&test, crc); | ||
187 | return GNUNET_OK; | ||
188 | } | ||
189 | #if VERBOSE | 180 | #if VERBOSE |
190 | fprintf (stderr, "Found result type=%u, priority=%u, size=%u, expire=%llu\n", | 181 | fprintf (stderr, |
182 | "Found result type=%u, priority=%u, size=%u, expire=%llu\n", | ||
191 | type, priority, size, | 183 | type, priority, size, |
192 | (unsigned long long) expiration.abs_value); | 184 | (unsigned long long) expiration.abs_value); |
193 | #endif | 185 | #endif |
194 | crc->cnt++; | 186 | GNUNET_SCHEDULER_add_now (&test, crc); |
195 | crc->api->next_request (next_cls, | ||
196 | GNUNET_NO); | ||
197 | return GNUNET_OK; | 187 | return GNUNET_OK; |
198 | } | 188 | } |
199 | 189 | ||
200 | 190 | ||
191 | static uint64_t guid; | ||
201 | 192 | ||
202 | static int | 193 | static int |
203 | dummy_get (void *cls, | 194 | iterate_with_next (void *cls, |
204 | void *next_cls, | 195 | void *next_cls, |
205 | const GNUNET_HashCode * key, | 196 | const GNUNET_HashCode * key, |
206 | uint32_t size, | 197 | uint32_t size, |
207 | const void *data, | 198 | const void *data, |
208 | enum GNUNET_BLOCK_Type type, | 199 | enum GNUNET_BLOCK_Type type, |
209 | uint32_t priority, | 200 | uint32_t priority, |
210 | uint32_t anonymity, | 201 | uint32_t anonymity, |
211 | struct GNUNET_TIME_Absolute | 202 | struct GNUNET_TIME_Absolute |
212 | expiration, | 203 | expiration, |
213 | uint64_t uid) | 204 | uint64_t uid) |
214 | { | 205 | { |
215 | struct CpsRunContext *crc = cls; | 206 | struct CpsRunContext *crc = cls; |
216 | 207 | ||
217 | crc->cnt++; | 208 | if (key == NULL) |
218 | if (1000 == crc->cnt) | ||
219 | { | 209 | { |
220 | crc->end = GNUNET_TIME_absolute_get(); | ||
221 | printf (crc->msg, | ||
222 | crc->i, | ||
223 | (unsigned long long) (crc->end.abs_value - crc->start.abs_value), | ||
224 | crc->cnt); | ||
225 | crc->phase++; | 210 | crc->phase++; |
226 | crc->cnt = 0; | 211 | GNUNET_SCHEDULER_add_now (&test, crc); |
227 | crc->start = GNUNET_TIME_absolute_get (); | 212 | return GNUNET_OK; |
228 | } | 213 | } |
229 | GNUNET_SCHEDULER_add_now (&test, crc); | 214 | guid = uid; |
215 | #if VERBOSE | ||
216 | fprintf (stderr, | ||
217 | "Found result type=%u, priority=%u, size=%u, expire=%llu\n", | ||
218 | type, priority, size, | ||
219 | (unsigned long long) expiration.abs_value); | ||
220 | #endif | ||
221 | crc->cnt++; | ||
222 | crc->api->next_request (next_cls, | ||
223 | GNUNET_NO); | ||
230 | return GNUNET_OK; | 224 | return GNUNET_OK; |
231 | } | 225 | } |
232 | 226 | ||
227 | |||
233 | /** | 228 | /** |
234 | * Function called when the service shuts | 229 | * Function called when the service shuts |
235 | * down. Unloads our datastore plugin. | 230 | * down. Unloads our datastore plugin. |
@@ -267,7 +262,8 @@ unload_plugin (struct GNUNET_DATASTORE_PluginFunctions * api, | |||
267 | * the transport and core. | 262 | * the transport and core. |
268 | */ | 263 | */ |
269 | static void | 264 | static void |
270 | cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 265 | cleaning_task (void *cls, |
266 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
271 | { | 267 | { |
272 | struct CpsRunContext *crc = cls; | 268 | struct CpsRunContext *crc = cls; |
273 | 269 | ||
@@ -282,51 +278,85 @@ test (void *cls, | |||
282 | { | 278 | { |
283 | struct CpsRunContext *crc = cls; | 279 | struct CpsRunContext *crc = cls; |
284 | int j; | 280 | int j; |
281 | unsigned long long os; | ||
282 | unsigned long long cs; | ||
283 | GNUNET_HashCode key; | ||
285 | 284 | ||
286 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 285 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) |
287 | { | 286 | { |
288 | crc->phase = RP_DONE; | 287 | crc->phase = RP_ERROR; |
289 | ok = 1; | 288 | ok = 1; |
290 | } | 289 | } |
291 | switch (crc->phase) | 290 | switch (crc->phase) |
292 | { | 291 | { |
292 | case RP_ERROR: | ||
293 | GNUNET_break (0); | ||
294 | crc->api->drop (crc->api->cls); | ||
295 | GNUNET_SCHEDULER_add_now (&cleaning_task, crc); | ||
296 | break; | ||
293 | case RP_PUT: | 297 | case RP_PUT: |
294 | crc->start = GNUNET_TIME_absolute_get (); | 298 | os = 0; |
295 | for (j=0;j<PUT_10;j++) | 299 | for (j=0;j<PUT_10;j++) |
296 | putValue (crc->api, j, crc->i); | 300 | { |
297 | crc->end = GNUNET_TIME_absolute_get (); | 301 | put_value (crc->api, j, crc->i); |
298 | printf ("%3u insertion took %20llums for %u\n", | 302 | cs = crc->api->get_size (crc->api->cls); |
299 | crc->i, | 303 | GNUNET_assert (os < cs); |
300 | (unsigned long long) (crc->end.abs_value - crc->start.abs_value), | 304 | os = cs; |
301 | (unsigned int) PUT_10); | 305 | } |
302 | crc->i++; | 306 | crc->phase++; |
303 | crc->start = GNUNET_TIME_absolute_get (); | 307 | GNUNET_SCHEDULER_add_now (&test, crc); |
304 | crc->phase = RP_LP_GET; | ||
305 | GNUNET_SCHEDULER_add_after (GNUNET_SCHEDULER_NO_TASK, | ||
306 | &test, crc); | ||
307 | break; | 308 | break; |
308 | case RP_LP_GET: | 309 | case RP_GET: |
309 | crc->msg = "%3u replication iteration took %20llums for %u\n"; | 310 | if (crc->cnt == 1) |
311 | { | ||
312 | crc->cnt = 0; | ||
313 | crc->phase++; | ||
314 | GNUNET_SCHEDULER_add_now (&test, crc); | ||
315 | break; | ||
316 | } | ||
317 | gen_key (5, &key); | ||
318 | crc->api->get (crc->api->cls, | ||
319 | &key, NULL, | ||
320 | GNUNET_BLOCK_TYPE_ANY, | ||
321 | &iterate_with_next, | ||
322 | crc); | ||
323 | break; | ||
324 | case RP_UPDATE: | ||
325 | GNUNET_assert (GNUNET_OK == | ||
326 | crc->api->update (crc->api->cls, | ||
327 | guid, 1, | ||
328 | GNUNET_TIME_UNIT_ZERO_ABS, | ||
329 | NULL)); | ||
330 | crc->phase++; | ||
331 | GNUNET_SCHEDULER_add_now (&test, crc); | ||
332 | break; | ||
333 | |||
334 | case RP_ITER_ZERO: | ||
335 | if (crc->cnt == 1) | ||
336 | { | ||
337 | crc->cnt = 0; | ||
338 | crc->phase++; | ||
339 | GNUNET_SCHEDULER_add_now (&test, crc); | ||
340 | break; | ||
341 | } | ||
342 | crc->api->iter_zero_anonymity (crc->api->cls, | ||
343 | 1, | ||
344 | &iterate_with_next, | ||
345 | crc); | ||
346 | break; | ||
347 | case RP_REPL_GET: | ||
310 | crc->api->replication_get (crc->api->cls, | 348 | crc->api->replication_get (crc->api->cls, |
311 | &dummy_get, | 349 | &iterate_one_shot, |
312 | crc); | 350 | crc); |
313 | break; | 351 | break; |
314 | case RP_AE_GET: | 352 | case RP_EXPI_GET: |
315 | crc->msg = "%3u expiration iteration took %20llums for %u\n"; | ||
316 | crc->api->expiration_get (crc->api->cls, | 353 | crc->api->expiration_get (crc->api->cls, |
317 | &dummy_get, | 354 | &iterate_one_shot, |
318 | crc); | 355 | crc); |
319 | break; | 356 | break; |
320 | case RP_ZA_GET: | 357 | case RP_DROP: |
321 | crc->msg = "%3u zero anonymity iteration took %20llums for %u\n"; | ||
322 | crc->api->iter_zero_anonymity (crc->api->cls, 0, | ||
323 | &iterateDummy, | ||
324 | crc); | ||
325 | break; | ||
326 | case RP_DONE: | ||
327 | crc->api->drop (crc->api->cls); | 358 | crc->api->drop (crc->api->cls); |
328 | GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, | 359 | GNUNET_SCHEDULER_add_now (&cleaning_task, crc); |
329 | &cleaning_task, crc); | ||
330 | break; | 360 | break; |
331 | } | 361 | } |
332 | } | 362 | } |
diff --git a/src/datastore/test_plugin_datastore_data_mysql.conf b/src/datastore/test_plugin_datastore_data_mysql.conf index d436ea53d..1e38bb0cf 100644 --- a/src/datastore/test_plugin_datastore_data_mysql.conf +++ b/src/datastore/test_plugin_datastore_data_mysql.conf | |||
@@ -1,5 +1,5 @@ | |||
1 | [PATHS] | 1 | [PATHS] |
2 | SERVICEHOME = /tmp/perf-gnunet-datastore-mysql/ | 2 | SERVICEHOME = /tmp/test-gnunet-datastore-plugin-mysql/ |
3 | 3 | ||
4 | [datastore] | 4 | [datastore] |
5 | PORT = 22654 | 5 | PORT = 22654 |
diff --git a/src/datastore/test_plugin_datastore_data_postgres.conf b/src/datastore/test_plugin_datastore_data_postgres.conf index c2a181bc7..1604165a9 100644 --- a/src/datastore/test_plugin_datastore_data_postgres.conf +++ b/src/datastore/test_plugin_datastore_data_postgres.conf | |||
@@ -1,5 +1,5 @@ | |||
1 | [PATHS] | 1 | [PATHS] |
2 | SERVICEHOME = /tmp/perf-gnunet-datastore-postgres/ | 2 | SERVICEHOME = /tmp/test-gnunet-datastore-plugin-postgres/ |
3 | 3 | ||
4 | [datastore] | 4 | [datastore] |
5 | PORT = 22654 | 5 | PORT = 22654 |
diff --git a/src/datastore/test_plugin_datastore_data_sqlite.conf b/src/datastore/test_plugin_datastore_data_sqlite.conf index 90cf9f103..5eb1d1341 100644 --- a/src/datastore/test_plugin_datastore_data_sqlite.conf +++ b/src/datastore/test_plugin_datastore_data_sqlite.conf | |||
@@ -1,5 +1,5 @@ | |||
1 | [PATHS] | 1 | [PATHS] |
2 | SERVICEHOME = /tmp/perf-gnunet-datastore-sqlite/ | 2 | SERVICEHOME = /tmp/test-gnunet-datastore-plugin-sqlite/ |
3 | 3 | ||
4 | [datastore] | 4 | [datastore] |
5 | PORT = 22654 | 5 | PORT = 22654 |