Skip to content

Implement incremental hash table resizing in isc_ht

Previously, an incremental hash table resizing was implemented for the dns_rbt_t hash table implementation. Using that as a base, also implement the incremental hash table resizing also for isc_ht API hashtables:

  1. During the resize, allocate the new hash table, but keep the old table unchanged.
  2. In each lookup, delete, or iterator operation, check both tables.
  3. Perform insertion operations only in the new table.
  4. At each insertion also move elements from the old table to the new table.
  5. When all elements are removed from the old table, deallocate it.

To ensure that the old table is completely copied over before the new table itself needs to be enlarged, it is necessary to increase the size of the table by a factor of at least ( + 1)/ during resizing.

In our implementation is equal to 1.

The downside of this approach is that the old table and the new table could stay in memory for longer when there are no new insertions into the hash table for prolonged periods of time as the incremental rehashing happens only during the insertions.

Closes #3212 (closed)

Edited by Ondřej Surý

Merge request reports