<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 --- - Poor performance of degenerated unordered_multimap"
href="http://llvm.org/bugs/show_bug.cgi?id=16747">16747</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Poor performance of degenerated unordered_multimap
</td>
</tr>
<tr>
<th>Product</th>
<td>libc++
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</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>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>All Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>hhinnant@apple.com
</td>
</tr>
<tr>
<th>Reporter</th>
<td>gs.libcxx.bug@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>The following code uses an unordered_multimap to associate very few values with
a long list of values. The example performs very poor compared to libstdc++ and
the std lib implementation of Visual Studio 2012.
#include <chrono>
#include <iostream>
#include <string>
#include <unordered_map>
int main (int argc, char* argv[]) {
const int N = (argc > 1) ? std::stoi(argv[1]) : 123456;
const auto begin = std::chrono::high_resolution_clock::now();
std::unordered_multimap<int, int> map;
for (int i = 0; i < N; ++i) {
map.insert({i % 4, i});
}
const auto end = std::chrono::high_resolution_clock::now();
const auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(end -
begin);
std::cout << "Duration for " << map.size() << " integer inserts: " <<
ms.count() << "ms" << std::endl;
}
Results on Linux (SLES 11.2):
=============================
clang-3.2 with libc++ from 2013-01-31:
Duration for 123456 integer inserts: 21605ms
clang-3.3 with libc++ from 2013-01-31:
Duration for 123456 integer inserts: 21836ms
gcc-4.6 with GLIBCXX_3.4.16:
Duration for 123456 integer inserts: 7ms
Results on Windows 2008 Server:
===============================
Visual Studio 2012 SP3:
Duration for 123456 integer inserts, count=123456: 15ms
Results on OS X 10.8.4:
=======================
Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn):
Duration for 123456 integer inserts: 18702ms
The Linux and Windows results are on the same hardware, the OS X test was run
on a Mac Pro 2.93GHz and has similar performance to the Linux/Windows hardware.
I am building an inverse map for fast look-up. In most cases this works fine.
In rare cases the map degenerates to a few values being mapped to a long list.
In these rare case the performance deteriorates badly compared to other
implementations.</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>