aboutsummaryrefslogtreecommitdiff
path: root/src/datastore
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2009-07-17 12:59:05 +0000
committerChristian Grothoff <christian@grothoff.org>2009-07-17 12:59:05 +0000
commitee070fe6f1caa8fbf81d770c8685939a91b2cbc5 (patch)
treeec72b322782b986ad4c5d6220ced08476fba9ec4 /src/datastore
parent8146ad014b181ea88150d67a9780eea2103ae446 (diff)
downloadgnunet-ee070fe6f1caa8fbf81d770c8685939a91b2cbc5.tar.gz
gnunet-ee070fe6f1caa8fbf81d770c8685939a91b2cbc5.zip
sthuff
Diffstat (limited to 'src/datastore')
-rw-r--r--src/datastore/perf_datastore_api.c128
1 files changed, 82 insertions, 46 deletions
diff --git a/src/datastore/perf_datastore_api.c b/src/datastore/perf_datastore_api.c
index 4d84d88bd..3d4f45806 100644
--- a/src/datastore/perf_datastore_api.c
+++ b/src/datastore/perf_datastore_api.c
@@ -111,36 +111,12 @@ static struct GNUNET_TIME_Absolute start_time;
111 111
112static int ok; 112static int ok;
113 113
114static int
115putValue (int i, int k)
116{
117
118 return GNUNET_OK;
119}
120
121
122static void
123iterate_delete (void *cls,
124 const GNUNET_HashCode * key,
125 uint32_t size,
126 const void *data,
127 uint32_t type,
128 uint32_t priority,
129 uint32_t anonymity,
130 struct GNUNET_TIME_Absolute
131 expiration, uint64_t uid)
132{
133 GNUNET_DATASTORE_remove (datastore, key, size, data, NULL, NULL);
134}
135
136
137enum RunPhase 114enum RunPhase
138 { 115 {
139 RP_DONE = 0, 116 RP_DONE = 0,
140 RP_PUT, 117 RP_PUT,
141 RP_CUT, 118 RP_CUT,
142 RP_REPORT, 119 RP_REPORT
143 RP_END
144 }; 120 };
145 121
146 122
@@ -152,10 +128,6 @@ struct CpsRunContext
152 int j; 128 int j;
153 unsigned long long size; 129 unsigned long long size;
154 int i; 130 int i;
155
156
157 GNUNET_HashCode key;
158 int *iptr;
159}; 131};
160 132
161 133
@@ -172,6 +144,8 @@ check_success (void *cls,
172 int success, 144 int success,
173 const char *msg) 145 const char *msg)
174{ 146{
147 static int ic;
148
175 struct CpsRunContext *crc = cls; 149 struct CpsRunContext *crc = cls;
176 if (GNUNET_OK != success) 150 if (GNUNET_OK != success)
177 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 151 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -182,9 +156,19 @@ check_success (void *cls,
182 if (ic % REP_FREQ == 0) 156 if (ic % REP_FREQ == 0)
183 fprintf (stderr, "I"); 157 fprintf (stderr, "I");
184#endif 158#endif
185 stored_bytes += size; 159 stored_bytes += crc->size;
186 stored_ops++; 160 stored_ops++;
187 stored_entries++; 161 stored_entries++;
162 crc->j++;
163 if (crc->j == PUT_10)
164 {
165 crc->j = 0;
166 crc->i++;
167 if (crc->i == ITERATIONS)
168 crc->phase = RP_DONE;
169 else
170 crc->phase = RP_CUT;
171 }
188 GNUNET_SCHEDULER_add_continuation (crc->sched, 172 GNUNET_SCHEDULER_add_continuation (crc->sched,
189 GNUNET_NO, 173 GNUNET_NO,
190 &run_continuation, 174 &run_continuation,
@@ -192,6 +176,61 @@ check_success (void *cls,
192 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 176 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
193} 177}
194 178
179
180/**
181 * Continuation called to notify client about result of the
182 * operation.
183 *
184 * @param cls closure
185 * @param success GNUNET_SYSERR on failure
186 * @param msg NULL on success, otherwise an error message
187 */
188static void
189remove_next(void *cls,
190 int success,
191 const char *msg)
192{
193 GNUNET_assert (GNUNET_OK == success);
194}
195
196
197static void
198delete_value (void *cls,
199 const GNUNET_HashCode * key,
200 uint32_t size,
201 const void *data,
202 uint32_t type,
203 uint32_t priority,
204 uint32_t anonymity,
205 struct GNUNET_TIME_Absolute
206 expiration, uint64_t uid)
207{
208 struct CpsRunContext *crc = cls;
209
210 /* FIXME: should probably abort deletion iteration
211 earlier (to not delete everything...) */
212 if (key == NULL)
213 {
214 crc->phase = RP_REPORT;
215 /* FIXME: should wait for all "remove_next" calls
216 to complete before going back to the run_continuation */
217 GNUNET_SCHEDULER_add_continuation (crc->sched,
218 GNUNET_NO,
219 &run_continuation,
220 crc,
221 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
222 return;
223 }
224 GNUNET_DATASTORE_remove (datastore,
225 key,
226 size,
227 data,
228 &remove_next,
229 crc);
230}
231
232
233
195static void 234static void
196run_continuation (void *cls, 235run_continuation (void *cls,
197 const struct GNUNET_SCHEDULER_TaskContext *tc) 236 const struct GNUNET_SCHEDULER_TaskContext *tc)
@@ -199,7 +238,6 @@ run_continuation (void *cls,
199 struct CpsRunContext *crc = cls; 238 struct CpsRunContext *crc = cls;
200 size_t size; 239 size_t size;
201 static GNUNET_HashCode key; 240 static GNUNET_HashCode key;
202 static int ic;
203 static char data[65536]; 241 static char data[65536];
204 int i; 242 int i;
205 int k; 243 int k;
@@ -208,14 +246,14 @@ run_continuation (void *cls,
208 switch (crc->phase) 246 switch (crc->phase)
209 { 247 {
210 case RP_PUT: 248 case RP_PUT:
211 memset (&crc->key, 256 - crc->i, sizeof (GNUNET_HashCode)); 249 memset (&key, 256 - crc->i, sizeof (GNUNET_HashCode));
212 i = crc->j; 250 i = crc->j;
213 k = crc->i; 251 k = crc->i;
214 /* most content is 32k */ 252 /* most content is 32k */
215 size = 32 * 1024; 253 size = 32 * 1024;
216 if (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 16) == 0) /* but some of it is less! */ 254 if (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 16) == 0) /* but some of it is less! */
217 size = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 32 * 1024); 255 size = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 32 * 1024);
218 size = size - (size & 7); /* always multiple of 8 */ 256 crc->size = size = size - (size & 7); /* always multiple of 8 */
219 GNUNET_CRYPTO_hash (&key, sizeof (GNUNET_HashCode), &key); 257 GNUNET_CRYPTO_hash (&key, sizeof (GNUNET_HashCode), &key);
220 memset (data, i, size); 258 memset (data, i, size);
221 if (i > 255) 259 if (i > 255)
@@ -235,23 +273,22 @@ run_continuation (void *cls,
235 TIMEOUT, 273 TIMEOUT,
236 &check_success, 274 &check_success,
237 crc); 275 crc);
238 crc->j++;
239 if (crc->j < PUT_10)
240 break;
241 crc->j = 0;
242 crc->i++;
243 if (crc->i == ITERATIONS)
244 crc->phase = RP_DONE;
245 else
246 crc->phase = RP_CUT;
247 break; 276 break;
248 case RP_CUT: 277 case RP_CUT:
249 /* trim down below MAX_SIZE again */ 278 /* trim down below MAX_SIZE again */
250 if ((i % 2) == 0) 279 if ((i % 2) == 0)
251 GNUNET_DATASTORE_get_random (datastore, 280 {
252 &iterate_delete, 281 GNUNET_DATASTORE_get_random (datastore,
253 NULL); 282 &delete_value,
283 crc);
284 break;
285 }
254 crc->phase = RP_REPORT; 286 crc->phase = RP_REPORT;
287 GNUNET_SCHEDULER_add_continuation (crc->sched,
288 GNUNET_NO,
289 &run_continuation,
290 crc,
291 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
255 break; 292 break;
256 case RP_REPORT: 293 case RP_REPORT:
257 size = 0; 294 size = 0;
@@ -264,7 +301,6 @@ run_continuation (void *cls,
264 (stored_ops * 2 - stored_entries) / 1024, /* total operations (in k) */ 301 (stored_ops * 2 - stored_entries) / 1024, /* total operations (in k) */
265 1000 * (stored_ops * 2 - stored_entries) / (1 + GNUNET_TIME_absolute_get_duration(start_time).value)); /* operations per second */ 302 1000 * (stored_ops * 2 - stored_entries) / (1 + GNUNET_TIME_absolute_get_duration(start_time).value)); /* operations per second */
266 crc->phase = RP_PUT; 303 crc->phase = RP_PUT;
267 // fixme: trigger next round...
268 GNUNET_SCHEDULER_add_continuation (crc->sched, 304 GNUNET_SCHEDULER_add_continuation (crc->sched,
269 GNUNET_NO, 305 GNUNET_NO,
270 &run_continuation, 306 &run_continuation,