diff options
author | Neil Horman <nhorman@openssl.org> | 2024-01-28 10:50:38 -0500 |
---|---|---|
committer | Pauli <ppzgs1@gmail.com> | 2024-04-24 12:03:30 +1000 |
commit | cc4ea5e00028e8e0fe3acbf5027497c077f84446 (patch) | |
tree | 8230073fa847312b71b0537acd8fffa7e063f660 /util | |
parent | 7e45ac6891ade57cb0141402745d144c4ce342cb (diff) |
Introduce new internal hashtable implementation
Create a new hashtable that is more efficient than the existing LHASH_OF
implementation. the new ossl_ht api offers several new features that
improve performance opportunistically
* A more generalized hash function. Currently using fnv1a, provides a
more general hash function, but can still be overridden where needed
* Improved locking and reference counting. This hash table is
internally locked with an RCU lock, and optionally reference counts
elements, allowing for users to not have to create and manage their
own read/write locks
* Lockless operation. The hash table can be configured to operate
locklessly on the read side, improving performance, at the sacrifice
of the ability to grow the hash table or delete elements from it
* A filter function allowing for the retrieval of several elements at a
time matching a given criteria without having to hold a lock
permanently
* a doall_until iterator variant, that allows callers which need to
iterate over the entire hash table until a given condition is met (as
defined by the return value of the iterator callback). This allows
for callers attempting to do expensive cache searches for a small
number of elements to terminate the iteration early, saving cpu cycles
* Dynamic type safety. The hash table provides operations to set and
get data of a specific type without having to define a type at the
instatiation point
* Multiple data type storage. The hash table can store multiple data
types allowing for more flexible usage
* Ubsan safety. Because the API deals with concrete single types
(HT_KEY and HT_VALUE), leaving specific type casting to the call
recipient with dynamic type validation, this implementation is safe
from the ubsan undefined behavior warnings that require additional
thunking on callbacks.
Testing of this new hashtable with an equivalent hash function, I can
observe approximately a 6% performance improvement in the lhash_test
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23671)
Diffstat (limited to 'util')
-rw-r--r-- | util/libcrypto.num | 1 | ||||
-rw-r--r-- | util/other.syms | 1 | ||||
-rw-r--r-- | util/platform_symbols/unix-symbols.txt | 2 |
3 files changed, 4 insertions, 0 deletions
diff --git a/util/libcrypto.num b/util/libcrypto.num index 0c83e9598e..ec20d5490e 100644 --- a/util/libcrypto.num +++ b/util/libcrypto.num @@ -5549,3 +5549,4 @@ OPENSSL_LH_set_thunks 5676 3_3_0 EXIST::FUNCTION: OPENSSL_LH_doall_arg_thunk 5677 3_3_0 EXIST::FUNCTION: OSSL_HTTP_REQ_CTX_set_max_response_hdr_lines 5678 3_3_0 EXIST::FUNCTION:HTTP CRYPTO_atomic_store ? 3_4_0 EXIST::FUNCTION: +CRYPTO_aligned_alloc ? 3_4_0 EXIST::FUNCTION: diff --git a/util/other.syms b/util/other.syms index 84e6bb6ba3..4793ca357f 100644 --- a/util/other.syms +++ b/util/other.syms @@ -416,6 +416,7 @@ OPENSSL_clear_free define OPENSSL_clear_realloc define OPENSSL_free define OPENSSL_malloc define +OPENSSL_aligned_alloc define OPENSSL_malloc_init define OPENSSL_mem_debug_pop define deprecated 3.0.0 OPENSSL_mem_debug_push define deprecated 3.0.0 diff --git a/util/platform_symbols/unix-symbols.txt b/util/platform_symbols/unix-symbols.txt index 2b2fe53672..20f1a78ad9 100644 --- a/util/platform_symbols/unix-symbols.txt +++ b/util/platform_symbols/unix-symbols.txt @@ -1,5 +1,6 @@ abort accept +aligned_alloc bcmp bind calloc @@ -78,6 +79,7 @@ munmap opendir openlog poll +posix_memalign pthread_attr_destroy pthread_attr_init pthread_attr_setdetachstate |