Optimize hashtable allocator

François Dumont frs.dumont@gmail.com
Wed Oct 31 22:15:00 GMT 2012


On 10/30/2012 10:26 PM, Jonathan Wakely wrote:
>
>      I try to adapt pretty printer code but haven't been able to test it as I
> don't have the necessary gdb version and don't have time to update it at the
> moment. If you prefer I can leave it untouched.
> Please try to install a newer GDB, building it is as simple as
> ./configure --prefix=PREFIX && make install and takes a few minutes.
> You need GDB 7.x for GCC 4.7 anyway, which would also be new enough to
> test the pretty printers.  Either test the changes or don't change the
> printers.
     Are you sure all GDB 7.x should work ? I have gdb 7.1 and when 
running pretty printers tests I have:

Spawning: gdb -nw -nx -quiet -batch -ex "python print 
gdb.lookup_global_symbol"
ESC[?1034hTraceback (most recent call last):
   File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'lookup_global_symbol'
Error while executing Python code.
UNSUPPORTED: prettyprinters.exp

>
>>   By the way, there is suspect
>> code in it. It tries to deal with std and std::tr1 unordered containers
>> through the same python code but it won't work anymore for iterators. They
>> are different in std and tr1 modes so there are adaptations missing if we
>> still want to support both versions.
> Yes we want to support both.
>
> Can the difference between the iterators be handled easily the same
> way I changed the printers to use _M_h when necessary, or should be
> just have separate StdHashtableIterator and Tr1HashtableIterator
> printers?

Yes, I think the same code could deal both type of iterators.

>
>
>> 2012-09-29  François Dumont  <fdumont@gcc.gnu.org>
> 2012-10  :)
>
> +
> +      template<typename _Alloc>
> +	_Before_begin(_Alloc __a)
> +	  : _NodeAlloc(__a)
> +	{ }
>
> Can this use a "universal reference" (to use Scott Meyers's term) to
> avoid a copy?
>
>        template<typename _Alloc>
> 	_Before_begin(_Alloc&& __a)
> 	  : _NodeAlloc(std::forward<_Alloc>(__a))
> 	{ }
>
> There's no need to use Doxygen for _Before_begin, it's not for end users.
>
     Here is the patch I came to. I use the 'universal reference' like 
you propose but some tests started to fail because I think gcc called it 
instead of the move constructor. Making those constructors explicit, 
even if using default implementation, fix the tests. I still need to 
check if tests are checking instantiation of unordered containers 
passing an allocator instance to confirm that the universal reference 
behaves correctly. I should be able to do so next week.

François

-------------- next part --------------
A non-text attachment was scrubbed...
Name: hashtable.patch
Type: text/x-patch
Size: 11041 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20121031/c3d45ea0/attachment.bin>


More information about the Libstdc++ mailing list