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) | |
download | gnunet-303334e67262bb6121dfbd245c66535f259d08af.tar.gz gnunet-303334e67262bb6121dfbd245c66535f259d08af.zip |
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 f8ac6c31c..c5a37dcac 100644 --- a/src/namestore/gnunet-service-namestore.c +++ b/src/namestore/gnunet-service-namestore.c | |||
@@ -251,6 +251,12 @@ static struct ZoneMonitor *monitor_tail; | |||
251 | */ | 251 | */ |
252 | static struct GNUNET_NotificationContext *monitor_nc; | 252 | static struct GNUNET_NotificationContext *monitor_nc; |
253 | 253 | ||
254 | /** | ||
255 | * Optimize block insertion by caching map of private keys to | ||
256 | * public keys in memory? | ||
257 | */ | ||
258 | static int cache_keys; | ||
259 | |||
254 | 260 | ||
255 | /** | 261 | /** |
256 | * Task run during shutdown. | 262 | * Task run during shutdown. |
@@ -707,11 +713,18 @@ refresh_block (struct NamestoreClient *nc, | |||
707 | ? GNUNET_TIME_UNIT_ZERO_ABS | 713 | ? GNUNET_TIME_UNIT_ZERO_ABS |
708 | : GNUNET_GNSRECORD_record_get_expiration_time (res_count, | 714 | : GNUNET_GNSRECORD_record_get_expiration_time (res_count, |
709 | res); | 715 | res); |
710 | block = GNUNET_GNSRECORD_block_create (zone_key, | 716 | if (cache_keys) |
711 | exp_time, | 717 | block = GNUNET_GNSRECORD_block_create2 (zone_key, |
712 | name, | 718 | exp_time, |
713 | res, | 719 | name, |
714 | res_count); | 720 | res, |
721 | res_count); | ||
722 | else | ||
723 | block = GNUNET_GNSRECORD_block_create (zone_key, | ||
724 | exp_time, | ||
725 | name, | ||
726 | res, | ||
727 | res_count); | ||
715 | GNUNET_assert (NULL != block); | 728 | GNUNET_assert (NULL != block); |
716 | GNUNET_CRYPTO_ecdsa_key_get_public (zone_key, | 729 | GNUNET_CRYPTO_ecdsa_key_get_public (zone_key, |
717 | &pkey); | 730 | &pkey); |
@@ -1722,6 +1735,9 @@ run (void *cls, | |||
1722 | monitor_nc = GNUNET_notification_context_create (1); | 1735 | monitor_nc = GNUNET_notification_context_create (1); |
1723 | namecache = GNUNET_NAMECACHE_connect (cfg); | 1736 | namecache = GNUNET_NAMECACHE_connect (cfg); |
1724 | /* Loading database plugin */ | 1737 | /* Loading database plugin */ |
1738 | cache_keys = GNUNET_CONFIGURATION_get_value_yesno (cfg, | ||
1739 | "namestore", | ||
1740 | "CACHE_KEYS"); | ||
1725 | if (GNUNET_OK != | 1741 | if (GNUNET_OK != |
1726 | GNUNET_CONFIGURATION_get_value_string (cfg, | 1742 | GNUNET_CONFIGURATION_get_value_string (cfg, |
1727 | "namestore", | 1743 | "namestore", |
diff --git a/src/namestore/namestore.conf.in b/src/namestore/namestore.conf.in index f19ac5643..8b5e440b8 100644 --- a/src/namestore/namestore.conf.in +++ b/src/namestore/namestore.conf.in | |||
@@ -9,8 +9,17 @@ HOSTNAME = localhost | |||
9 | BINARY = gnunet-service-namestore | 9 | BINARY = gnunet-service-namestore |
10 | ACCEPT_FROM = 127.0.0.1; | 10 | ACCEPT_FROM = 127.0.0.1; |
11 | ACCEPT_FROM6 = ::1; | 11 | ACCEPT_FROM6 = ::1; |
12 | |||
13 | # Which database should we use? | ||
12 | DATABASE = sqlite | 14 | DATABASE = sqlite |
13 | 15 | ||
16 | # Should we optimize publishing record by caching the mapping | ||
17 | # from zone private keys to zone public keys in memory? | ||
18 | # (Set to NO if totally paranoid about keeping private keys | ||
19 | # in RAM longer than necessary.) | ||
20 | CACHE_KEYS = YES | ||
21 | |||
22 | |||
14 | [namestore-sqlite] | 23 | [namestore-sqlite] |
15 | FILENAME = $GNUNET_DATA_HOME/namestore/sqlite.db | 24 | FILENAME = $GNUNET_DATA_HOME/namestore/sqlite.db |
16 | 25 | ||
@@ -38,5 +47,3 @@ UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-fcfsd.sock | |||
38 | 47 | ||
39 | # On what port does the FCFS daemon listen for HTTP clients? | 48 | # On what port does the FCFS daemon listen for HTTP clients? |
40 | HTTPPORT = 18080 | 49 | HTTPPORT = 18080 |
41 | |||
42 | |||