unordered profile mode patch

François Dumont frs.dumont@gmail.com
Mon May 6 20:00:00 GMT 2013


Hi

     Here is the patch to fix the unordered containers profile mode. 
There are a number of enhancements/fixes:
- Use inheritance to play code on instantiation/destruction. This way 
some constructors and assignment operators can be defaulted like in the 
normal implementation and then be deleted if the normal implementation 
has his special function deleted.
- Extend the Inefficient Hash diagnostic to the unordered_multiset and 
unordered_multimap. Surprisingly __profcxx_hashtable_destruct2 was 
called without __profcxx_hashtable_construct2 so having only the 
performance drawback without beneficing from the diagnostic result. I 
implemented it by simply ignoring equivalent elements.
- Do not collect data for the Inefficient Hash diagnostic if it is not 
On, it is a costly operation.
- Use an implementation detail, the cached hash code, when possible. 
This is good for performance and mandatory for robustness because the 
hash functor can throw and the code is called from the destructor. Some 
tests were failing because of that since I had the 
__gnu_cxx::throw_value_* hash functor to conditionally throw.
- Remove useless non-Standard insert(const value_type*, const 
value_type*) overloads.

I also add a missing & in the MoveOnly equality functor signature of 
55043.cc test file. I don't think it was intentional and it was a 
problem for the profile modes that uses it.

Regarding usage of cached hash code I realized that none of the Standard 
methods of the unordered containers allowed to benefit from it. There is 
no gate between iterator and local_iterator. Has a size_type 
bucket(const_iterator) signature been discussed ?

Tested on x86_64 linux profile mode.

2013-05-07  François Dumont <fdumont@gcc.gnu.org>

     * include/profile/unordered_base.h: New.
     * include/Makefile.am: Add new profile header.
     * include/Makefile.in: Regenerate.
     * include/profile/impl/profiler.h
     (__profcxx_inefficient_hash_is_on): New macro.
     * include/profile/unordered_map (std::profile::unordered_map<>):
     Use new _Unordered_profile base class. Use default implementations
     for special functions.
     (std::profile::unordered_multimap<>): Likewise.
     * include/profile/unordered_set (std::profile::unordered_set<>):
     Likewise.
     (std::profile::unordered_multiset<>): Likewise.
     * testsuite/23_containers/unordered_multiset/55043.cc: Fix
     MoveOnly equality operator signature.

Ok to commit ?

François

-------------- next part --------------
A non-text attachment was scrubbed...
Name: profile.patch
Type: text/x-patch
Size: 33573 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20130506/2a2c2f85/attachment.bin>


More information about the Gcc-patches mailing list