<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Performance of unordered_multimap::insert much slower than GCC 4.8.2"
   href="http://llvm.org/bugs/show_bug.cgi?id=21275">21275</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Performance of unordered_multimap::insert much slower than GCC 4.8.2
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libc++
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.4
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>All Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>zaxxon2011@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu, mclow.lists@gmail.com
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The performance of unordered_multimap::insert is very slow in LLVM libc++ 
when used on large data sets that have degenerate non-uniform key distribution. 

// g++ -std=c++11 -O3 umm.cpp -o umm && time ./umm
// 13.5s for Apple LLVM version 6.0 (clang-600.0.51) (based on LLVM 3.5svn).
// 0.016s for GCC version 4.8.2.
#include <unordered_map>
int main() {
    std::unordered_multimap<int,int> m;
    for (int x = 0; x < 100000; ++x)
        m.insert(std::pair<int,int>(x%4, x));
    return 0;
}

I recognize that a another ticket was filed on this issue and marked as
WONTFIX. 
But even using max_load_factor() does not help LLVM libc++ get anywhere near 
the performance of GCC. 

One cannot always know in advance what the key distribution of the data set
will 
be - it can be uniform or degenerate. Data sets can be multi-gigabyte and would 
not be conducive to multiple passes to determine key distribution. As a 
workaround I used #ifdefs with an ordered std::multimap on Mac which is only 
twice as slow as GCC 4.8.2 libstdc++'s unordered_multimap for this scenario, 
which is not ideal.</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>