[PATCH 5/5][_Hahtable] Prealloc nodes on copy

François Dumont frs.dumont@gmail.com
Mon Jun 20 16:58:31 GMT 2022


libstdc++: [_Hashtable] Prealloc nodes on _Hashtable copy

Prealloc nodes on copy to reduce memory fragmentation of nodes. Create a new
assignment method which copy hashtable instances respecting order of 
nodes in the
bucket rather than order of node in the singly-linked list.

libstdc++-v3/ChangeLog:

     * include/bits/hashtable_policy.h: Include stl_tempbuf.h.
     (_Hashtable_alloc<>::_M_allocate_node_ptr): New.
     (_PreAllocHashtableNodes<>): New.
     * include/bits/hashtable.h 
(_Hashtable<>::__prealloc_hashtable_nodes_gen_t): New.
     (_Hashtable<>::_M_assign_stable):New.
     (_Hashtable<>::operator=(const _Hashtable&)): Use latter.
     (_Hashtable(const _Hashtable&)): Likewise.
     (_Hashtable(const _Hashtable&, const allocator_type&)): Likewise.
     (_Hashtable(_Hashtable&&, __node_alloc_type&&, false_type)): Likewise.
     * testsuite/util/exception/safety.h (setup_base::compare): Compare 
containers
     rather than compare iterators.
     * testsuite/23_containers/unordered_multiset/cons/copy.cc (main): 
Likewise.

Tested under Linux x86_64.

François
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 5_hashtable_prealloc_nodes.patch
Type: text/x-patch
Size: 11253 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20220620/22282b08/attachment.bin>


More information about the Libstdc++ mailing list