]> git.ipfire.org Git - thirdparty/bind9.git/commit
Use thread_local EVP_MD_CTX in isc_iterated_hash()
authorOndřej Surý <ondrej@isc.org>
Mon, 16 Jan 2023 10:12:06 +0000 (11:12 +0100)
committerOndřej Surý <ondrej@isc.org>
Wed, 18 Jan 2023 18:36:21 +0000 (19:36 +0100)
commitf3753d591fbc5057997e08eaf0b41c91ef466b2c
treeeb6084e058957d7f84d5af896da6d94f7089b52e
parent25db8d010337b8f62705b44a7f01aa4658ce1c6f
Use thread_local EVP_MD_CTX in isc_iterated_hash()

As this code is on hot path (NSEC3) this introduces an additional
optimization of the EVP_MD API - instead of calling EVP_MD_CTX_new() on
every call to isc_iterated_hash(), we create two thread_local objects
for each thread - a basectx and mdctx, initialize basectx once and then
use EVP_MD_CTX_copy_ex() to flip the initialized state into mdctx.  This
saves us couple more valuable microseconds from the isc_iterated_hash()
call.
lib/isc/include/isc/iterated_hash.h
lib/isc/iterated_hash.c
lib/isc/lib.c
lib/isc/trampoline.c