diff options
author | Christian Grothoff <christian@grothoff.org> | 2018-04-25 16:41:22 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2018-04-25 16:41:22 +0200 |
commit | 303334e67262bb6121dfbd245c66535f259d08af (patch) | |
tree | 1a92109915ffe63b7e2815edc6a6355f4065a48c /src/namestore | |
parent | 3c62493eb1aaa74812bbb79431686d99652417f4 (diff) |
enable caching private->public key mapping in memory to improve CPU consumption for large zone insertions
Diffstat (limited to 'src/namestore')
-rw-r--r-- | src/namestore/gnunet-service-namestore.c | 26 | ||||
-rw-r--r-- | src/namestore/namestore.conf.in | 11 |
2 files changed, 30 insertions, 7 deletions
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c index f8ac6c31c9..c5a37dcac3 100644 --- a/src/namestore/gnunet-service-namestore.c +++ b/src/namestore/gnunet-service-namestore.c @@ -251,6 +251,12 @@ static struct ZoneMonitor *monitor_tail; */ static struct GNUNET_NotificationContext *monitor_nc; +/** + * Optimize block insertion by caching map of private keys to + * public keys in memory? + */ +static int cache_keys; + /** * Task run during shutdown. @@ -707,11 +713,18 @@ refresh_block (struct NamestoreClient *nc, ? GNUNET_TIME_UNIT_ZERO_ABS : GNUNET_GNSRECORD_record_get_expiration_time (res_count, res); - block = GNUNET_GNSRECORD_block_create (zone_key, - exp_time, - name, - res, - res_count); + if (cache_keys) + block = GNUNET_GNSRECORD_block_create2 (zone_key, + exp_time, + name, + res, + res_count); + else + block = GNUNET_GNSRECORD_block_create (zone_key, + exp_time, + name, + res, + res_count); GNUNET_assert (NULL != block); GNUNET_CRYPTO_ecdsa_key_get_public (zone_key, &pkey); @@ -1722,6 +1735,9 @@ run (void *cls, monitor_nc = GNUNET_notification_context_create (1); namecache = GNUNET_NAMECACHE_connect (cfg); /* Loading database plugin */ + cache_keys = GNUNET_CONFIGURATION_get_value_yesno (cfg, + "namestore", + "CACHE_KEYS"); if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, "namestore", diff --git a/src/namestore/namestore.conf.in b/src/namestore/namestore.conf.in index f19ac56439..8b5e440b87 100644 --- a/src/namestore/namestore.conf.in +++ b/src/namestore/namestore.conf.in @@ -9,8 +9,17 @@ HOSTNAME = localhost BINARY = gnunet-service-namestore ACCEPT_FROM = 127.0.0.1; ACCEPT_FROM6 = ::1; + +# Which database should we use? DATABASE = sqlite +# Should we optimize publishing record by caching the mapping +# from zone private keys to zone public keys in memory? +# (Set to NO if totally paranoid about keeping private keys +# in RAM longer than necessary.) +CACHE_KEYS = YES + + [namestore-sqlite] FILENAME = $GNUNET_DATA_HOME/namestore/sqlite.db @@ -38,5 +47,3 @@ UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-fcfsd.sock # On what port does the FCFS daemon listen for HTTP clients? HTTPPORT = 18080 - - |