strongswan/src/libstrongswan/tests/suites
Tobias Brunner 45376040ce hashtable: Maintain insertion order when enumerating
With the previous approach we'd require at least an additional pointer
per item to store them in a list (15-18% increase in the overhead per
item).  Instead we switch from handling collisions with overflow lists to
an open addressing scheme and store the actual table as variable-sized
indices pointing into an array of all inserted items in their original
order.

This can reduce the memory overhead even compared to the previous
implementation (especially for smaller tables), but because the array for
items is preallocated whenever the table is resized, it can be worse for
certain numbers of items.  However, avoiding all the allocations required
by the previous design is actually a big advantage.

Depending on the usage pattern, the performance can improve quite a bit (in
particular when inserting many items).  The raw lookup performance is a bit
slower as probing lengths increase with open addressing, but there are some
caching benefits due to the compact storage.  So for general usage the
performance should be better.  For instance, one test I did was counting the
occurrences of words in a list of 1'000'000 randomly selected words from a
dictionary of ~58'000 words (i.e. using a counter stored under each word as
key).  The new implementation was ~8% faster on average while requiring
10% less memory.

Since we can't remove items from the array (would change the indices of all
items that follow it) we just mark them as removed and remove them once the
hash table is resized/rehashed (the cells in the hash table for these may
be reused).  Due to this the latter may also happen if the number of stored
items does not increase e.g. after a series of remove/put operations (each
insertion requires storage in the array, no matter if items were removed).
So if the capacity is exhausted, the table is resized/rehashed (after lots
of removals the size may even be reduced) and all items marked as removed
are simply skipped.

Compared to the previous implementation the load factor/capacity is
lowered to reduce chances of collisions and to avoid primary clustering to
some degree.  However, the latter in particular, but the open addressing
scheme in general, make this implementation completely unsuited for the
get_match() functionality (purposefully hashing to the same value and,
therefore, increasing the probing length and clustering).  And keeping the
keys optionally sorted would complicate the code significantly.  So we just
keep the existing hashlist_t implementation without adding code to maintain
the overall insertion order (we could add that feature optionally later, but
with the mentioned overhead for one or two pointers).

The maximum size is currently not changed.  With the new implementation
this translates to a hard limit for the maximum number of items that can be
held in the table (=CAPACITY(MAX_SIZE)).  Since this equals 715'827'882
items with the current settings, this shouldn't be a problem in practice,
the table alone would require 20 GiB in memory for that many items.  The
hashlist_t implementation doesn't have that limitation due to the overflow
lists (it can store beyond it's capacity) but it itself would require over
29 GiB of memory to hold that many items.
2020-07-20 13:50:11 +02:00
..
test_array.c Unify format of HSR copyright statements 2018-05-23 16:32:53 +02:00
test_asn1.c asn1: Add function to generate an ASN.1 integer from an uint64_t 2017-11-08 16:48:10 +01:00
test_asn1_parser.c Some whitespace fixes 2019-08-22 15:18:06 +02:00
test_auth_cfg.c Spelling fixes 2020-02-11 18:23:07 +01:00
test_bio_reader.c Unify format of HSR copyright statements 2018-05-23 16:32:53 +02:00
test_bio_writer.c Unify format of HSR copyright statements 2018-05-23 16:32:53 +02:00
test_certnames.c constraints: Add permitted/excludedNameConstraints check 2014-10-30 11:40:48 +01:00
test_certpolicy.c constraints: Add requireExplicitPolicy tests 2014-10-30 11:40:47 +01:00
test_chunk.c chunk: Add helper to copy a chunk left-padded to a certain length 2019-04-24 11:40:14 +02:00
test_crypter.c Some whitespace fixes 2019-08-22 15:18:06 +02:00
test_crypto_factory.c Unify format of HSR copyright statements 2018-05-23 16:32:53 +02:00
test_ecdsa.c Fixed some typos, courtesy of codespell 2019-12-12 11:09:06 +01:00
test_ed448.c wolfssl: Add support for Ed448 2020-05-07 09:33:43 +02:00
test_ed25519.c wolfssl: Add wolfSSL plugin for cryptographic implementations 2019-04-24 11:40:14 +02:00
test_enum.c enum: Add compile-time check for missing strings 2019-10-28 14:26:32 +01:00
test_enumerator.c Unify format of HSR copyright statements 2018-05-23 16:32:53 +02:00
test_fetch_http.c soup: Use soup_session_new() to avoid deprecation warning 2020-02-05 10:49:35 +01:00
test_hasher.c auth-cfg: Store signature schemes as signature_params_t objects 2017-11-08 16:48:10 +01:00
test_hashtable.c hashtable: Maintain insertion order when enumerating 2020-07-20 13:50:11 +02:00
test_host.c Unify format of HSR copyright statements 2018-05-23 16:32:53 +02:00
test_identification.c identification: Optionally match RDNs in any order and accept missing RDNs 2019-08-26 11:15:53 +02:00
test_iv_gen.c Unify format of HSR copyright statements 2018-05-23 16:32:53 +02:00
test_linked_list.c Unify format of HSR copyright statements 2018-05-23 16:32:53 +02:00
test_linked_list_enumerator.c linked-list: Order of insert_before/remove_at calls doesn't matter anymore 2018-06-26 15:11:02 +02:00
test_mgf1.c drbg: Implemented NIST SP-800-90A DRBG 2019-10-16 16:46:24 +02:00
test_ntru.c drbg: The drbg instance owns the entropy rng 2019-11-28 09:55:56 +01:00
test_pen.c unit-tests: Move test suites to its own subfolder 2013-11-06 10:30:58 +01:00
test_prf_plus.c prf-plus: Fail after counter has wrapped around 2019-10-21 13:53:11 +02:00
test_printf.c Fixed some typos, courtesy of codespell 2018-09-17 18:51:44 +02:00
test_process.c process: Don't use the shells built-in echo in tests 2014-10-14 16:33:10 +02:00
test_proposal.c proposal: Add selection flags to clone() method 2019-10-24 17:43:21 +02:00
test_rng_tester.c drbg: Implemented NIST SP-800-90A DRBG 2019-10-16 16:46:24 +02:00
test_rsa.c Fixed some typos, courtesy of codespell 2019-12-12 11:09:06 +01:00
test_settings.c settings: Don't allow dots in section/key names anymore 2018-09-11 18:30:18 +02:00
test_signature_params.c signature-params: Provide option for maximum RSA/PSS salt length 2018-10-26 09:03:26 +02:00
test_stream.c unit-tests: Don't test Unix socket stream/services on Windows 2014-06-04 15:53:00 +02:00
test_threading.c Spelling fixes 2020-02-11 18:23:07 +01:00
test_traffic_selector.c Unify format of HSR copyright statements 2018-05-23 16:32:53 +02:00
test_utils.c Spelling fixes 2020-02-11 18:23:07 +01:00
test_vectors.c unit-tests: Increase timeout for test vectors suite 2020-02-13 16:42:13 +01:00
test_watcher.c windows: Provide a sched_yield() implementation 2014-06-04 15:53:01 +02:00