diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-11-12 14:42:25 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-11-12 14:42:25 +0000 |
commit | bc9a331bbd28bb636dd868cf6f018cefcf0cb0a2 (patch) | |
tree | 9a321b783d470ded2f907c4e1bcfb9c564140c14 /src/datacache/datacache.c | |
parent | f397c283914604f4d526e7b9fc438c7ccc56bded (diff) | |
download | gnunet-bc9a331bbd28bb636dd868cf6f018cefcf0cb0a2.tar.gz gnunet-bc9a331bbd28bb636dd868cf6f018cefcf0cb0a2.zip |
add option to disable Bloom filter entirely (only for benchmarking)
Diffstat (limited to 'src/datacache/datacache.c')
-rw-r--r-- | src/datacache/datacache.c | 43 |
1 files changed, 20 insertions, 23 deletions
diff --git a/src/datacache/datacache.c b/src/datacache/datacache.c index 53f7cc864..cc04b84d4 100644 --- a/src/datacache/datacache.c +++ b/src/datacache/datacache.c | |||
@@ -156,27 +156,22 @@ GNUNET_DATACACHE_create (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
156 | ret = GNUNET_malloc (sizeof (struct GNUNET_DATACACHE_Handle)); | 156 | ret = GNUNET_malloc (sizeof (struct GNUNET_DATACACHE_Handle)); |
157 | 157 | ||
158 | if (GNUNET_YES != | 158 | if (GNUNET_YES != |
159 | GNUNET_CONFIGURATION_get_value_yesno (cfg, section, "DISABLE_BF_RC")) | 159 | GNUNET_CONFIGURATION_get_value_yesno (cfg, section, "DISABLE_BF")) |
160 | { | 160 | { |
161 | fprintf (stderr, "Using RC!\n"); | 161 | if (GNUNET_YES != |
162 | ret->bloom_name = GNUNET_DISK_mktemp ("gnunet-datacachebloom"); | 162 | GNUNET_CONFIGURATION_get_value_yesno (cfg, section, "DISABLE_BF_RC")) |
163 | } | 163 | { |
164 | if (NULL != ret->bloom_name) | 164 | ret->bloom_name = GNUNET_DISK_mktemp ("gnunet-datacachebloom"); |
165 | { | 165 | } |
166 | ret->filter = GNUNET_CONTAINER_bloomfilter_load (ret->bloom_name, quota / 1024, /* 8 bit per entry in DB, expect 1k entries */ | 166 | if (NULL != ret->bloom_name) |
167 | 5); | 167 | { |
168 | } | 168 | ret->filter = GNUNET_CONTAINER_bloomfilter_load (ret->bloom_name, quota / 1024, /* 8 bit per entry in DB, expect 1k entries */ |
169 | 169 | 5); | |
170 | if (NULL == ret->filter) | 170 | } |
171 | { | 171 | if (NULL == ret->filter) |
172 | ret->filter = GNUNET_CONTAINER_bloomfilter_init (NULL, bf_size, 5); /* approx. 3% false positives at max use */ | 172 | { |
173 | } | 173 | ret->filter = GNUNET_CONTAINER_bloomfilter_init (NULL, bf_size, 5); /* approx. 3% false positives at max use */ |
174 | if (NULL == ret->filter) | 174 | } |
175 | { | ||
176 | GNUNET_free (name); | ||
177 | GNUNET_free (ret->bloom_name); | ||
178 | GNUNET_free (ret); | ||
179 | return NULL; | ||
180 | } | 175 | } |
181 | ret->stats = GNUNET_STATISTICS_create ("datacache", cfg); | 176 | ret->stats = GNUNET_STATISTICS_create ("datacache", cfg); |
182 | ret->section = GNUNET_strdup (section); | 177 | ret->section = GNUNET_strdup (section); |
@@ -210,7 +205,7 @@ GNUNET_DATACACHE_create (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
210 | void | 205 | void |
211 | GNUNET_DATACACHE_destroy (struct GNUNET_DATACACHE_Handle *h) | 206 | GNUNET_DATACACHE_destroy (struct GNUNET_DATACACHE_Handle *h) |
212 | { | 207 | { |
213 | if (h->filter != NULL) | 208 | if (NULL != h->filter) |
214 | GNUNET_CONTAINER_bloomfilter_free (h->filter); | 209 | GNUNET_CONTAINER_bloomfilter_free (h->filter); |
215 | if (h->api != NULL) | 210 | if (h->api != NULL) |
216 | GNUNET_break (NULL == GNUNET_PLUGIN_unload (h->lib_name, h->api)); | 211 | GNUNET_break (NULL == GNUNET_PLUGIN_unload (h->lib_name, h->api)); |
@@ -260,7 +255,8 @@ GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h, | |||
260 | GNUNET_NO); | 255 | GNUNET_NO); |
261 | GNUNET_STATISTICS_update (h->stats, gettext_noop ("# items stored"), 1, | 256 | GNUNET_STATISTICS_update (h->stats, gettext_noop ("# items stored"), 1, |
262 | GNUNET_NO); | 257 | GNUNET_NO); |
263 | GNUNET_CONTAINER_bloomfilter_add (h->filter, key); | 258 | if (NULL != h->filter) |
259 | GNUNET_CONTAINER_bloomfilter_add (h->filter, key); | ||
264 | while (h->utilization + used > h->env.quota) | 260 | while (h->utilization + used > h->env.quota) |
265 | GNUNET_assert (GNUNET_OK == h->api->del (h->api->cls)); | 261 | GNUNET_assert (GNUNET_OK == h->api->del (h->api->cls)); |
266 | h->utilization += used; | 262 | h->utilization += used; |
@@ -288,7 +284,8 @@ GNUNET_DATACACHE_get (struct GNUNET_DATACACHE_Handle *h, | |||
288 | GNUNET_NO); | 284 | GNUNET_NO); |
289 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing request for key `%s'\n", | 285 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing request for key `%s'\n", |
290 | GNUNET_h2s (key)); | 286 | GNUNET_h2s (key)); |
291 | if (GNUNET_OK != GNUNET_CONTAINER_bloomfilter_test (h->filter, key)) | 287 | if ( (NULL != h->filter) && |
288 | (GNUNET_OK != GNUNET_CONTAINER_bloomfilter_test (h->filter, key)) ) | ||
292 | { | 289 | { |
293 | GNUNET_STATISTICS_update (h->stats, | 290 | GNUNET_STATISTICS_update (h->stats, |
294 | gettext_noop | 291 | gettext_noop |