<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><span class="vcard"><a class="email" href="mailto:eric@efcs.ca" title="Eric Fiselier <eric@efcs.ca>"> <span class="fn">Eric Fiselier</span></a>
</span> changed
              <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED DUPLICATE - Performance of unordered_multimap::insert much slower than GCC 4.8.2"
   href="https://llvm.org/bugs/show_bug.cgi?id=21275">bug 21275</a>
        <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">Status</td>
           <td>ASSIGNED
           </td>
           <td>RESOLVED
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Resolution</td>
           <td>---
           </td>
           <td>DUPLICATE
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED DUPLICATE - Performance of unordered_multimap::insert much slower than GCC 4.8.2"
   href="https://llvm.org/bugs/show_bug.cgi?id=21275#c12">Comment # 12</a>
              on <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED DUPLICATE - Performance of unordered_multimap::insert much slower than GCC 4.8.2"
   href="https://llvm.org/bugs/show_bug.cgi?id=21275">bug 21275</a>
              from <span class="vcard"><a class="email" href="mailto:eric@efcs.ca" title="Eric Fiselier <eric@efcs.ca>"> <span class="fn">Eric Fiselier</span></a>
</span></b>
        <pre>
(In reply to <a href="show_bug.cgi?id=21275#c11">comment #11</a>)
<span class="quote">> As explained at the top of this PR, the current implementation of libc++'s
> unordered_map and unordered_multimap is wildly uncompetitive with GCC with
> and without hints.</span >

The problem you describe at the top of this PR is exactly the same as PR16747.
While you may not agree with the resolution this problem has been discussed and
decided on. 

ALso you ONLY describe a problem with std::unordered_multimap. I have yet to
see how libc++'s std::unordered_map is uncompetative with GCC's. I have spent
time benchmarking both implementations and I do not see the problem. Could you
explain further?

<span class="quote">> One cannot possibly know
> the key distribution in advance, so the libc++ implementation of
> unordered_map and unordered_multimap is simply not usable in its present
> form on large data sets. </span >

While that is somewhat true for unordered_multimap PR16747 describes how to use
unordered_multimap to get the behavior and performance you desire.

You once again mention std::unordered_map but I don't know what your refering
too. The problem only exists in std::unordered_multimap.



<span class="quote">> Surely libc++ can be adapted to do something similar to GCC libstdc++'s
> superior algorithm? All the has to be done is to keep a pointer to the end
> of the values in the hash bucket and check that value first instead of doing
> a pointless and inefficient sequential scan.</span >

I've looked into making changes to add an "bucket end" pointer but it seems
quite complicated.

First you have to understand that a change like this is made harder by the fact
we can't introduce ABI breaking changes. That means I cant actually add any new
class data members to any data type in std::unordered_multimap. This makes the
change a lot harder then simply adding a new list of bucket pointers.

Second, std::unordered_multimap and std::unordered_map are implemented using
the same underlying container `__hash_table`. Any changes made to
`__hash_table` to support std::unordered_multimap MUST NOT introduce needless
overhead to std::unordered_map. I don't see how we can easily make the changes
you describe without affecting std::unordered_map.


While I don't agree with Howard Hinnants decision to make
std::unordered_multimap do insertions at the end I don't think I can change the
existing behavior. If any change is going to be made to fix the performance
problems it should be to do insertions at the front. 

I'm closing this bug as a duplicate of PR16747. If I missed a performance
problem in std::unordered_map please reopen this bug.

*** This bug has been marked as a duplicate of <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED WONTFIX - Poor performance of degenerated unordered_multimap"
   href="show_bug.cgi?id=16747">bug 16747</a> ***</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>