cxx/test/containers/unord/unord.multimap
Howard Hinnant 7a44515588 This commit establishes a new bucket_count policy in the unordered containers: The policy now allows a power-of-2 number of buckets to be requested (and that request honored) by the client. And if the number of buckets is set to a power of 2, then the constraint of the hash to the number of buckets uses & instead of %. If the client does not specify a number of buckets, then the policy remains unchanged: a prime number of buckets is selected. The growth policy is that the number of buckets is roughly doubled when needed. While growing, either the prime, or the power-of-2 strategy will be preserved. There is a small run time cost for putting in this switch. For very cheap hash functions, e.g. identity for int, the cost can be as high as 18%. However with more typical use cases, e.g. strings, the cost is in the noise level. I've measured cases with very cheap hash functions (int) that using a power-of-2 number of buckets can make look up about twice as fast. However I've also noted that a power-of-2 number of buckets is more susceptible to accidental catastrophic collisions. Though I've also noted that accidental catastrophic collisions are also possible when using a prime number of buckets (but seems far less likely). In short, this patch adds an extra tuning knob for those clients trying to get the last bit of performance squeezed out of their hash containers. Casual users of the hash containers will not notice the introduction of this tuning knob. Those clients who swear by power-of-2 hash containers can now opt-in to that strategy. Clients who prefer a prime number of buckets can continue as they have.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@159836 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-06 17:31:14 +00:00
..
unord.multimap.cnstr unord test fixes by Edward Meewis 2011-12-02 21:23:14 +00:00
unord.multimap.modifiers The rules for emplace in map, multimap, unordered_map and unordered_multimap changed a while back and I'm just now updating to these new rules. In a nutshell, you've got to know you're emplacing to a pair and use one of pair's constructors. I made one extension: If you want to emplace the key and default construct the mapped_type, you can just emplace(key), as opposed to emplace(piecewise_construct, forward_as_tuple(key), forward_as_tuple()). 2012-05-25 22:04:21 +00:00
unord.multimap.swap noexcept for <unordered_map>. 2011-06-04 18:54:24 +00:00
bucket_count.pass.cpp license change 2010-11-16 22:09:02 +00:00
bucket_size.pass.cpp license change 2010-11-16 22:09:02 +00:00
bucket.pass.cpp license change 2010-11-16 22:09:02 +00:00
count.pass.cpp license change 2010-11-16 22:09:02 +00:00
eq.pass.cpp license change 2010-11-16 22:09:02 +00:00
equal_range_const.pass.cpp license change 2010-11-16 22:09:02 +00:00
equal_range_non_const.pass.cpp license change 2010-11-16 22:09:02 +00:00
find_const.pass.cpp license change 2010-11-16 22:09:02 +00:00
find_non_const.pass.cpp license change 2010-11-16 22:09:02 +00:00
iterators.fail.cpp license change 2010-11-16 22:09:02 +00:00
iterators.pass.cpp Bug 9096 - list::iterator not default constructible 2011-01-28 23:46:28 +00:00
load_factor.pass.cpp unord test fixes by Edward Meewis 2011-12-02 21:23:14 +00:00
local_iterators.fail.cpp license change 2010-11-16 22:09:02 +00:00
local_iterators.pass.cpp license change 2010-11-16 22:09:02 +00:00
max_bucket_count.pass.cpp license change 2010-11-16 22:09:02 +00:00
max_load_factor.pass.cpp license change 2010-11-16 22:09:02 +00:00
max_size.pass.cpp license change 2010-11-16 22:09:02 +00:00
rehash.pass.cpp unord test fixes by Edward Meewis 2011-12-02 21:23:14 +00:00
reserve.pass.cpp This commit establishes a new bucket_count policy in the unordered containers: The policy now allows a power-of-2 number of buckets to be requested (and that request honored) by the client. And if the number of buckets is set to a power of 2, then the constraint of the hash to the number of buckets uses & instead of %. If the client does not specify a number of buckets, then the policy remains unchanged: a prime number of buckets is selected. The growth policy is that the number of buckets is roughly doubled when needed. While growing, either the prime, or the power-of-2 strategy will be preserved. There is a small run time cost for putting in this switch. For very cheap hash functions, e.g. identity for int, the cost can be as high as 18%. However with more typical use cases, e.g. strings, the cost is in the noise level. I've measured cases with very cheap hash functions (int) that using a power-of-2 number of buckets can make look up about twice as fast. However I've also noted that a power-of-2 number of buckets is more susceptible to accidental catastrophic collisions. Though I've also noted that accidental catastrophic collisions are also possible when using a prime number of buckets (but seems far less likely). In short, this patch adds an extra tuning knob for those clients trying to get the last bit of performance squeezed out of their hash containers. Casual users of the hash containers will not notice the introduction of this tuning knob. Those clients who swear by power-of-2 hash containers can now opt-in to that strategy. Clients who prefer a prime number of buckets can continue as they have. 2012-07-06 17:31:14 +00:00
swap_member.pass.cpp license change 2010-11-16 22:09:02 +00:00
types.pass.cpp license change 2010-11-16 22:09:02 +00:00