Home GnuPG
Diffusion GnuPG 64a5fd37271a

gpg: New caching functions.

Description

gpg: New caching functions.

* g10/objcache.c: New.
* g10/objcache.h: New.
* g10/Makefile.am (common_source): Add them.
* g10/gpg.c: Include objcache.h.
(g10_exit): Call objcache_dump_stats.
* g10/getkey.c: Include objcache.h.
(get_primary_uid, release_keyid_list): Remove.
(cache_user_id): Remove.
(finish_lookup): Call the new cache_put_keyblock instead of
cache_user_id.
(get_user_id_string): Remove code for mode 2.
(get_user_id): Implement using cache_get_uid_bykid.

This generic caching module is better than the ad-hoc code we used in
getkey.c. More cleanup in getkey is still required but it is a
start. There is also a small performance increase with the new cache:

With a large keyring and --list-sigs I get these numbers:

beforeafter
------+------------+------------
real14m1.028s12m16.186s
user2m18.484s1m36.040s
sys11m42.420s10m40.044s

Note the speedup in the user time which is due to the improved cache
algorithm. This is obvious, because the old cache was just a long
linked list; the new cache are two hash tables.

  • Signed-off-by: Werner Koch <wk@gnupg.org>

Details

Provenance
wernerAuthored on Apr 13 2019, 11:48 AM
Parents
rG60f384592144: gpg: Cache a once computed fingerprint in PKT_public_key.
Branches
Unknown
Tags
Unknown